Use this when handling OAuth, personal access or session tokens.
Tokens
Tokens are issued credentials such as OAuth access tokens, personal access tokens or session tokens. Prefer short-lived, narrowly scoped tokens and protect refresh tokens like passwords.
1. Tokens (OAuth, PATs, session) grant access.
2. Short-lived; refresh securely.
3. Never log or put in URLs.
4. Revoke on compromise.
5. Prefer workload identity over long-lived tokens.
issuance → use → expiry/revocation
Context & applicabilityCommon mistakes · platform/version boundaries
- Tokens logged in application logs or URLs.
- Personal access tokens with broad scopes and no expiry (GitHub, Azure DevOps).
- Stored in browser localStorage, readable by XSS.
- Not revoked when the user or integration is removed.
Operational reference
Fast context before you go deeper.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Short-lived and narrowly scoped.
- Refresh tokens are as sensitive as passwords.
- Revoke on logout or compromise.
- Token lifetimes — short
- Token storage (no logs/URLs) — protection
- Revocation capability — incident response
ReferenceWhy it matters1 section · depth on demand
Token types and risks
| Token | Risk |
|---|---|
| OAuth access token | Short-lived; leaks in logs or URLs |
| Refresh token | Long-lived access if stolen |
| Personal access token (GitHub, GitLab) | Often broad scope and long expiry |
| Session cookie | Bypasses MFA if stolen (info-stealers) |
Set expiry, minimal scopes, monitor creation and use, and revoke on suspicion. Secret scanning (GitHub push protection) catches tokens in repositories.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
Tokens are credentials issued after authentication — OAuth access and refresh tokens, JWTs, session tokens, personal access tokens. Most are bearer tokens: possession is enough to use them, so they must be protected like passwords.
| Token | Lifetime guidance |
|---|---|
| Access token | Minutes to an hour |
| Refresh token | Longer; rotate on use; revocable |
| Personal access token | Expiry required; minimal scopes |
| Session cookie | Idle and absolute timeouts |
Protections: transmit only over TLS, store securely (not in localStorage for sensitive web apps), bind to client where possible (DPoP, mTLS), and monitor for token use from unexpected locations — token theft is increasingly used to bypass MFA.
Storage in apps
| Where | Advice |
|---|---|
| Browser SPA | In memory or httpOnly cookie via BFF; avoid localStorage |
| Mobile app | Keychain (iOS) / Keystore (Android) |
| Server | Secret manager or encrypted cache |
| CI/CD | Platform secrets or OIDC federation |
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Secrets Management → Tokens. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html · confidence 94%