Do not expose third-party secrets to browser-based agent tools unless the tool must call that service directly and the secret is tightly scoped. Prefer token brokering, short-lived delegated tokens, and server-side mediation so API keys, refresh tokens, and certificates stay out of the browser. If a secret must be handled client-side, isolate it per session and rotate it quickly.
Why browser-based agent tools should not hold third-party secrets
Browser-based agent tools sit in a high-exposure layer: they can be inspected, replayed, instrumented by extensions, affected by cross-site context, and reused in ways that are hard to constrain once a secret is present. The safer pattern is to keep third-party credentials server-side whenever possible and give the browser only short-lived, tightly scoped access that matches the exact task.
That design matters because the browser is usually the least defensible place to store API keys, refresh tokens, or certificates. Even when the user interface feels local, the control boundary is not the same as a protected backend, so a compromise of the session or page context can become credential exposure.
Where a browser-based agent must act on behalf of a user, the access model should be delegated, not copied. Token brokering lets a backend exchange or mint a narrow token for one service and one session, rather than placing reusable third-party credentials in the client. That keeps the authority needed for the task while reducing the blast radius if the browser context is lost.
How to handle secrets when the browser cannot be avoided
If client-side handling is unavoidable, scope the secret to a single session, make it short-lived, and bind it to the minimum service and action set. A browser-facing token should be treated as disposable access, not as a standing credential that survives beyond the user task or can be reused for unrelated calls.
Server-side mediation is the strongest default because it separates user interaction from upstream authentication material. The browser can submit intent, parameters, or a signed request, while the server performs the privileged exchange with the third party. That pattern also makes revocation, logging, and policy enforcement simpler when the external service changes its own access rules.
When teams need a concrete control model for this pattern, the AI Agent Tool and Plugin Security Guide is useful for scoped tool permissions and validation, and the API Key Management Guide covers scoping, rotation, revocation, and safe handling when keys are part of the workflow.
What teams should verify before trusting the design
Teams should verify that the browser never receives more authority than the task requires. That means checking whether the secret is actually needed client-side, whether the third party supports delegated tokens or brokered exchange, and whether the browser can be limited to a single audience, scope, and lifetime.
It also helps to test the failure case, not just the happy path. If the session is hijacked, if the page is refreshed, or if the token is copied into logs or developer tools, the design should either fail closed or leave behind an access token that is already too narrow and too short-lived to be useful outside that session.
For teams that want a broader credential lifecycle view, the Ultimate Guide to NHIs, Static vs Dynamic Secrets explains why ephemeral credentials are materially safer than long-lived ones, and the Secrets Management Guide covers centralization, rotation, and secretless patterns that reduce browser exposure.
Risk and Threat Considerations
Browser-based exposure creates a straightforward theft and misuse problem: once a third-party credential reaches the client, it becomes easier to copy, replay, or abuse outside the intended session. The risk is highest when the secret has broad API access, a long lifetime, or the ability to refresh itself without server-side oversight.
Failure mechanism: The browser context leaks the credential through inspection, injected code, logging, extensions, replay, or unintended reuse, and the attacker or another tool gains direct access to the third-party service.
Impact: Unauthorized API access, data exposure, privilege abuse, and difficult-to-contain compromise can follow, especially if the token or certificate can be reused across sessions or environments.
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 and OWASP API Security Top 10 address the attack and risk surface, while NIST SP 800-53 Rev 5 sets the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-02 — Secret Leakage | Browser-held third-party secrets create direct leakage risk. |
| NHI-07 — Long-Lived Secrets | The question centers on avoiding durable browser-stored credentials. | |
| NHI-05 — Overprivileged NHI | Client-side secrets should only carry the minimum third-party scope. | |
| Recommendation — Keep reusable secrets out of the browser and broker short-lived delegated access instead. Replace long-lived credentials with short-lived tokens and rotate them quickly. Scope browser-facing access to the minimum service, action, and lifetime needed. | ||
| OWASP API Security Top 10 | API2 — Broken Authentication | Client-side token handling affects whether third-party API auth can be abused. |
| Recommendation — Use brokered authentication so exposed client tokens cannot become standing API access. | ||
| NIST SP 800-53 Rev 5 | IA-5 — Authenticator Management | The issue is lifecycle control for secrets, tokens, and certificates. |
| Recommendation — Manage issuance, rotation, revocation, and storage of browser-used authenticators centrally. | ||
Practitioner Guidance
What to prioritise: Put the third party behind a broker or backend mediation layer first, then decide whether the browser needs any credential at all. If it does, treat the credential as a session artifact with the smallest possible audience and lifetime.
Decision rule: If the browser must hold a secret to complete the workflow, require short-lived delegated access, per-session isolation, and explicit revocation on session end or task completion. If the secret can be kept server-side without breaking the workflow, do that instead.
What to verify: Confirm that refresh paths, fallback logic, and debug tooling cannot silently widen access. A design is not safe just because the initial token is narrow if it can be renewed into a broader or longer-lived credential later.
Practitioner takeaway: The safest browser agent design is the one that never lets reusable third-party secrets cross the client boundary, and the second-best design is one that makes any client-side access disposable, narrowly scoped, and easy to revoke.
Related resources from NHI Mgmt Group
- How should security teams handle third-party credentials in MCP-based agent workflows without exposing secrets to the client?
- What are the implications of using OAuth tokens in third-party integrations?
- How should security teams prevent jailbreak prompts from reaching agent tools?
- Why do browser-based controls matter for contractor and third-party access?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on December 3, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org