LLM API Header Size Limits at the Authenticated HTTP Boundary
LLM API header size limits need one aligned policy across the edge, gateway, application, and provider adapter. This guide applies RFC 9110 and RFC 9112 to authenticated user and agent traffic, covering per-field and aggregate limits, identity and tracing metadata, 4xx handling, request smuggling risk, test cases, and audit evidence. The target is deterministic rejection before prompt or model processing.

HTTP sets no universal maximum for one header field or the header section as a whole. RFC 9110 Section 5.4 leaves recipients to set practical limits and requires a server to return an appropriate 4xx response when request fields exceed what it will process. Ignoring an oversized field increases request smuggling exposure. An LLM API needs explicit limits because authentication and delegated identity often accumulate in headers. Tracing and model routing add more. Policy metadata does too. An unlimited policy is reckless, and five unrelated defaults are almost as bad.
TL;DR
- Set per-field and aggregate header limits for every authenticated LLM ingress. Cap the field count separately.
- Align limits and parsing behavior across the load balancer, gateway, application, and model adapter.
- Reject oversized fields with a defined 4xx response before prompt parsing or provider forwarding.
- Budget identity and tracing metadata instead of allowing unbounded claims or baggage.
- Test boundary values, duplicates, obsolete folding, invalid octets, and asymmetric hop limits.
HTTP leaves field limits to implementations
RFC 9110 says HTTP has no predefined limit for a field line, field value, or entire header or trailer section. Real servers impose ad hoc limits based on implementation and field semantics. That makes the deployed chain, rather than the protocol alone, the source of the effective maximum.
Use three distinct ceilings for request headers. Cap the bytes in one field line and restrict the complete header section by bytes. Set a field-count limit as its own control. Consider a separate limit for trailers if the route accepts them. Write the counting rules down, including whether they use wire octets before normalization or decoded characters after parsing.
An authenticated LLM request may carry Authorization, a signed identity context, tenant and role metadata, tracing fields, idempotency keys, model-routing hints, and content metadata. Put those fields on a paper strip during design review and mark a byte budget beside each one. The remaining blank space is the safety margin. This physical exercise quickly exposes a token carrying hundreds of group claims or tracing baggage copied through every agent hop.
Identity context needs a byte budget
Identity-aware policy depends on enough context to identify the user or agent and evaluate authority. That requirement does not justify copying an entire directory record into HTTP fields. Keep bearer credentials compact and validate them at a trusted point. Pass only the claims needed by the next decision point under an integrity-protected format.
Large group lists are a common source of growth. Prefer a stable subject identifier and policy-relevant roles, or resolve additional attributes at a trusted service when latency and availability requirements allow. Cap custom agent delegation chains and reject recursive or repeated metadata. The post-authentication gap calls for per-request authority, but per-request should still be bounded.
Tracing deserves the same discipline. Limit baggage member count and total bytes. Prevent callers from supplying internal-only routing or audit fields. Strip untrusted copies before setting authoritative values. A request ID should remain a short correlation value, not a container for serialized state.
Document which fields participate in authorization. Dropping an oversized optional trace field can be safe only when its absence cannot change framing or routing. Its absence also cannot change response semantics or policy. Authentication and delegation fields should fail closed.
Every hop must parse the same request
A typical model call passes through a CDN or load balancer, an API gateway, an identity-aware proxy, an application, and a provider adapter. If the edge accepts a larger header section than the gateway, clients see one rejection point. If the gateway truncates a field that the application interprets differently, the chain can reach opposite authorization decisions.
RFC 9110 explicitly warns that ignoring oversized request fields raises request smuggling risk. RFC 9112 Section 11.2 describes smuggling as exploiting parsing differences among recipients to hide additional requests inside an apparently harmless one. Header limits sit beside message-framing rules because both determine where one request ends and the next begins.
Set the public ingress limit at or below every downstream limit, leaving room for fields an intermediary adds. Better still, keep added metadata inside a measured budget and reject before forwarding when the next hop cannot accept the result. The OWASP API Security mapping for LLM endpoints treats configuration consistency as an API control, which is exactly the issue here.
Syntax rejection belongs beside size rejection
Size limits cannot compensate for permissive parsing. RFC 9112 Section 5 requires rejection of whitespace between a field name and colon. It deprecates obsolete line folding outside message/http and gives servers explicit rejection or replacement rules. RFC 9110 also treats CR, LF, and NUL inside field values as invalid and dangerous.
Choose strict behavior for authenticated LLM ingress. Reject invalid field-name whitespace and bare control characters. Reject prohibited folding, malformed singleton fields, and ambiguous duplicates before policy evaluation. Do not normalize a request into something one downstream recipient would parse differently.
Run syntax and size checks over the complete header section. RFC 9110 says a server must not apply the request to the target resource until it has received that complete section because later fields can contain credentials or conditionals. They can also contain misleading duplicates. Early routing may begin, but model or application action waits.
I would rather break one outdated client than keep two parsers that disagree about an authorization header. Compatibility has a lower value than a stable security boundary on an authenticated model route.
Choose a defined 4xx contract
RFC 9110 requires an appropriate 4xx response for request fields larger than the server wishes to process. RFC 6585 Section 5 defines 431 Request Header Fields Too Large for an oversized header section or individual field. A malformed field can use 400. The exact mapping belongs in the API contract and gateway configuration.
Keep the response small enough to survive the same constrained path. Include a correlation ID and a generic reason such as request_headers_too_large. Do not echo the offending field. Keep the bearer token and delegated identity value out of the response. If the system can safely identify a non-sensitive field by name, document that behavior and cap the error itself.
Reject before reading a large body when the protocol and server permit it. The request should create no model invocation, provider request ID, prompt log, or tool event. Rate-limit repeated oversized attempts by authenticated subject and source context, while preserving enough evidence to distinguish client drift from deliberate pressure.
The AI API security vendor guide explains why an inline enforcement point is useful for these early decisions. Header-size policy still needs alignment with the surrounding edge and origin.
Boundary tests need exact byte counts
Build fixtures exactly at the limit and on both sides, one byte below and one byte above. Repeat for a single field and total section size. Test the field count separately. Test large authorization tokens and repeated cookies. Run separate fixtures for tracing baggage. Add many small fields plus duplicate singleton entries, then use an intermediary-added identity value to push the forwarded request over the next-hop maximum.
Count wire bytes with the same rules as the deployed component. Include HTTP/1.1 requests with obsolete folding and invalid whitespace. Exercise HTTP/2 or HTTP/3 ingress that is translated into HTTP/1.1, since compression on one hop does not remove the uncompressed field-list constraints or the downstream wire limit.
Verify the rejection point and side effects. The gateway event should show the measured size and configured ceiling. It should also show status, identity if authentication completed safely, and zero forwarding. A packet capture should show a short 4xx response after a dense block of headers, with no prompt body crossing the gateway. The LLM security testing guide provides the regression pattern for retaining these negative fixtures.
Audit records should expose limit drift
Record the ingress protocol, authenticated subject when available, route, method, total measured header bytes, field count, triggered limit category, configured ceiling, policy version, status, and correlation ID. Keep field values out of this record. For a sensitive field, a field-name category such as authorization or identity-context is enough.
Monitor rejection counts by route and client version. Segment them by authenticated identity as well. A release that enlarges a delegation token should produce a visible cluster just above one threshold. A sharp spread of random oversized fields points to a different investigation. Do not publish a universal threshold as a performance claim; use the value actually configured and tested in each environment.
Review limits whenever a proxy, identity provider, tracing library, or LLM adapter changes. Keep a machine-readable limit inventory next to route policy. The smallest effective downstream limit and the space required for intermediary-added fields should determine the public contract.
DeepInspect
DeepInspect operates on authenticated HTTP traffic intentionally routed between users or agents and LLM endpoints. It can enforce route-specific field and section limits while validating identity and policy metadata. It can deny an oversized or malformed request before prompt content reaches the model. The decision can run alongside method, media-type, body-size, and model authorization policy.
A per-decision record can preserve measured sizes, the triggered rule, caller context, route, policy version, and outcome without copying credentials into logs. Edge and proxy limits still need coordinated configuration with origin limits. Direct traffic that bypasses the governed path remains outside this control.
Book a demo today.