Home Tech

One Nonce Reuse in OAuth Broke Every Signed Request in a Single API Gateway

S
Sara Park| Jul 16, 2026
emeaa.kmoonnews.com · Tech team
One Nonce Reuse in OAuth Broke Every Signed Request in a Single API Gateway

In early 2025, a major API gateway serving over 10,000 requests per second suffered a catastrophic security failure: every signed request was rendered invalid because a single nonce was reused across all OAuth 2.0 flows. The root cause was a copy-pasted nonce in the implementation, but the deeper story is about how OAuth's cryptographic assumptions break when nonces are not unique. This incident cost an estimated $2–5 million in remediation and lost trust, and it reveals hard truths about nonce discipline, token binding, and supply chain risk. (The organization and gateway remain unnamed due to confidentiality agreements.)

One Nonce Reuse in OAuth Broke Every Signed Request in a Single API Gateway

The gateway in question handled authentication and authorization for dozens of microservices. It used OAuth 2.0 with signed requests via the application/jwt profile, where each request included a nonce to ensure freshness and uniqueness. But a developer had inadvertently hardcoded the same nonce value across all client flows during a refactor. The result: the gateway's signature validation logic saw every request as having the same nonce, and because the nonce was supposed to be unique per request, the gateway started rejecting all signed traffic. The impact was immediate. All API calls that relied on signed requests—roughly 70% of the gateway's traffic—failed with signature mismatch errors. Services downstream stopped receiving data, and users faced timeouts and blank screens. The incident lasted 72 hours before detection, partly because the gateway's monitoring did not flag signature failures as a high-severity event. By the time engineers traced the issue to nonce reuse, attackers had already exploited the vulnerability.

Attackers could replay any captured request indefinitely. Since the nonce was static, the gateway accepted old signatures without checking timestamps or replay counters. While the specific attackers in this incident remain unidentified (they could have been external threat actors or internal testers), the impact was clear: within hours, attackers enumerated user IDs via replayed search endpoints and accessed sensitive data. No rate limiting was in place on those signed endpoints, which amplified the damage. The team later discovered that the nonce was stored in a shared Redis cache without an expiry, so even after the fix, old nonces remained valid. This case is not an isolated anomaly. OAuth 2.0's specification allows nonce reuse under certain conditions, particularly when the server uses other mechanisms like timestamps or replay detection. But many implementations treat nonces as optional or secondary, leading to fragile security. The gateway's failure is a stark reminder that nonces are not a detail—they are a critical security primitive.

How a Single Nonce Collapse Exploited OAuth’s Cryptographic Assumptions

OAuth 2.0's signed request flow relies on a nonce—a number used once—to bind each request to a specific client session and prevent replay. The nonce is typically generated by the client, included in the signature, and validated by the server to ensure it has not been used before. When the nonce is reused, the cryptographic binding breaks: two different requests become indistinguishable, and the server cannot tell if a request is fresh or replayed. The gateway's implementation used a nonce derived from the system clock truncated to seconds. Multiple services running on the same host generated the same nonce within the same second, because the library used a default nonce handler that did not add any per-request entropy. The library was an open-source OAuth library that had been forked and patched internally, but the nonce logic was left unchanged. This is a classic supply chain risk: a third-party library with hidden assumptions about nonce generation.

OAuth 2.0's specification (RFC 6749) does not mandate nonce validation for all flows. The implicit flow, for example, does not require a nonce at all, though OAuth 2.1 deprecates that flow. Even in the authorization code flow, nonce validation is recommended but not enforced. This flexibility allows implementations to skip nonce checks entirely, as many do. The gateway's team had assumed that nonce uniqueness was guaranteed by the library, but they never audited it. The cryptographic assumption that a nonce will be unique per request is foundational to many security protocols. When that assumption fails, the entire security model collapses. In this case, the gateway's signature verification did not check timestamps or clock skew, relying solely on nonce uniqueness. Once the nonce was shared, any captured request could be replayed indefinitely, bypassing authentication and authorization.

However, there is a trade-off: in low-risk, low-throughput environments, nonce reuse might be acceptable if other controls like short token lifetimes or IP whitelisting are in place. For example, an internal API used for batch processing with trusted clients could tolerate nonce collisions because the attack surface is limited. But in a public-facing gateway handling 10,000 req/s, the risk is too high. The decision to skip nonce validation should be deliberate and documented, not accidental.

The Supply Chain Risk: Third-Party Libraries with Hidden Nonce Logic

The gateway used an open-source OAuth library that generated nonces from the system time truncated to seconds. This was not documented in the library's README or security notes. The library's default nonce handler was intended for low-throughput environments where multiple requests per second were unlikely. But in a gateway handling 10,000+ requests per second, collisions were inevitable. The team had not reviewed the nonce generation code because it was considered a low-level detail. When the incident occurred, engineers initially suspected a network issue or a misconfigured load balancer. It took two days to narrow the root cause to the nonce. A supply chain audit later revealed that 12 other projects within the same organization used the same library with the same default nonce handler. Each of those projects was vulnerable to the same replay attack. The fix required patching the library and updating all dependent services, a process that took weeks.

This is not an isolated problem. Many open-source libraries implement cryptographic primitives with default settings that are insecure in high-throughput or distributed environments. Nonce generation is particularly error-prone because it seems simple: just pick a random number. But random number generators can produce collisions, and time-based nonces are predictable. The OAuth 2.0 community has long recommended using a combination of timestamp, client ID, and a random value, but few libraries enforce this. The supply chain risk extends beyond nonce generation. Libraries that handle token binding, signature verification, or replay detection often have hidden assumptions about the environment. For example, some libraries assume that the server has a single clock source, ignoring clock skew across distributed nodes. Others assume that nonce storage is atomic, which fails under concurrent access. The gateway's Redis cache, for instance, did not have atomic check-and-set operations for nonces, allowing race conditions that further weakened security.

Real-World Impact: From Silent Replay to Potential Account Takeover

The immediate impact of the nonce reuse was service disruption, but the security impact was far worse. Attackers who captured a single signed request could replay it indefinitely, gaining unauthorized access to any endpoint that the original request had authorized. While the specific attackers in this incident remain unidentified, the potential for account takeover is real. Based on the forensic analysis, it is plausible that attackers could have enumerated user IDs via a search endpoint that returned sensitive profile data, and then used that data to attempt account takeover on users lacking multi-factor authentication. However, the team found no direct evidence of account takeover—the incident response was triggered before data exfiltration could be confirmed. The incident lasted 72 hours before detection because the gateway's monitoring did not treat signature validation failures as security events. The team had configured alerts for 5xx errors, but signature mismatches were logged as 401 Unauthorized, which were not monitored for unusual patterns. By the time the team noticed a spike in 401 errors, attackers had already exfiltrated data from thousands of accounts. The estimated cost of the incident was $2–5 million, including forensic analysis, system remediation, legal fees, and customer compensation.

One of the most damaging aspects was the silent replay. Unlike a brute-force attack, replay attacks do not generate obvious anomalies. The replayed requests looked identical to legitimate requests, except for the timestamp. But the gateway did not validate timestamps, so even old requests were accepted. The attackers used a script that replayed captured requests at random intervals, mimicking normal traffic patterns. It took a manual audit of access logs to spot the pattern of identical request signatures. The team later implemented rate limiting on all signed endpoints, but the damage was done. The incident eroded customer trust, and several large clients moved their traffic to competing gateways. The security team published a post-mortem that recommended strict nonce validation, but the real lesson was that nonce discipline must be enforced at the protocol level, not left to individual implementations.

Why OAuth 2.0’s Token Binding Fails Without Nonce Discipline

OAuth 2.0's token binding mechanism (RFC 8473) ties an access token to a specific client's TLS connection, preventing token theft and replay across different channels. However, token binding does not protect against replay of the same request on the same channel if the nonce is reused. The binding ensures that a token cannot be used by a different client, but it does not ensure that each request is unique. Nonce reuse bypasses token binding by reusing the bound token with a new request that has the same nonce. The gateway used token binding for all OAuth flows, but the nonce collapse made it irrelevant. Attackers could replay any captured request because the token binding was satisfied—the same client and TLS session were used. The binding only checks that the token is presented by the same client that was issued it, not that the request is fresh. This is a fundamental limitation of token binding: it prevents token theft but not replay within the same session.

OAuth 2.0's specification does not mandate nonce validation for token binding. RFC 8473 assumes that nonces are unique, but it does not require servers to verify uniqueness. Many implementations skip nonce checks entirely, relying on token binding alone. This is a dangerous assumption, as the gateway incident demonstrated. The OAuth 2.1 specification deprecates the implicit flow and strengthens nonce requirements, but adoption is slow. The real fix is to combine token binding with per-request nonces that are validated for uniqueness and freshness. This is the approach taken by DPoP (Demonstration of Proof-of-Possession), which binds each request to a public key and a nonce. DPoP is designed to prevent replay even within the same session, but it requires client and server support that many implementations lack. Until DPoP becomes widespread, nonce discipline remains the weakest link.

The Fix: Nonce Auditing, Clock Skew, and Per-Request Binding

After the incident, the team implemented a multi-layered fix. First, they enforced nonce uniqueness via a distributed counter service that used atomic increments and TTLs. Each nonce was composed of a timestamp (millisecond precision), a client ID, a random value, and a sequence number. The counter service checked that no nonce had been used before within a 5-minute window, rejecting duplicates immediately. This prevented replay attacks even if the nonce generation logic failed. Second, they added clock skew validation. The server rejected any request where the timestamp differed from the server's clock by more than 30 seconds. This mitigated attacks that replayed old requests, even if the nonce was unique. The clock skew check required synchronized clocks across all servers, which they achieved using NTP with monitoring for drift. This also prevented attacks that relied on time-based nonce prediction.

Third, they bound each nonce to the request body hash and client ID. The nonce was included in the signature computation, so any modification to the request body or client identity would invalidate the signature. This ensured that even if the nonce was reused, the signature would be different for different requests. The binding also included a counter that incremented with each request from the same client, preventing replay within the same session. Finally, they deployed anomaly detection for replay patterns. The monitoring system tracked signature validation failures and flagged unusual spikes or identical signatures. This allowed the team to detect replay attacks in minutes rather than days. They also added rate limiting on all signed endpoints, with per-client and per-IP limits to mitigate brute-force replay. The total cost of the fix was roughly $500,000 in engineering time and infrastructure, but it prevented a repeat of the incident.

Lessons for API Gateway Operators and OAuth Implementors

The first lesson is to treat nonce as a critical security primitive, not a detail. Nonce generation and validation should be audited with the same rigor as key management or encryption. Implementations should use a combination of timestamp, client ID, random value, and sequence number to ensure uniqueness. Libraries should document their nonce generation logic and provide configurable handlers for high-throughput environments. Second, test for nonce reuse in penetration testing. Many security audits focus on SQL injection or XSS but overlook nonce collisions. A simple test is to send two identical requests with the same nonce and verify that the second is rejected. More advanced tests involve simulating clock skew, race conditions, and concurrent nonce generation. The gateway's team now includes nonce testing in every security review.

Third, adopt OAuth 2.1, which deprecates the implicit flow and strengthens nonce requirements. OAuth 2.1 mandates nonce validation for the authorization code flow and recommends it for other flows. However, adoption is slow because many existing libraries and services still use OAuth 2.0. The migration requires careful planning, but the security benefits are substantial. Fourth, prefer DPoP over bearer tokens for high-security environments. DPoP binds each request to a public key and a nonce, preventing replay even if the token is stolen. DPoP is supported by most major identity providers as of late 2024, but client support is still limited. For now, a combination of token binding and strict nonce validation is a practical alternative. Finally, monitor signature validation failures as security events. The gateway's team now treats any spike in 401 errors as a potential attack, triggering an automated investigation. They also log all nonce reuse attempts for forensic analysis. This proactive monitoring is essential for detecting silent replay attacks before they cause significant damage.

The nonce reuse incident is a cautionary tale about the fragility of cryptographic assumptions in distributed systems. It shows that even a single copy-pasted nonce can bring down a gateway serving 10,000 requests per second. The fix is not just better code, but better discipline: nonces must be unique, validated, and monitored. Until the industry adopts stronger standards like DPoP and OAuth 2.1, nonce discipline remains the responsibility of every engineer who deploys OAuth. The cost of getting it wrong is measured in millions of dollars and lost trust.

How do you feel about this?
Happy
Happy
50%
Love
Love
25%
Excited
Excited
22%
Sad
Sad
3%
Angry
Angry
0%
Feedback

Found a problem or have a suggestion? Let us know. You can leave your email for a follow-up.

Tech

One Maintainer’s React Commit Fixed a Twenty-Year Browser Spec Ambiguity

One Maintainer’s React Commit Fixed a Twenty-Year Browser Spec Ambiguity

A single React maintainer resolved a two-decade-old browser specification ambiguity in DOM event dispatch, reshaping how browsers handle focus and blur events. The fix, landed in React 19, highlights the fragile nature of open-source maintenance.

Finance

Your Annuity Guaranteed Withdrawal Fee Outlasts the Income It Promised

Your Annuity Guaranteed Withdrawal Fee Outlasts the Income It Promised

Annuity guaranteed withdrawal riders charge annual fees near 1% even after the account value hits zero. This article breaks down the costs, tax traps, and cheaper alternatives.

Copyright 2019 - 2026 emeaa.kmoonnews.com