They should stop putting credentials in URLs, even when redirects are limited to paths. Use server-side session state or opaque references, validate browser and server URL handling separately, and test for fragment-driven loops, redirect errors, and navigation-history exposure in OAuth-style flows.
Why This Matters for Security Teams
Secret leakage in browser redirect flows is a control failure, not just a coding mistake. When credentials, tokens, or one-time values are embedded in a URL, they can surface in browser history, logs, analytics, referer headers, error pages, and intermediary caches. That makes the issue especially dangerous in OAuth-style sign-in, magic-link, and delegated authorization paths where redirects are routine and often under-tested. The right question is whether the flow preserves secrets end to end, not whether a redirect is technically allowed.
Security teams often miss this because the redirect itself may appear harmless during review. The real exposure comes from how browsers, proxy layers, application telemetry, and support tooling process the full URL. Guidance from the OWASP URL Redirect Validation Cheat Sheet is useful here, but it must be paired with application-specific testing for history and logging side effects. The same pattern also matters for Non-Human Identity controls, because service credentials and automation tokens are frequently routed through orchestration flows that inherit browser-like behaviors when developers reuse human login patterns. In practice, many teams discover the problem only after a token has already appeared in logs or been replayed from a leaked redirect URL.
How It Works in Practice
The safest pattern is to remove secrets from the URL entirely. Use server-side session state, a short-lived opaque reference, or an authorization code that is exchanged server to server after the browser returns. If a redirect is needed, keep it limited to routing context, not authentication material. URL fragments are not a safe substitute for secrecy, because client-side handling can still expose values through scripts, browser navigation, or custom handlers if the implementation is inconsistent.
Implementation should be tested at several layers, because browser behavior and server behavior are not the same thing. Teams should validate:
- Whether query parameters, path segments, or fragments are written to logs, traces, or analytics.
- Whether redirect chains preserve, strip, or transform parameters in unexpected ways.
- Whether the application reads secrets from client-visible state at any point.
- Whether reverse proxies, WAFs, or SSO middleware rewrite URLs in a way that reintroduces exposure.
- Whether failure pages or exception handlers echo the full request URL back to users.
For automation-heavy environments, the OWASP Non-Human Identity Top 10 is relevant because leaked redirect values often become reusable credentials for workloads, bots, or agentic systems. The operational rule is simple: if a value can authenticate, authorise, or unlock a session, it should be treated as a secret and never placed where the browser or infrastructure can casually reproduce it. These controls tend to break down when legacy identity providers, SPA routing, and telemetry collectors all process the same URL differently because secrets are stripped in one layer but retained in another.
Common Variations and Edge Cases
Tighter redirect control often increases implementation overhead, requiring organisations to balance user experience against leakage risk. There is no universal standard for every browser quirk, so current guidance suggests testing the exact identity flow rather than assuming a pattern is safe because it works in one environment. This is especially true for embedded apps, mobile webviews, and federated login journeys where the browser may not expose state the same way a desktop session does.
One common edge case is the use of fragments in single-page applications. Fragments can reduce server visibility, but they do not automatically make a value safe if client-side JavaScript reads, stores, or forwards it. Another edge case is “limited” redirects that only accept a path. If the application appends sensitive parameters after validation, or if downstream components reconstruct the full URL, the limitation does not meaningfully reduce exposure. Teams should also treat post-authentication redirect destinations as part of the attack surface, because open redirect weaknesses can combine with secret leakage and turn a minor bug into a credential replay path. The broader AI and automation landscape raises the stakes further, as the Anthropic report on the first AI-orchestrated cyber espionage campaign illustrates how stolen tokens and session material can be weaponised quickly once exposed. Best practice is evolving, but the core principle is stable: keep secrets server-side, validate redirect targets separately, and test every layer that can copy or store the URL.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10, OWASP Agentic AI Top 10 and MITRE ATLAS address the attack and risk surface, while NIST CSF 2.0 and NIST AI RMF set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-02 | Secret handling in redirects can expose workload credentials and tokens. |
| NIST CSF 2.0 | PR.AC-1 | Redirect leakage can bypass intended access control and session boundaries. |
| NIST AI RMF | GOV-4 | AI and automation flows can inherit insecure redirect handling and leak credentials. |
| OWASP Agentic AI Top 10 | A2 | Agentic flows may pass sensitive state through browser-mediated redirects. |
| MITRE ATLAS | AML.TA0001 | Leaked tokens can support downstream abuse of AI systems and automation. |
Prevent agents from storing or forwarding secrets in any browser-visible redirect path.
Related resources from NHI Mgmt Group
- What do security teams get wrong about browser-based data leakage?
- How should security teams use browser detections to stop identity abuse?
- How should security teams stop browser sync from exposing corporate credentials?
- How should security teams stop browser-based attacks before account compromise occurs?