Sectona at Infosecurity Europe 2025 | June 3–5 | ExCeL London
Stop by our booth (Stand C 95) for live demo of Sectona’s Modern Infrastructure Access Platform
Your application delegates authentication to an identity provider, follows the authorisation code flow, validates tokens, and implements code verification. The OAuth implementation passes security review. Production traffic flows through without incident.
Then an attacker extracts a refresh token from a compromised CI/CD pipeline, uses it to mint access tokens for six months, and exfiltrates customer data from APIs that never questioned the token’s legitimacy. The OAuth flow worked exactly as designed. The security failure occurred in the privileged access layer that OAuth specifications barely address.
Most OAuth and OIDC security guidance focuses on protocol compliance: use authorisation code flow, implement code verification, validate signatures, check token expiry. These practices prevent attacks against the authentication flow itself. They do not address how tokens become privileged credentials that require the same controls as database passwords or API keys.
1. Long-Lived Refresh Tokens
Refresh tokens with unbounded lifetimes accumulate across development environments, CI/CD systems, mobile apps, and service-to-service integrations. Each represents persistent access that survives password resets and account lockouts.
The specifications permit refresh token rotation but do not mandate it. Implementations that skip rotation create credentials that function identically to static passwords.
Service accounts present the worst case. A microservice authenticates once during deployment, receives a refresh token valid for a year, and stores it in environment variables or configuration files. Operators who rotate database credentials monthly ignore OAuth tokens entirely.
2. Token Storage Without Encryption
Access tokens and refresh tokens flow through application memory, logs, environment variables, secret managers, databases, and browser storage. Each storage point requires encryption at rest and access controls matching the privileges those tokens grant.
Developers encrypt database credentials but store OAuth tokens in Kubernetes secrets without encryption, LocalStorage without httpOnly flags, or application logs that flow to centralised logging systems.
The token itself contains no sensitive data. The risk lies in what that token can access.
3. Scope Creep and Over-Permissioned Tokens
Applications request broad scopes during initial authentication and never reduce privileges for specific operations. A token with user:admin scope performs routine read operations that require only user:read.
OIDC providers issue tokens with all requested scopes. Applications that fail to implement least-privilege access at the operation level grant every API call maximum permission.
Service-to-service authentication compounds this problem. Backend services authenticate with client credentials flow and receive tokens scoped to entire resource hierarchies than individual operations.
1. Client Credentials in Source Code
Client secrets appear in configuration files committed to repositories, hardcoded in mobile apps, embedded in frontend JavaScript, and stored in container images.
The OAuth client credentials flow treats client ID and secret as bearer credentials. Any system possessing both can obtain tokens. Rotating leaked client secrets requires coordinating changes across every dependent system.
Secret scanning tools that flag database passwords often fail to recognise OAuth client secrets as equally privileged credentials.
2. Token Introspection Without Rate Limiting
Resource servers validate tokens through introspection endpoints that query the authorisation server. Without rate limiting, attackers enumerate valid tokens by brute-forcing the introspection endpoint.
Introspection responses reveal token metadata including scopes, expiration, and associated user context. This information aids attackers in understanding token privileges and validity windows.
Implementations that cache introspection results introduce a window where revoked tokens continue to grant access until the cache expires.
3. Inconsistent Revocation Across Services
Organisations running microservices architectures implement OAuth providers that issue tokens, but individual services maintain their own revocation logic. Revoking a compromised token at the authorisation server does not guarantee that every resource server immediately rejects it.
Services that validate tokens through JWT signature verification never contact the authorisation server after token issuance. These services cannot detect revocation without implementing token introspection or maintaining synchronised revocation lists.
The gap between revoking a token and every service respecting that revocation creates a window for continued credential use.
1. Just-in-Time Token Issuance
Rather than issuing long-lived refresh tokens, systems can generate short-lived access tokens on demand through a just-in-time provisioning layer.
Administrative access represents the clearest use case. When an engineer requires elevated privileges, the system authenticates them, validates approval workflows, issues a time-bounded token with specific scopes, and revokes it automatically after a defined period.
This eliminates standing privileges. No refresh tokens persist in environment variables. Access tokens expire within minutes. The blast radius of a compromised token shrinks to the remaining validity window.
2. Scope-Based Session Recording
Systems that track database queries through privileged access management can apply the same recording to API calls authenticated via OAuth. Each token carries scopes that define permitted operations.
Correlation between token issuance and API activity reveals anomalous patterns. A token issued to a frontend application that suddenly queries backend administrative endpoints indicates compromise.
Recording complements the OAuth audit log maintained by the authorisation server. The authorisation server knows who received tokens and what scopes those tokens grant. Session recording captures what those tokens actually accessed.
3. Token Binding and Device Attestation
Binding tokens to specific devices or network contexts prevent stolen tokens from functioning when used from unauthorised locations.
Token binding mechanisms include certificate-based binding, network egress binding, and hardware attestation where tokens verify device integrity before granting access.
Mobile applications benefit most from device attestation. The application requests tokens that the authorisation server binds to hardware-backed keys.
1. Anomalous Token Usage Patterns
Baseline normal behaviour for each client and service account. Deviations from established patterns indicate potential compromise:
Machine learning models trained on OAuth token telemetry detect subtle anomalies that rule-based systems miss.
2. Refresh Token Rotation Enforcement
Track which clients implement refresh token rotation versus maintaining perpetual tokens. Clients that never rotate refresh tokens accumulate long-lived credentials that should trigger security reviews.
Automated policies can enforce rotation by expiring refresh tokens after a maximum lifetime regardless of usage.
Organisations should inventory all refresh tokens, identify those older than policy thresholds, and revoke them to force re-authentication through current authorisation flows.
3. Cross-Reference Token Activity with Identity Changes
Token revocation should occur automatically when identity attributes change. Password resets, role modifications, department transfers, and terminations must trigger immediate revocation of all associated tokens.
The gap between identity system changes and token revocation creates privilege escalation opportunities.
1. Centralised Token Management
Rather than distributing token validation logic across dozens of microservices, centralise verification through a gateway that validates token signatures and expiration, checks revocation status, enforces scope-based access control, and records token usage for audit purposes.
This architecture ensures consistent revocation enforcement. When a token is revoked, the gateway immediately blocks all access.
2. Dynamic Scope Reduction
Applications should request broad scopes during authentication but reduce scope when performing specific operations. This requires token exchange flows where the application exchanges tokens for reduced-scope versions.
Token exchange allows fine-grained least-privilege access without forcing users through repeated authentication flows.
3. Secrets Management Integration
OAuth client credentials, private keys for JWT signing, and encryption keys for token storage belong in secrets management systems, not configuration files.
Integration requirements include automated rotation of client secrets without service interruption, audit logging of which services access which credentials, and access controls limiting secret retrieval to authorised services.
Platforms such as Sectona provide unified secrets management that treats OAuth credentials with the same controls as database passwords and API keys.
Audit your OAuth implementations against these criteria:
1. The First Step
Review refresh token lifetimes across all clients and services. Identify tokens older than 90 days and revoke them. Implement rotation policies that automatically expire refresh tokens based on age.
Scan codebases and container images for hardcoded client secrets. Move discovered credentials to encrypted secret stores and rotate the compromised values.
2. Architecture Improvements
Implement centralised token validation that enforces revocation across all services. Deploy gateways that verify tokens before routing requests to backend systems.
Add token binding for high-privilege operations. Administrative actions and sensitive data access should require tokens bound to specific devices or network contexts.
3. Monitoring and Response
Deploy telemetry that tracks token issuance rates, scope usage, and access patterns. Configure alerts for anomalous behaviour including unusual geographic locations and volume spikes.
Establish runbooks for token compromise scenarios. Define who can revoke tokens, how quickly revocation propagates, and what evidence supports forensic investigation.
The OAuth and OIDC specifications provide authentication frameworks. Security requires treating the tokens they produce as privileged credentials demanding the same access controls, rotation policies, and monitoring applied to traditional secrets.
Solutions by Industry
Products
Resources
Customer Resources
Technical Support
Solutions by Industry
Products
Resources
Customer Resources
Technical Support
Solutions by
Industry
Products
Resources
Customer Resources
Technical Support