How to fix: Bearer token in URL query string
Authorization: Bearer is fine, but a Bearer token in a URL query string can leak via logs.
Why it matters
Tokens in URLs appear in server access logs, browser history, Referer headers, and CDN logs, any of which may be accessible to third parties. A single log export or shoulder-surf leaks all active sessions.
Authorization: Bearer is fine, but a Bearer token in a URL query string can leak via logs. Matching only the parameter name would also flag ordinary one-time links (password reset, email verification), so this requires the value itself to look like a JWT or a long opaque token, and excludes common one-time-link paths.
How to fix it
- 1Send Bearer tokens only in the Authorization header
- 2Never accept tokens as query parameters (?token=...) in production endpoints
- 3If cookies are used, set Secure; HttpOnly; SameSite=Strict and add CSRF protection
Code examples
Correct: Authorization header
const response = await fetch('/api/resource', {
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
});Server: reject token in query string
app.use((req, res, next) => {
if (req.query.token || req.query.access_token) {
return res.status(400).json({
error: 'Tokens must be sent in the Authorization header, not the URL.',
});
}
next();
});References
Detected automatically by VulnRadar. The check id is api-bearer-header-leak, stable across every scan so you can filter or diff on it.
More api checks
- LowTRACE method referenced in API response body
- InfoREST endpoint allows DELETE
- LowGraphQL introspection field suggestions
- MediumGraphQL endpoint has no rate-limit headers
- LowOpenAPI server URL leaks internal host
- LowCORS preflight result not cached
- MediumJSONP callback parameter accepted
- InfoPUT method listed in Allow header
Questions
- How severe is Bearer token in URL query string?
- VulnRadar rates this high severity in the api category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id api-bearer-header-leak, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Bearer token in URL query string map to?
- It maps to CWE-598. In the OWASP Top 10 it falls under A02:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.