Information Exposure Through Query String

ID

java.information_exposure_through_query_string

Severity

low

Remediation Complexity

medium

Remediation Risk

low

Remediation Effort

medium

Resource

Information Leak

Language

Java

Tags

ASVS50:v8.3.1, CWE:598, NIST.SP.800-53, OWASP:2025:A04, PCI-DSS:6.5.10

Description

Sensitive data — a password, token, secret or API key — is placed in a URL query string.

Rationale

Data in a URL query string is not protected the way a request body is: it is written to web-server and proxy access logs, kept in the browser history, and forwarded in the Referer header to third-party sites. Even over HTTPS the full URL, including the query string, routinely ends up in logs and history. Sending credentials or tokens this way exposes them well beyond the intended endpoint.

// VULNERABLE: the token lands in logs, history and Referer headers
String url = "https://api.example.com/data?access_token=" + token;
String login = "https://example.com/login?password=" + password;

Remediation

Send sensitive values in the request body of a POST/PUT request, or in an Authorization header — never in the URL query string.

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.example.com/data"))
    .header("Authorization", "Bearer " + token)
    .POST(HttpRequest.BodyPublishers.ofString(body)) // credentials go in the body, not the query string
    .build();

References

  • CWE-598 : Use of GET Request Method With Sensitive Query Strings