What is a positive security model?
A positive security model decides by describing what is allowed and refusing everything else. A negative security model does the opposite: it describes what is known to be bad and lets the rest through. The same split is usually called allowlisting against blocklisting, and it applies to a firewall's rules, to input validation in code, and to an API gateway that checks requests against a schema.
Quick facts
- Positive model
- Describe what is valid; refuse the rest. Also called allowlisting or whitelisting
- Negative model
- Describe what is known to be bad; allow the rest. Also called blocklisting, denylisting or blacklisting
- OWASP on validation
- “Define what the application accepts and reject values outside those rules,” and “Do not try to recognize every malicious string.” Source: Input Validation Cheat Sheet
- A negative-style example
- The OWASP Core Rule Set is described as “a set of generic attack detection rules”
- A positive-style example
- “Apply an allowlist of permitted HTTP Methods,” with other methods answered by 405. Source: REST Security Cheat Sheet
- A machine-readable contract
- The OpenAPI Specification defines “a standard, programming language-agnostic interface description for HTTP APIs”, which is what a positive check can be built from
The two models side by side
The difference sits in what happens to a request nobody anticipated. Under a negative model it passes; under a positive model it is stopped. Everything else follows from that.
| Question | Negative model | Positive model |
|---|---|---|
| Starts from | A list of attack shapes | A description of valid traffic |
| An unknown request | Passes | Refused |
| Typical failure | An attack nobody wrote a rule for | A valid request nobody wrote down |
| Upkeep follows | New attack techniques | Changes to the application |
How a negative model works
A rule says: if the request looks like this, act on it. The pattern may be a signature, a keyword combination, or a structural check such as an unbalanced quote in a parameter. Everything that matches no rule goes through untouched, which is why the model is easy to start with: it needs no knowledge of the application, only knowledge of attacks. Rule sets such as the Core Rule Set take this approach; the rules section explains what rules match.
Two costs come with that. The first is coverage. A rule describes an attack as it was understood when the rule was written, so a variation that no pattern captures gets past it. This is the gap a zero-day lives in, and the reason a pattern-based filter can delay an exploit without removing the weakness behind it.
The second is noise. Legitimate input can look like an attack: a support ticket quoting a SQL statement, a developer forum, a search for the word select. A rule that cannot tell the quotation from the use will refuse it. That is the usual origin of false positives, and handling them is the main running cost of any pattern-based rule set. For the injection family that these rules target most, see SQL injection.
How a positive model works
Here the work is done up front. Someone describes what valid looks like, and the filter checks every request against that description: which paths exist, which methods each accepts, which content types are valid, which fields appear, and what type, length or format each field has. OWASP states the principle as defining what the application accepts and rejecting values outside those rules.
The strength is that an unfamiliar attack fails by default. A payload that no rule author imagined still has to fit a field described as, say, a five-digit number, and most payloads do not.
The costs mirror the strengths. The description has to exist, and it has to be kept in step with the application: a new field, a new endpoint or a changed format means a changed description, or valid requests start to be refused. And the guarantee is only as tight as the description. A field that must accept free text, such as a comment or a search box, cannot be constrained much, and a hostile string can be a perfectly valid piece of text. The model narrows what can reach the application; it does not prove the remaining input is safe.
Where a positive model fits naturally
It fits best where a precise description already exists. Structured APIs are the clearest case: an OpenAPI document lists operations, parameters and body schemas, and the schema language it relies on follows JSON Schema (the specification points to Draft 2020-12). A gateway or an application layer can check each request against that document without anyone writing a rule per attack. What a given deployment does when a schema leaves a field loosely typed or leaves an object open depends on how the schema is written, which is the first thing to read when a check seems to let too much through. The endpoint security page covers how this looks per endpoint.
Simple allowlists apply almost everywhere. A list of permitted methods, a list of accepted content types, a closed set of values for a parameter with only three legitimate answers: these cost little and cut off whole families of requests.
The deepest place for the positive check is the application itself. OWASP recommends validating both syntax, meaning type and format, and semantics, meaning whether the value makes sense for the operation, and it treats the defences applied when the data is used, parameterized queries for SQL and context-aware output encoding for XSS, as a separate layer. A filter in front helps with the first and cannot do the second. For the OWASP vocabulary around these layers, see OWASP and the OWASP Top 10.
Where a WAF helps and where it does not
A web application firewall reads HTTP requests before they reach the origin and acts on what it sees. That is useful in both models: a filter can refuse a recognisable attack shape while the code is being fixed, which is the idea behind virtual patching, and it can enforce a stated list of what is valid. It does not repair the weakness. The code stays as it was written.
What the filter cannot see is the meaning of a request. Whether this user may open order 17 is a question for the application, and a request that passes every syntactic check can still be an abuse of it, as with IDOR. A positive check also says nothing about a request that is valid in form and wrong in purpose.
This page defines the two terms and does not say which of them Bridge WAF applies. What Bridge WAF has is three modes, and they matter more here than the vocabulary does:
off
Nothing is inspected. Requests reach your origin as they otherwise would.
monitor
Matches are recorded and every request is still served.
block
Matching requests are refused and still recorded.
Start in monitor mode. Under either model the risk of enforcing early is the same: valid traffic the rules did not expect gets refused. Monitoring shows what would have been refused, so the surprises are found in the log and not in a customer complaint, and only then is a switch to block worth making.
Questions
What is the difference between a positive and a negative security model?
A negative model lists what is known to be bad and lets everything else through. A positive model lists what is valid and refuses everything else. The first fails on attacks nobody described; the second fails on legitimate requests nobody described.
Is an allowlist always better than a blocklist?
No. An allowlist is stricter, but it only works where the valid input can be described tightly, and it has to be kept in step with the application. A free-text field cannot be constrained much, and a blocklist of attack patterns is cheaper to start with. The choice is a trade between upkeep and coverage, not a ranking.
Can a WAF use both models?
In principle, yes. A broad set of attack rules can cover a whole site while a strict description applies to selected endpoints. Which approach a particular product takes is stated in its own documentation, and this page does not claim either one for Bridge WAF.
How does a positive security model apply to an API?
An API usually has a written contract, such as an OpenAPI description, that lists paths, methods, parameters and body fields with their types. Requests that fall outside that contract can be refused, which is the positive model applied to HTTP. Whether a request matches the contract says nothing about whether the caller may see the data.
Does a positive model replace input validation in the application?
No. A filter in front of the application sees the request, not the meaning behind it, so it cannot judge whether a value makes sense for the operation. OWASP describes validation of both syntax and semantics, and the application is the place that knows the semantics.