API Key Passed in the URL
The API accepts its API key or access token as a URL query parameter, so the credential is recorded in logs, browser history and other places that keep full addresses.
| Severity | Low |
| CVSS 3.1 | 3.7 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N Open in the calculator |
| CVSS 4.0 | 6.3 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-598: Use of GET Request Method With Sensitive Query Strings |
| OWASP Top 10 | A06:2025 Insecure Design |
| MITRE ATT&CK | T1552.001 Credentials In Files, T1550.001 Application Access Token |
| Category | Information Disclosure |
Description
The API expects, or accepts, its API key or access token in the query string of the request address, for example as an api_key, key, token or access_token parameter, rather than in a request header. Full request addresses are recorded in many more places than headers: web server, load balancer, proxy and content delivery network access logs, API gateway and monitoring logs, browser history and bookmarks where the request is made from a browser, and analytics and error-tracking services. Where a web page includes the address in a link or resource, the key can also be sent to other sites in the Referer header.
The key is therefore exposed to anyone with access to the logs and systems that record request addresses, which commonly include operations staff, third-party providers of hosting, content delivery, monitoring and analytics, and attackers who gain access to any of them. Because API keys are often long-lived and are not tied to a user session, a key recorded in any of these places remains useful to whoever later reads it: they can call the API with the key's permissions until it is revoked, without needing the user or application it was issued to. The impact depends on what the key allows and how long it remains valid, and is greater for keys with broad or administrative access.
The weakness is identified by observing credentials in the query strings of API requests made by the client and in documentation and code examples, and by checking whether an API that normally takes the key in a header also accepts it as a query parameter.
Remediation
Send credentials in headers, never in the URL:
- Accept API keys and tokens only in a request header, such as
Authorizationor a dedicated header likeX-API-Key, and reject requests that supply them as query parameters, so that clients cannot fall back to the insecure form. - Update client applications, integrations and documentation to send the header, and announce a date after which keys in query parameters stop working.
- Rotate every key that has been sent in a URL, as it should be assumed to be in logs already.
- Mask or remove credential parameters in existing logs, and configure servers, gateways and monitoring tools to redact them.
- Where a key has to be used from a browser, restrict it to the minimum permissions and to the allowed origins, and set a
Referrer-Policythat does not send full addresses to other sites.
Confirm the fix by checking that requests with the key in the query string are rejected and that logs no longer contain credentials.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.