CWE-294: Authentication Bypass by Capture-replay
An attacker captures a valid authentication request or token and resends it to gain access, because the server does not detect the replay.
Also known as: Replay attack, Capture-replay authentication bypass, Token replay
Risk
Typically high. A replayed request can authenticate as another user or re-trigger a sensitive action, and it needs no cracking, just resending traffic the attacker observed.
Definition
What it is
CWE-294 occurs when an authentication or authorization step can be replayed: a captured valid message, token, or signed request is accepted again because the server does not bind it to a single use, a short time window, or a fresh challenge. An attacker who observes or intercepts the exchange resends it and is treated as legitimate. The defense is a one-time element such as a nonce, timestamp, or server challenge that makes each exchange usable only once. The weakness is the absence of that freshness check.
Use-cases
How it shows up in real code
Replayed login request
A login or token-exchange request is captured on the network and resent later. Because nothing marks it as used, the server authenticates the attacker as the original user.
Reused one-time code
A one-time passcode or magic link is accepted more than once because it is not invalidated on first use, so a captured code is replayed to log in again.
Signed request without a nonce
An API signs requests but includes no nonce or timestamp. An intercepted signed request is replayed and the server honors it as fresh.
Replayed state-changing action
A captured request that transfers funds or changes a setting is resent, and with no idempotency or freshness check the server performs the action again.
AI risk
Why AI-generated code has increased the exposure
- Assistants implement a flow that authenticates correctly on the first try, and replay protection is an extra step the prompt rarely names, so it is omitted.
- Whether messages travel over a replayable channel is deployment context the model cannot see, so it assumes a single valid exchange is enough.
- Models optimize for a flow that works in testing, where no one resends a captured request, so the missing freshness check never shows.
- Many authentication snippets in training data omit nonces, timestamps, and single-use invalidation, and that incomplete pattern is reproduced.
- As the assistant generates more token exchanges and sensitive endpoints, each lacks replay protection by default, and volume widens the window.
Vibe coding
How vibe coding amplifies the risk
- Vibe coding ships authentication flows whose missing replay defense is invisible in an unread diff.
- Normal manual testing sends each request once, so a replayed capture is never exercised and the flaw stays hidden.
- Prompt-and-ship skips the review where someone would ask whether a captured request can be resent.
- A prototype auth flow built without nonces or single-use codes is promoted to production unchanged.
- Rapid growth adds token exchanges and sensitive actions faster than anyone checks each for freshness protection.
Detection
How to find it
- Confirm each authentication exchange includes a one-time element such as a nonce, timestamp, or server challenge.
- Confirm one-time codes and tokens are invalidated on first use and cannot be accepted twice.
- Capture a valid request and resend it; confirm the server rejects the replay.
- For sensitive state-changing actions, confirm an idempotency or freshness check prevents a resent request from repeating the effect.
Remediation
How to fix it
- Include a server-issued nonce or challenge in each authentication exchange and accept it only once.
- Bind requests to a short time window with a timestamp and reject stale or future-dated messages.
- Invalidate one-time codes, magic links, and tokens immediately on first use.
- Carry authentication over TLS so exchanges cannot be captured in transit, as defense in depth.
- Add tests that replay a captured valid request and fail the build if the server accepts it.
Frequently asked questions
- What is CWE-294 (authentication bypass by capture-replay)?
- CWE-294 is when an attacker captures a valid authentication request or token and resends it to gain access, because the server does not bind the exchange to a single use, a short time window, or a fresh challenge. Without that freshness check, replayed traffic is treated as legitimate.
- How have AI assistants and vibe coding increased capture-replay risk?
- Assistants implement a flow that authenticates correctly on the first attempt and omit replay protection because the prompt rarely names it and the channel context is invisible to the model. Vibe coding ships that flow unread, and because manual testing sends each request only once, the missing nonce or single-use check stays hidden until someone replays a capture.
- How do I fix authentication bypass by capture-replay?
- Include a server-issued nonce or challenge accepted only once, bind requests to a short time window with a timestamp, invalidate one-time codes and tokens on first use, carry authentication over TLS, and add tests that replay a captured request to confirm it is rejected.
Related weaknesses
Catch CWE-294 before you ship
Tethlyn Audit scans your codebase and its git history for CWE-294 and the rest of the business logic vulnerabilities class, then ranks each finding by real exploitability and data sensitivity.