← Blog

HTTP Request-Target Form Validation for LLM Gateways

Parminder Singh
Parminder Singh··7 min read
Summarize with AI

HTTP request-target form validation prevents an authenticated LLM call from being routed under conflicting target interpretations. This guide maps the four HTTP/1.1 forms in RFC 9112 to direct inference routes, forward proxies, CONNECT, and server-wide OPTIONS, then defines form-by-method policy, Host handling, target reconstruction, rejection behavior, fixtures, and audit evidence.

Platform & Architectureai-securityllm-securityzero-trustidentity-and-authorizationpolicy-enforcementarchitecture
HTTP Request-Target Form Validation for LLM Gateways

The first line of an HTTP/1.1 LLM request carries a method and request-target. That target can be an origin path, an absolute URI, an authority for a tunnel, or one asterisk for server-wide OPTIONS. Each form has a narrow protocol role. An LLM gateway should identify the form, bind it to the permitted method and deployment role, reconstruct one target URI, and authorize that result before forwarding prompt content.

TL;DR

  • Classify every HTTP/1.1 request-target as origin-form, absolute-form, authority-form, or asterisk-form.
  • Bind each accepted form to the method and authenticated route policy for that connection role.
  • Reject whitespace, malformed targets, duplicate or invalid Host fields, and form-method mismatches.
  • Reconstruct one target URI and use it for authorization, forwarding, cache keys, and audit evidence.
  • Exercise all four forms through the deployed gateway before release.

Four forms carry four protocol meanings

RFC 9112 Section 3.2 defines four request-target formats. The selected form depends on the method and on the presence of a proxy. The same section bans whitespace in the target and warns recipients against silently autocorrecting a malformed request line because crafted input can bypass filters along the chain.

Origin-form carries an absolute path and an optional query. The RFC requires this form for a direct request to an origin server, apart from CONNECT and server-wide OPTIONS. This is the expected form for a direct POST /v1/chat/completions call. An empty URI path becomes /, and the Host field supplies authority.

Absolute-form carries the complete absolute URI. The RFC requires this form when a client sends a request to a forward proxy, apart from CONNECT and server-wide OPTIONS. A proxy receiving absolute-form must derive Host from the request-target rather than trust a conflicting received Host value. RFC 9112 also requires an origin server to accept absolute-form, which means a gateway must parse it safely even when its normal clients use origin-form.

Authority-form contains only a host and port and is reserved for CONNECT. Asterisk-form contains only * and is reserved for server-wide OPTIONS. Allowing either form on an inference POST gives downstream components room to invent a path or authority that the policy never approved.

I would fail a gateway review if it passes an unknown target form to the application router. The request line is security input, and forgiveness here turns into disagreement one hop later.

Form policy belongs beside method policy

Create a form allowlist for each gateway listener and method. A reverse proxy serving an authenticated inference API will normally accept origin-form for POST and related API methods. A forward proxy may accept absolute-form after destination policy approves the target origin. CONNECT requires a separate tunnel policy and should stay disabled on a listener built only for inspected LLM HTTP traffic. Server-wide OPTIONS needs an explicit operational reason.

This split matters because CONNECT creates a tunnel. Once established, the gateway may lose the application-layer visibility needed to inspect the inner model request unless it terminates and governs that traffic under an approved design. A blanket CONNECT pass-through conflicts with a route that promises prompt inspection and per-request policy.

Bind form validation to the exact method token before body processing. A valid authority-form target on POST still fails. An asterisk on an inference route still fails. An absolute URI naming an unapproved provider origin still fails after syntactic form validation. Protocol validity opens the next policy gate; it never grants model access by itself.

The per-route AI policies guide explains the method, route, identity, and model fields surrounding this check. The AI egress control implementation guide covers the destination decision needed when a forward proxy receives absolute-form.

Host handling must produce one authority

HTTP/1.1 clients must send Host. The request-target rules require a 400 response when Host is absent or invalid. A duplicated Host field also requires a 400 response. For origin-form, Host supplies the authority used to reconstruct the target URI. For absolute-form, the authority in the request-target wins and the recipient regenerates Host from it.

RFC 9110 Section 7.2 calls host and port an application-level routing mechanism and identifies them as frequent targets for cache poisoning and unintended redirection. An LLM gateway should compare the effective authority with its approved origin manifest before forwarding sensitive content.

Do not run authorization against Host while the forward proxy routes on the absolute URI. Do not let the application use a forwarded host field that the edge treated as untrusted. Strip untrusted forwarding metadata and name the trusted proxy hops. Downstream components should receive one structured authority selected under the request-target rules.

Put a packet capture next to the policy event during review. The request line should show the accepted form and the Host line should show the effective authority. The event should name the same normalized origin. A mismatch visible across those lines is enough to block release.

Target reconstruction must be deterministic

RFC 9112 Section 3.3 defines target URI reconstruction. Absolute-form already supplies the target URI. Other forms combine trusted connection context with authority information and the request-target path and query. A gateway configuration can provide a fixed scheme, which is common when an inbound gateway terminates one connection and opens another.

Reconstruct the target once and attach the result to the request context. Route authorization, cache keys, forwarding, metrics, and audit records should consume that structured value. Reconstructing it independently in each layer recreates the ambiguity that validation was meant to remove.

An empty authority on HTTP or HTTPS needs a rejection unless the server can uniquely identify a safe configured default from the connection context. RFC 9112 warns that supplying a default name on a secured connection is inherently unsafe when the client's intended authority might differ. A generic fallback hostname is therefore a poor fit for a multi-tenant LLM gateway.

The LLM API authority validation guide covers the origin, TLS identity, DNS, and connection checks that follow reconstruction. Form validation supplies the protocol-correct input to that decision.

Rejection should happen before prompt processing

Parse the request line under a strict size limit, classify the target form, validate syntax, enforce the form-method pair, and validate Host before reading or forwarding a large request body. Return a small 400 response for malformed syntax or invalid Host under the HTTP/1.1 rules. Use the gateway's documented deny response for a syntactically valid form that policy forbids.

Avoid redirect-based repair for authenticated inference calls. RFC 9112 permits a 301 response with a properly encoded target as one response to an invalid request line, but a production API gateway can choose a closed 400 outcome. Repair and retry logic can expose a sensitive body to another target or cause a client to change method semantics.

Keep the denial body stable by including a correlation identifier and a coarse reason such as invalid_target_form or form_method_mismatch. Use invalid_host when Host validation fails. Omit parser traces, internal hostnames, provider credentials, and prompt fragments.

Acceptance fixtures must cover every form

Start with an origin-form POST to an approved inference route and confirm model invocation. Exercise absolute-form through the intended forward-proxy listener against an approved origin and an unknown origin. Test a conflicting Host field separately. Authority-form with CONNECT belongs in tests for listeners where tunnels are denied and explicitly approved. Finish with asterisk-form under OPTIONS and POST.

Add whitespace, an empty target, duplicate Host lines, invalid Host syntax, an empty origin path, and an absolute URI without approved authority. Run each case through the deployed load balancer, gateway, application router, and adapter. A rejection must happen before model invocation, and every component must report the same effective target.

Retain authenticated identity, method, raw target form, normalized target URI, effective Host, connection context identifier, route policy version, decision, status, and correlation ID. A digest can represent the raw request-target when evidence policy avoids storing it directly. The LLM security testing guide provides the surrounding release-test pattern.

This guide stays inside authenticated HTTP traffic deliberately routed through the enforcement point. HTTP/2 and HTTP/3 use pseudo-header control data rather than the HTTP/1.1 request line and need their own validation profile. Direct provider calls and local model execution keep separate owners.

DeepInspect

DeepInspect can evaluate the reconstructed target of authenticated user and agent requests deliberately routed through its HTTP path to an LLM endpoint. That decision can bind identity context to method, normalized origin, route, model destination, and data policy before request content is forwarded.

The gateway and application remain responsible for strict HTTP parsing and trusted connection context. They also remain responsible for listener configuration. DeepInspect can preserve the resulting route-policy decision and correlation evidence for traffic that traverses the governed path. Bypass traffic and uninspected tunnels remain outside that boundary.

Book a demo today.