CCyberwiki

Personal data in URLs

Personal data in URLs
ClassData exposure
Also known asSensitive data in the query string, information exposure through URLs
CWECWE-598: Use of HTTP Request With Sensitive Query String
OWASP Top 10A04:2025 Cryptographic Failures
Typical severityMedium; high when the address holds a working sign-in or reset token
AffectsPassword reset and sign-in links, OAuth callbacks, API calls with a token parameter, search and filter forms sent with GET

The address https://example.com/reset?token=8f2c91&email=anna@example.com is copied, with no action from the user, into the server's access log, the browser's history, the analytics report and, when the page loads a file from another site, into a request header that other site receives. A token, an email address or a health detail placed in a URL therefore reaches every system that records or forwards addresses. Encryption with HTTPS protects the address on the network only; each endpoint and every tool behind it sees the URL in plain text.1

The HTTP standard says that URIs "are intended to be shared, not secured" and calls it unwise to place anything sensitive or personally identifying in one.2

Where an address goes

On the server, the default access log format of nginx, combined, writes the full request line, so the path and the query string of every request are stored, along with the Referer the browser sent.3 Proxies and other servers on the way log the target address too.2 Personal data in logs covers logs that end up holding personal data.

In the browser, visited addresses stay in history and in the cache, end up in bookmarks and printouts, and can be read over a shoulder.1

A standard Google Analytics page tag reports the URL and title of each page viewed. Google's policy forbids sending it personal data and notes that such data often arrives through those URLs by accident.4 Third-party monitoring tools on the page receive the address in the same way.1 Third-party requests lists the kinds of files that cause these requests.

The Referer header

When a user follows a link, or a page loads an image, script or frame, the browser tells the destination which page made the request. The header can hold the origin, the path and the query string; it never holds the fragment after # or a user:password@ prefix.5 A reset page with a social media link in its footer can thus hand the reset address to that social network when the user clicks it, and an embedded third-party image does the same on every page load.6

How much is sent depends on the referrer policy, one of the HTTP security headers. Since a specification change in November 2020, a page with no policy uses strict-origin-when-cross-origin: requests to other sites over HTTPS carry only the origin, such as https://example.com/, and requests to plain HTTP carry nothing. The earlier default, no-referrer-when-downgrade, sent the full address to any HTTPS site, and a page that sets unsafe-url still does.7 Same-origin requests keep the full address under the default, so the site's own logs still record it.

A password reset email carries its token in the link's query string. The reset page should send Referrer-Policy: no-referrer, and the token should work once and expire.8 Account recovery describes the rest of that flow. A sign-in link that carries both a one-time code and the user's email exposes a credential and a login name together.1

OAuth returns an authorization code as a query parameter, and the callback URL lands in browser history. If the callback page links to other sites or embeds third-party images or ads, the code and the state value can leak through Referer. The countermeasures are to keep third-party content and outside links off that page, invalidate each code after its first use, and bind the code to a client secret or a PKCE challenge, so that an attacker who copies it lacks the secret needed to exchange it.9 The implicit flow, which returns the access token in the fragment, is exposed in another way: a browser re-attaches the fragment when a redirect has none of its own, so an Open redirect on the app can forward the token to the attacker's page.9

For API calls, the bearer token specification advises against ?access_token= unless neither the Authorization header nor the request body can be used, because such URLs are likely to be logged.10 Past CVEs include a security camera that sent its password in the query string and a communication product that put an access token in a GET request.11

HealthCare.gov, 2015

In January 2015 the EFF confirmed a report by the Associated Press that the US health insurance marketplace sent personal health details to at least 14 third-party domains, including DoubleClick, Akamai and YouTube, even when the browser's Do Not Track setting was on. The plan search page placed the visitor's answers in its own address, for example (shortened) /see-plans/85601/results/?age=40&smoker=1&pregnant=1&zip=85601&state=AZ&income=35000. The embedded trackers received that address in the Referer header, and some also received it inside their own request URL. Google told the EFF that DoubleClick logged and kept the data but did not use it to pick ads.12

Keeping data out of addresses

Personal data and secrets go in the request body or in headers.11 An HTML form sends its fields in the URL unless told otherwise, because get is the default method:13

<form method="post" action="/account/email">
  <input name="email" type="email">
</form>

API tokens travel in the Authorization header:

await fetch("/api/orders", {
  headers: { Authorization: `Bearer ${token}` }
});

Where a link has to carry a token, the server reads it and then redirects to a clean address it generated, so later links and page views no longer contain it.2 Pages that receive a token (reset, sign-in, OAuth callback, payment) carry no third-party scripts, images or frames, and send Referrer-Policy: no-referrer as a header or as <meta name="referrer" content="no-referrer">. Single links can use rel="noreferrer", written without a dash.67 Google Analytics can strip email addresses on a best-effort basis and drop named query parameters, with data redaction, set in the Admin section for web data streams.4

Prompt for a coding agent

Find every place in this project where a token, password, one-time code, session id, email address, phone number or other personal detail is put into a URL: links built in code or in email templates, fetch or axios calls with a token query parameter, redirects, and HTML forms without method="post". Move API tokens into the Authorization header and form data into POST bodies. Where a link must carry a token (password reset, magic link, OAuth callback), read the token on the server, then redirect to an address without it, and make the token single use with an expiry. Add Referrer-Policy: no-referrer to those pages and remove any third-party scripts, images or iframes from them. List each file and line you changed.

In SecFlash

On the Security page, SF-SEC-638 reports an address that holds a password, token, email or card number, SF-SEC-654 a session id in the address, SF-SEC-656 such an address sent to other sites in the Referer header, and SF-SEC-107 a site with no Referrer-Policy. SF-EXP-210 on the Exposure page reports a public Apache status page, which lists the URLs being requested, query strings included.

See also

References

  1. a b c d Gilbert, Robert. "Information exposure through query strings in URL". OWASP Foundation.
  2. a b c "RFC 9110: HTTP Semantics", sections 10.1.3 and 17.9. IETF.
  3. back "Module ngx_http_log_module". nginx documentation.
  4. a b "Best practices to avoid sending Personally Identifiable Information (PII)". Google Analytics Help. Google.
  5. back "Referer header". MDN Web Docs. Mozilla.
  6. a b "Referer header: privacy and security concerns". MDN Web Docs. Mozilla.
  7. a b "Referrer-Policy header". MDN Web Docs. Mozilla.
  8. back "Forgot Password Cheat Sheet". OWASP Cheat Sheet Series.
  9. a b "RFC 9700: Best Current Practice for OAuth 2.0 Security", sections 4.1.2 to 4.3. IETF.
  10. back "RFC 6750: The OAuth 2.0 Authorization Framework: Bearer Token Usage", sections 2.3 and 5.3. IETF.
  11. a b "CWE-598: Use of HTTP Request With Sensitive Query String". Common Weakness Enumeration. MITRE.
  12. back Quintin, Cooper (20 January 2015, updated 21 January 2015). "HealthCare.gov Sends Personal Data to Dozens of Tracking Websites". EFF Deeplinks.
  13. back "<form>: The Form element". MDN Web Docs. Mozilla.