HTTP 412 Precondition Failed is a status code returned when a request does not meet conditions the client supplied, such as an If-Match or If-Unmodified-Since header. It is commonly used with optimistic concurrency control, where the server rejects an update because the resource changed since the client last read it.
How HTTP 412 Precondition Failed Works
HTTP 412 is a conditional-request outcome, not a generic server error. It tells the client that the server understood the request, but one of the supplied preconditions did not evaluate to true, so the operation was rejected before the resource was changed. That makes it a key part of safe update flows where clients must prove they are acting on a current view of the data.
In practice, the status code is most closely associated with concurrency control on shared resources. A client may send an If-Match header to require a matching entity tag, or an If-Unmodified-Since header to require that the resource has not changed since a known time. If the condition fails, the server returns 412 instead of silently overwriting newer content.
Why Precondition Checking Matters
Precondition checks reduce lost updates, accidental overwrites, and stale writes when multiple clients or processes touch the same object. They are especially important in APIs, content systems, and collaborative applications where read-modify-write cycles are common and a later write can otherwise erase a concurrent change without warning.
The security value is integrity and correctness rather than secrecy. A well-placed 412 response preserves the server’s authority over the current state of a resource and prevents clients from assuming that a write succeeded when the resource version they targeted was no longer valid. That behaviour is one of the simplest ways to make optimistic concurrency control visible to the caller.
Common Causes and Semantics
HTTP 412 is usually triggered by a mismatch between the client’s expectation and the server’s current state. The client may have supplied an outdated ETag, a timestamp that no longer reflects the last modification, or another condition tied to the resource version. The response does not mean the request was malformed; it means the precondition was valid to check but failed at evaluation time.
Because the failure is conditional, a 412 often signals that the caller should refresh its local copy, re-evaluate the change, and retry only after it has reconciled with the latest version. That makes the code materially different from 409 Conflict, which is often used for broader application-level collisions rather than a specific failed HTTP condition.
Operational Patterns and API Design
HTTP 412 is most useful when the server exposes a clear versioning or validator strategy, such as ETags, modification timestamps, or other state markers that clients can present back to the server. In well-designed APIs, it becomes part of the normal write path, not an exceptional edge case, because it gives clients a deterministic way to protect concurrent edits.
For API-first systems, conditional requests are a design choice about state ownership. They let the server enforce consistency without requiring heavyweight locking, while still giving clients an explicit signal when their view is stale. Teams that expose mutable resources should document which preconditions are supported and what retry behaviour the client should expect after a 412.
Risk and Threat Considerations
Conditional update failures matter because the wrong handling pattern can create silent data corruption, overwritten changes, or race-condition exposure in shared-state systems. If clients ignore 412 responses, retry blindly, or fall back to unconditional writes, the protection disappears and stale data can replace a newer server state.
Failure mechanism: An attacker or buggy client can exploit weak concurrency handling by submitting updates based on stale resource state, especially when the application does not enforce preconditions consistently across all write paths.
Impact: The result can be lost updates, inconsistent records, broken auditability, and, in security-sensitive workflows, incorrect permissions, policy data, or transaction state being committed.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP API Security Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 and OWASP ASVS set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP API Security Top 10 | API5 — Broken Function Level Authorization | Conditional write failures often protect state-changing API actions from stale or unauthorized execution. |
| API8 — Security Misconfiguration | Incorrect handling of conditional requests can weaken API integrity controls. | |
| Recommendation — Enforce function-level checks on mutating endpoints before accepting state changes. Configure APIs to reject unsafe unconditional writes where conditional updates are required. | ||
| NIST SP 800-53 Rev 5 | SI-10 — Information Input Validation | Preconditions validate request state before a write is accepted. |
| AU-3 — Content of Audit Records | Failed conditional writes can be important events for tracing concurrency and integrity issues. | |
| Recommendation — Validate required request conditions before processing updates. Record failed conditional update attempts with enough context to reconstruct the state mismatch. | ||
| OWASP ASVS | V8 — Authorization | Preconditioned updates are part of controlled access to state-changing actions. |
| Recommendation — Require explicit authorization checks on every state-changing request path. | ||
Practitioner Guidance
Why practitioners should care: Treat 412 as a control signal, not a nuisance status. It tells you the server has detected a state mismatch and that the client must re-read before making a safe change. If your API supports conditional writes, make sure the behaviour is consistent across all mutating endpoints.
What to watch for: Repeated 412 responses can indicate a stale client cache, poor retry logic, or a workflow that needs stronger version awareness. In distributed systems, that pattern may also reveal contention hotspots where optimistic concurrency is doing useful work and needs to be preserved rather than bypassed.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 16, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org