Token Replay in Adonisjs
Token Replay in Adonisjs APIs
Token replay attacks occur when an authentication token, such as a JWT or session cookie, is accepted by the server for multiple requests without expiration or revocation. In Adonisjs, this typically manifests through stateless JWT usage where the same token can be reused across different user sessions if not properly bound to contextual attributes. Adonisjs applications often rely on the @adonisjs/auth package or custom implementations of JWT verification that lack strict binding to request context. When the verification logic only checks token validity and not usage patterns, an attacker can capture a valid token from one session and replay it to impersonate the original user in another session.
Common attack vectors include using JWTs without nonce or binding to IP address, user agent, or request headers. If the Adonisjs controller does not validate these attributes, the token remains valid and reusable. Additionally, session-based authentication in Adonisjs may be misconfigured to allow multiple concurrent sessions per user without invalidating previous tokens. This can allow an attacker to steal a token from one session and replay it in another, bypassing authentication checks. The risk is heightened when tokens are long-lived, lack rotation policies, or are stored in insecure locations such as local storage.
Token replay can also occur at the application layer when APIs accept tokens in Authorization headers without validating their freshness or usage context. If the backend does not track token usage or enforce single-session semantics, replay becomes trivial. For example, an API endpoint that processes a token without checking recent usage or device fingerprints is vulnerable. This is especially dangerous in APIs serving financial transactions, user profile updates, or administrative actions where a single replayed token can yield high-value impact.