Join our Newsletter — 33% off our NHI Course
Home› FAQ› Authentication, Authorisation & Trust› How should teams handle stolen session tokens and…
Authentication, Authorisation & Trust

How should teams handle stolen session tokens and API keys in client applications?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated October 22, 2026 Domain: Authentication, Authorisation & Trust

Treat stolen tokens as a runtime trust problem, not only a credential problem. If an attacker can reuse a secret without proving the app is genuine, the backend is trusting possession instead of current integrity. Bind sensitive API access to runtime attestation, shorten token lifetimes, and revoke any credential path that can be replayed outside a verified application state.

When session tokens and API keys stop being “just secrets”

Session tokens and API keys are often treated as static credentials, but in client applications they function as bearer access. If they can be replayed from another device, process, or runtime state, the real problem is not only theft, it is that the backend accepted possession as proof. The practical question is how to reduce replay value and make stolen material useless outside the intended application context.

That distinction matters because client-side exposure is common in mobile, desktop, browser, and embedded app environments. Keys can leak through logs, reverse engineering, memory inspection, debug builds, proxying, or insecure storage. Once a secret is copied, the defender has to assume the attacker can use it until the access path is constrained, revoked, or bound to a stronger proof of legitimacy.

For API keys, a useful baseline is to treat them as high-risk bearer credentials and manage them with explicit lifecycle controls. NHIMG’s API Key Management Guide covers scoping, rotation, revocation, and when a stronger mechanism is appropriate. For client-distributed secrets specifically, the important judgement is whether the key can be limited to a narrow audience, short lifetime, or constrained usage pattern before it ever leaves the trusted boundary.

What to change when the secret can be replayed

The safest response is to reduce the usefulness of the stolen token, not to hope the attacker will be detected before use. Short-lived session tokens and access tokens narrow the replay window, while revocation removes the credential path entirely when compromise is confirmed. Where the app supports it, bind the access path to the current runtime state so a copied token is insufficient on its own.

That is why sender-constrained tokens matter. Proof-of-possession style approaches, such as RFC 9449: OAuth 2.0 Demonstrating Proof of Possession (DPoP) and RFC 8705: OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound Access Tokens, are designed to make a stolen bearer token harder to reuse from an untrusted context. If the application cannot prove itself in a fresh runtime, the backend should not treat token possession as sufficient.

In practice, this also means checking whether the access model is too broad. An API key that can reach multiple environments, tenants, or sensitive functions turns a single leak into a wide incident. The right fix is usually to shrink scope, separate environments, and remove long-lived credentials from client code rather than simply adding more monitoring around them.

How teams should respond when compromise is suspected

When a client token or API key is suspected stolen, treat it as an active access incident, not a routine credential hygiene task. Revoke the credential path first, then determine whether the token was session-only, refresh-capable, or linked to broader service access. The response differs materially because a stolen session token may indicate immediate user impersonation, while a leaked API key may expose an integration or backend workflow.

Teams should also look for signs that the stolen secret was used before revocation. That means checking access logs, token issuance and refresh events, unusual geography or device patterns, and requests that succeeded outside the app’s normal runtime profile. NHIMG’s Guide to the Secret Sprawl Challenge is useful here because the same leak paths that expose API keys often expose adjacent secrets, service credentials, and pipeline material that expand the blast radius.

Where the access path is app-mediated, teams should also verify whether the client can be distinguished from replay. If a token can be replayed unchanged from a different device or environment, assume the access layer is too permissive. If the application has no way to prove integrity at runtime, reduce the trust placed in that client and move sensitive operations behind a stronger control.

Risk and Threat Considerations

Stolen session tokens and API keys are attractive because they convert one compromise into immediate access with little attacker effort. The main risk is not token theft alone, but token replay, privilege abuse, and lateral access through integrations that trust bearer material more than runtime state.

Failure mechanism: A copied token is accepted outside the original application context because the backend does not verify current integrity, sender binding, or audience restriction. That lets attackers reuse the secret from an uncontrolled environment until expiry or revocation.

Impact: Attackers can impersonate users, automate API abuse, exfiltrate data, trigger downstream actions, or pivot into adjacent systems that trust the same credential path. The longer the lifetime and the broader the scope, the larger the blast radius.

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 define the specific risk controls and attack patterns relevant to this topic.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-02 — Secret LeakageClient tokens and API keys are secrets whose exposure creates replayable access risk.
NHI-07 — Long-Lived SecretsThe question centers on shortening lifetimes to reduce the value of stolen client credentials.
NHI-10 — Human Use of NHIClient tokens and API keys should not be treated as reusable human-accessible bearer material.
Recommendation — Remove leaked secrets from client apps and rotate any exposed credential immediately. Replace long-lived client secrets with short-lived credentials and revoke stale paths. Prevent end users from extracting and reusing production credentials in client software.
OWASP API Security Top 10API2 — Broken AuthenticationStolen tokens succeed when the API accepts copied bearer material as authentication.
API8 — Security MisconfigurationWeak token scoping, audience handling, or replay tolerance often stems from API control misconfiguration.
Recommendation — Require stronger client proof so copied tokens alone cannot authenticate. Harden token audience, expiry, and validation settings to block replay.

Practitioner Guidance

What to verify: Confirm whether the exposed secret is a bearer token, a refresh-capable credential, or a key with direct backend authority. If it can be replayed without proof of the client’s current state, treat it as inherently reusable and prioritize binding or replacement over simple monitoring.

Decision rule: If the secret can authorize sensitive production actions, revoke it and rotate any dependent credentials immediately. If revocation would break a customer workflow, move the workflow to a narrower, shorter-lived, or sender-constrained model before reissuing access.

What good looks like: Sensitive API calls require a fresh, bounded proof of legitimacy, client secrets are not embedded where users can extract them, and any replayable credential has a short operational lifetime with a clear revocation path.

Practitioner takeaway: Treat token theft as an authorization-design failure, not just an incident response event, because the lasting fix is to make replay useless outside the intended runtime.

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.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 22, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org