Security rules
NGB029: Sensitive data in navigation state
Reports credentials and payment data written to browser navigation state: window.name (high severity — it survives cross-origin navigation), history.pushState() / replaceState() state objects, and Angular Router navigation state (router.navigate(…, { state }), navigateByUrl(…, { state })), which is stored in history.state..
| Property | Value |
|---|---|
| Rule ID | NGB029 |
| Category | Sensitive data & payment security |
| Default severity | high |
| CWE | CWE-200, CWE-922 |
| Built-in presets | recommended: error, strict: error |
Confidence is reported per finding (high, medium, low) and is independent of severity. See Reading findings.
What it checks
Reports credentials and payment data written to browser navigation state: window.name (high severity — it survives cross-origin navigation), history.pushState() / replaceState() state objects, and Angular Router navigation state (router.navigate(…, { state }), navigateByUrl(…, { state })), which is stored in history.state.
Why it matters
window.name belongs to the browsing context, not the origin: after the user navigates to (or is redirected to) another site, that site can read the value. History state is persisted by the browser for back/forward navigation and session restore, outlives logout within the tab, and is readable by any script on your origin.
Detection behavior and supported patterns
window.name = v,self.name = v,globalThis.name = vhistory.pushState(state, …),history.replaceState(state, …)on the DOMHistoryrouter.navigate(commands, { state: {…} }),router.navigateByUrl(url, { state: {…} })(Routerfrom@angular/router)- Sensitivity: names, declared types and data-flow names classified as credentials or payment data (see NGB014/NGB016)
Example
this.router.navigate(['/checkout/confirm'], { state: { cardNumber: form.cardNumber, cvv: form.cvv } });Safer alternative
this.checkout.setPending(form); // CheckoutService keeps it in memorythis.router.navigate(['/checkout/confirm']);Remediation
Pass secrets between views through an in-memory service, not through navigation state. Never use window.name as a transport; clear it (window.name = "") if a legacy flow used it.
False-positive considerations
- Opaque identifiers with credential-like names (
resetTokenId) can be reported.
Known limitations
- Angular
Location.go(path, query, state)and third-party routers are not covered. - State objects built in another function are classified by their names/types only.
References
Run it
ngbastion explain NGB029