LLM Route URI Normalization Before Authorization
URI normalization before LLM route authorization gives the gateway and model adapter one canonical target for each authenticated call. This guide applies RFC 3986 and HTTP semantics to percent-encoding, reserved characters, dot segments, case, default ports, empty paths, query handling, rejection policy, release fixtures, and route-level audit evidence.

An authenticated LLM request reaches a route policy as a URI with a scheme and authority, followed by a path and optional query. Equivalent spellings can identify the same resource, while a small encoding change can alter the resource entirely. The gateway must parse and normalize that target once, authorize the normalized result, and forward the same interpretation to the model adapter.
TL;DR
- Parse the URI into components before decoding or comparing route text.
- Normalize scheme and host. Apply explicit RFC rules to percent-encoding, default ports, empty paths, and dot segments.
- Preserve reserved-character meaning and reject malformed or multiply encoded input.
- Authorize and forward one canonical target rather than letting each HTTP hop reinterpret it.
- Log the raw target digest, normalized route, policy version, and decision.
Percent-encoding changes route comparison
RFC 3986 Section 2.1 defines a percent-encoded octet as a percent sign followed by two hexadecimal digits. Hexadecimal letter case is equivalent, so a normalizer should use uppercase digits. That rule makes two encodings of the same octet comparable without changing the octet itself.
Unreserved characters have a broader equivalence. RFC 3986 Section 2.3 defines letters, digits, hyphen, and period as unreserved. The same applies to _ and tilde. A percent-encoded unreserved octet identifies the same resource as its literal character and should be decoded during normalization.
Reserved characters require the opposite care. A slash can delimit path segments, and its encoded form can represent data inside one segment. RFC 3986 says replacing a reserved character with its encoded octet can change interpretation. A gateway that decodes every percent sequence before splitting the path can authorize one route and forward another.
Parse components before decoding only the unreserved set used by the route contract. Keep encoded reserved characters encoded unless the application contract assigns them a precise meaning. Reject malformed triplets and input that would require a second decoding pass. The RFC warning against decoding the same string twice exists because a second pass can turn data into an encoding delimiter.
My blunt opinion is that permissive URI repair has no place in an authorization path. A malformed target deserves a denial, not a creative guess from whichever proxy sees it first.
Dot segments must resolve before route policy
A path can contain complete . and .. segments. RFC 3986 Section 5.2.4 defines the removal algorithm, including the rule that a parent segment removes the preceding output segment. The syntax-based normalization rules call for that algorithm even when implementations incorrectly skip reference resolution for an already absolute URI.
For an LLM API, route authorization should evaluate the path after dot-segment processing. A raw target that appears to begin with an approved prefix can resolve outside that prefix after normalization. Prefix checks against the raw string therefore belong nowhere near the final allow decision.
Decide how the API handles repeated and trailing slashes. Define separate rules for path parameters and encoded dot characters. RFC 3986 supplies generic equivalence rules, but an application still defines resource semantics for its own path. The safest route table uses exact normalized paths or a parser-aware template with named variables. A plain string prefix can collapse two resources into one authorization rule.
The per-route AI policies guide shows why normalized route identity must be bound to model permissions for the authenticated caller. Normalization supplies the stable route key used by that policy.
Case and default components need bounded rules
RFC 3986 Section 6.2.2.1 makes scheme and host case-insensitive. Other generic components remain case-sensitive unless the scheme says otherwise. Lowercase the scheme and host, then normalize percent-triplet hex digits. Preserve path case for an LLM API unless its route specification explicitly defines another rule.
RFC 3986 treats an empty path as equivalent to / for HTTP, and an explicit default port as equivalent to an omitted default port. Apply those rules when building the origin and route key. Keep non-default ports distinct because they name a different origin.
Query handling needs an application contract. Generic URI syntax defines the query component, while parameter names and decoding belong to the API. The API must also define duplicate handling and ordering. If model selection or response behavior can arrive through a query parameter, parse it once with a documented duplicate policy and include the effective value in authorization. Better still, keep sensitive inference parameters in a typed request body where the route contract can validate them.
The LLM API authority validation guide covers the scheme and host, plus port and TLS binding, around this route decision. URI normalization should produce the same authority key used by that check rather than creating a second destination interpretation.
One parser must own the canonical target
Put normalization after syntax validation and before route authorization. Forwarding the raw target after authorizing a normalized copy reopens the ambiguity at the next proxy or adapter.
On a whiteboard, draw the raw request target on a narrow paper strip entering one parser box. Only one arrow should leave that box, labeled canonical target. If separate arrows feed policy and logging, plus cache keys and forwarding, each output must carry the same structured object. Four independent string transformations create four chances to disagree.
A useful decision sequence is:
- Validate the request-target form and parse the URI into components.
- Reject invalid percent triplets and forbidden characters. Reject userinfo and unsupported schemes as well.
- Normalize scheme, host, port, and unreserved encodings. Then normalize the empty path and dot segments.
- Match the canonical origin and route for the method against authenticated policy.
- Forward the canonical target or deny the request before prompt content leaves the gateway.
RFC 9110 Section 4.1 adopts the RFC 3986 component definitions for HTTP and distinguishes absolute paths from other URI references. Use a standards-conforming parser that exposes those components. Avoid regex-only parsing for a security decision.
Release tests need equivalence and non-equivalence pairs
Build paired fixtures in which one set normalizes to the same route. Include host case changes, percent-triplet hex case, an encoded unreserved character, and an omitted default port. Include an empty HTTP path as well. Another set must remain different or fail. Cover path case changes, an encoded reserved delimiter, a non-default port, and malformed percent input. Add multiple encoding and traversal beyond the route root.
Run the fixtures through the deployed load balancer and gateway, then the application router and provider adapter. Capture each component's selected route without retaining a real prompt. The test fails if two components produce different canonical targets or if an unapproved raw target reaches the adapter. A denial after model invocation also fails the test.
Record authenticated identity, method, raw target digest, normalized scheme and authority, canonical path, effective query policy, route template, policy version, decision, and correlation ID. The LLM security testing guide provides a broader structure for positive and negative boundary fixtures.
This control covers authenticated HTTP requests deliberately routed through the enforcement point. Direct provider calls and local model execution require their own route and authorization controls. So do non-HTTP transports.
DeepInspect
DeepInspect can normalize and evaluate authenticated user or agent requests deliberately routed through its HTTP path to an LLM endpoint. The per-request decision can bind supplied identity context to the canonical method, origin, route, model destination, and data policy before prompt content is forwarded.
Each allow or deny event can preserve the canonical route, policy version, decision, and correlation context. The application remains responsible for defining route semantics and supplying trustworthy identity context. Direct traffic that bypasses the routed path remains outside this enforcement point.
Book a demo today.