Why AI tools produce this: AI coding tools produce this regularly, typically when prompted for a shortcut or a quick fix.
Why this matters
URLs leak: the full URL (token included) is recorded in server and reverse-proxy access logs, saved in browser history, and sent in the Referer header to every third-party CDN, analytics, and ad script loaded by the destination page. A token in a URL is a leaked token.
Send the token in the Authorization: Bearer … header, or in a POST request body. Never in the URL query string.
CWE-598: Use of GET Request Method With Sensitive Query Strings.
// ok: auth.oauth.access-token-in-url -- token sent in the Authorization header, not the URLexport function callApi(accessToken: string) { return fetch('https://api.example.com/data', { headers: { Authorization: `Bearer ${accessToken}` }, });}// ok: auth.oauth.access-token-in-url -- token in a POST body object property, not a URL query paramexport function exchange(accessToken: string) { return fetch('https://api.example.com/token', { method: 'POST', body: JSON.stringify({ access_token: accessToken }), });}// ok: auth.oauth.access-token-in-url -- a non-token query parameterexport const pagedUrl = 'https://api.example.com/items?page=2';// ok: auth.oauth.access-token-in-url -- the bare word access_token in a comment is not a URL paramexport const note = 'remember to refresh the access_token before it expires';
Suppressing this rule
If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.