Security rules
NGB017: Sensitive data in URLs
Reports credentials (access tokens, passwords, API keys, session IDs) and payment data (card number, CVV) placed into URL paths, query parameters or fragments when building HTTP requests, navigation targets or query-parameter objects.
| Property | Value |
|---|---|
| Rule ID | NGB017 |
| Category | Sensitive data & payment security |
| Default severity | high |
| CWE | CWE-598 |
| Built-in presets | recommended: error, strict: error, payments: error |
Confidence is reported per finding (high, medium, low) and is independent of severity. See Reading findings.
What it checks
Reports credentials (access tokens, passwords, API keys, session IDs) and payment data (card number, CVV) placed into URL paths, query parameters or fragments when building HTTP requests, navigation targets or query-parameter objects. OAuth 2.0 / OpenID Connect protocol parameters (code, state, nonce, client_id, redirect_uri, code_challenge, id_token_hint, …) are not reported.
Why it matters
URLs are written to browser history, server and proxy access logs, analytics tools and the Referer header sent to third parties. Secrets in URLs leak through all of these channels and are hard to revoke after the fact.
Detection behavior and supported patterns
- Template literals and
+concatenation building URLs:/api?token=${token}(parameter name from the precedingname=), dynamic path segments HttpClient.get/post/put/patch/delete/request(url, …, { params: { … } }),fetch(url)new HttpParams().set/append(name, value),new HttpParams({ fromObject: { … } }),URLSearchParams.set/append,new URLSearchParams({ … }),url.searchParams.set(…)router.navigate(commands, { queryParams: { … } }),router.navigateByUrl(url),window.open(url),location.assign/replace(url),location.href = url- URL variables are followed through up to two
const/letinitializers
Example
this.http.get(`/api/report?access_token=${this.auth.accessToken}`);Safer alternative
this.http.get('/api/report', { headers: { Authorization: `Bearer ${this.auth.accessToken}` } });Remediation
Send secrets in request headers (Authorization) or a POST body. For one-time links, use short-lived single-use tokens exchanged server-side and remove them from the address bar with history.replaceState() after use.
False-positive considerations
- Protocols that require a token in the URL (e.g. signed download links, password-reset links received by e-mail) are reported; document an exception with the justification.
- Opaque payment references (
paymentToken,orderId) are intentionally not treated as payment data.
Known limitations
- URLs assembled in helper functions or with
URL/HttpParamsobjects passed between functions are not reconstructed. - Values are judged by names (parameter, variable, property, type) and traced names; an opaque variable like
xcarrying a token is missed.
References
Run it
ngbastion explain NGB017