Reject Query-String Access Tokens on Authenticated LLM Routes
Authenticated LLM routes should reject access tokens carried in URI query parameters before normal routing, prompt parsing, or model forwarding. RFC 9700 prohibits clients from passing access tokens this way, while RFC 6750 documents the logging risk and makes the Authorization header the supported default. This guide defines ingress behavior, safe errors, logging controls, migration, and production tests.

An LLM route that accepts access_token in the URI can copy a bearer credential into proxy logs, browser history, tracing labels and analytics exports, or support screenshots before the authentication code runs. The safe ingress behavior is rejection. Credential redaction farther downstream arrives after several systems may already have observed the request target.
I want one line in the edge test report: the query-token fixture received a closed response, the sanitized event contains only the parameter name, the event contains no token value, and the provider adapter recorded zero outbound attempts.
TL;DR
- Reject an access token in the URI query before normal routing or prompt parsing. Cache lookup and tracing must also wait, along with model forwarding.
- Require the Bearer scheme in the
Authorizationheader for authenticated LLM API requests. - Return a stable authentication error and log only a sanitized reason, never the request target or token value.
- Test ingress and streaming paths, along with redirect and retry behavior, because one permissive listener can restore the leak.
Query parameters put bearer credentials on the request target
RFC 6750 Section 2.1 defines the Bearer authorization scheme for sending an OAuth access token in the Authorization request header. It says clients should use that method and resource servers must support it. This gives the authentication layer a standard field with one defined credential location.
The same RFC documented an older URI query method in Section 2.3. A client added access_token to the query component. The specification warned that this method had security weaknesses, including a high likelihood that the URL would be logged, and said it should stay unused unless header or form-body transport was impossible. It was documentation of existing deployment practice, rather than a recommendation for new API design.
The current OAuth security best practice removes that discretion. RFC 9700 Section 4.3.2 says clients must not pass access tokens in a URI query parameter as described by RFC 6750. Authenticated LLM APIs have full control over their clients and HTTP stack. They should enforce the stronger rule at every public and internal listener.
Rejection belongs before ordinary request processing
A request target is visible to infrastructure that runs ahead of application authentication. Reverse proxies can log it as soon as a connection reaches the listener. Tracing middleware may attach the raw path and query to a span. Rate-limiters, web application firewalls, service meshes, load balancers, and error trackers can each create another copy.
Place a credential-location check at the earliest request-target parsing point that can return a sanitized response. Run it ahead of route normalization and ordinary access logging. Cache lookup comes later, followed by prompt or JSON parsing. Provider selection and streaming setup must wait for the credential-location result on an LLM route.
Inspect the parsed query component for prohibited credential parameters under one canonical parameter-name policy. The standard name access_token is the first required rejection. If the deployment has legacy aliases, list them explicitly. Then retire them under a dated migration. Avoid fuzzy matching that blocks unrelated application parameters, and avoid decoding the same raw target differently in the security check and router.
The LLM route URI normalization guide covers parser agreement and the requirement to authorize the same target representation that the application forwards. Credential-location rejection should use that same parser boundary.
My blunt view is that accepting a query token and promising to redact it later is a logging incident with optimistic timing.
The Authorization header becomes the only token transport
Document one authentication contract for protected LLM routes: Authorization carries a Bearer credential, and the resource server validates it before constructing a principal. Missing or duplicated authorization fields receive the defined authentication response. So do malformed or unsupported fields. Query and form-body credentials receive a closed result under the route policy.
RFC 6750 allows a form-encoded body method only under a narrow set of conditions and discourages it except where a browser cannot use the Authorization header. JSON LLM endpoints already need their body for prompts, messages, model parameters, and tool definitions. Mixing an OAuth bearer token into that application body creates another parser and logging surface. A narrow enterprise LLM API can choose the header-only contract.
Keep inbound credentials separate from provider-facing keys or tokens. The gateway authenticates the caller at the enterprise boundary and authorizes the model request. It then selects a server-side provider credential. Forwarding the caller's Bearer token to the model provider can expose it and merge two security domains.
The LLM API authentication-challenges guide describes the 401 challenge contract and its separation from a 403 authorization denial. Query-token rejection belongs to authentication because the client used a prohibited credential transport.
Sanitized failure handling must avoid another copy
A rejection handler can still leak the token if it reflects the URI or includes a raw request object in an exception. It can also record the full target in a security event. Use a stable public message such as an invalid-request or invalid-token response aligned with the API's authentication contract. Include an opaque occurrence ID, without echoing the parameter value.
The protected event should record the listener, route family, method, verifier version, and reason such as query_credential_rejected. Record the prohibited parameter name only after canonical parsing. Add an outbound-attempt count and final result. Exclude the raw target, raw query, authorization header or bearer value, and any stack trace that serializes the request object.
Edge and application logs need compatible redaction rules because the edge may emit its access record before the application responds. Prefer dropping the entire query component from logs on authenticated LLM routes. If operational requirements need selected query fields, use an allowlist of harmless names and values. A denylist misses new aliases and encoding variants.
Set cache policy for authenticated prompt traffic independently. Cache-Control: no-store can reduce storage by conforming caches, yet it cannot retrieve a credential already copied into an access log. The no-store policy guide explains that narrower HTTP control.
Migration should fail visibly and quickly
Start with an inventory of every client, ingress hostname, route alias, SDK, CLI, webhook, and test fixture that can call the protected endpoint. Search configuration and source for the literal access_token query name, then inspect gateway telemetry using a process that never exports token values. The migration artifact should identify owner, route, last observed date, replacement release, and cutoff date.
Update clients to send the Bearer authorization header over TLS. For browser-based applications, keep tokens out of browser URLs and page content. For command-line examples, avoid placing credentials directly in command histories or process arguments. A client library should accept credentials through a protected configuration path and set the header itself.
Run a short warning period only when an existing contract requires it, but keep warnings out of normal request logs. At cutoff, reject the transport on all listeners at once. A canary that blocks only the newest hostname leaves the old route as a credential leak and bypass path.
Do not redirect a request containing a query token to a new URL. Redirect handling can preserve or expose the original target through referrer behavior. Logs and history can retain it too. Reject the credential at its arrival point and revoke the exposed token under the incident policy. Then require the client to obtain or present an appropriate credential through the header contract.
Production tests need the deployed logging path
Unit tests around an application framework miss the systems that make query credentials dangerous. Exercise the deployed load balancer, reverse proxy, service mesh, application, tracing collector, error tracker, and provider adapter. Use synthetic credentials that carry no production authority.
The release suite should include these cases:
- A valid Bearer token in the Authorization header passes authentication and reaches request-time model authorization.
- The same synthetic token in
access_tokenreceives the closed authentication response before model policy or provider forwarding. - Query parameter names vary by case, percent encoding, duplication, empty values, and delimiter placement according to the canonical parser policy.
- A request carries both a valid Authorization header and a query token. The route rejects the entire request instead of preferring one credential.
- GET, POST, streaming, batch, health-adjacent, and versioned route aliases apply the same rule where authentication is required.
- Redirect and retry middleware never replays or relocates a request that contains a prohibited query credential.
- Edge logs, application logs, traces, metrics labels, cache keys, error reports, and support events contain no synthetic token marker.
- Direct access to an origin or old hostname receives the same rejection, or the network blocks that bypass before HTTP processing.
Search every collected sink for the synthetic marker after the run. The fixture passes only when the marker appears in the test input and nowhere in retained telemetry. Confirm zero outbound model attempts alongside one sanitized decision event for each rejected request.
DeepInspect
DeepInspect applies identity-aware policy to authenticated user or agent traffic deliberately routed through its HTTP path to an LLM endpoint. The ingress and resource-server verifier should first enforce the header-only credential contract, reject query tokens, validate the accepted Bearer token, and supply trusted identity context. DeepInspect can then evaluate the route, model, tenant, and data classification for the request and produce a per-decision record.
DeepInspect does not recover tokens already exposed in browser history, proxy logs, traces, or direct provider calls. Credential transport, authentication parsing, token revocation, and challenge behavior remain with the client, ingress, authorization server, and resource server. Local runtimes and STDIO tools remain outside its evidence. So do HTTP paths that bypass the routed control point.
Book a demo today.
Frequently asked questions
- Does TLS make a query-string access token safe?
TLS protects the request in transit between authenticated channel endpoints. The request target still becomes visible to software at those endpoints, including reverse proxies, applications, tracing middleware, and browser history. RFC 6750 identified URL logging as a central weakness of the query method, and RFC 9700 now prohibits clients from passing access tokens that way. TLS remains mandatory, but it cannot control every copy created after decryption.
- Can the gateway accept the token and immediately redact it?
Infrastructure ahead of the redaction point may already have logged or traced the request target. Accepting the token also preserves a second credential transport. Every route and parser must support that transport securely. A header-only contract removes that ambiguity. The gateway should reject the request at the earliest parsed-target boundary and ensure upstream access logging omits query values on protected routes.
- What if an old client only supports query parameters?
Treat the client as a migration dependency. Give it an owner and cutoff date. Update it to set the Authorization header, then use synthetic tests to verify the replacement. If the client cannot support the required transport, place a controlled adapter in front of it only as a temporary, separately reviewed exception. That adapter still receives an exposed credential, so its edge logs, application logs, network path, and retirement date need explicit controls.
- Should a request with both header and query credentials be accepted?
The resource server should reject the entire request. Choosing the header while ignoring the query leaves a bearer credential in the URI and hides a client defect or probing attempt. Choosing the query violates the route contract. The protected event can record
multiple_credential_locationsorquery_credential_rejectedwithout retaining either value. The client must resend a clean request with one Authorization header after handling any exposed token under the incident policy.- Does `Cache-Control: no-store` solve the leakage problem?
no-storedirects conforming caches not to store a request or response. It cannot govern access logs, tracing systems, browser history, analytics, screenshots, or support exports. RFC 6750 recommendedno-storefor clients using its legacy query method, while also warning against the method. RFC 9700 supplies the current control: clients must not pass access tokens in URI query parameters. Rejection and telemetry hygiene address different copies.