PT-2026-161323

Published

2026-11-19

·

Updated

2026-11-19

Description by

Score
N/A
Not available

No severity ratings or metrics are available. When they are, we'll update the corresponding info on the page.

Summary

Incorrect number comparison in OPA can cause wrong policy decisions, including wrongful authorization.
Affected numbers have a decimal point followed only by zeros, and an integer part that ends in zero (100.0, 1000.00). OPA strips these trailing zeros before comparing, including the zeros in the integer part, so 100.0 is treated as equal to 1, 1000.00 to 1, and 20.0 to 2. The comparison goes wrong when the stripped value exactly matches the other operand. Numbers such as 105.0, 100.5 and 100 are not affected.

Details

Which numbers are affected

A number is affected if it has a decimal point followed only by zeros, and an integer part that ends in zero (100.0, 1000.00). Stripping 100.0, 1000.00, 20.0 and 30400.0 yields 1, 1, 2 and 304. Numbers whose integer part does not end in zero (105.0), whose decimal part contains a non-zero digit (100.5, 10.50), or that have no decimal point (100) are not affected.
The comparison is wrong only if the stripped value exactly matches the other operand: 100.0 is mistaken for 1, but not for 10 or 2. The comparison is symmetric, so the affected number may be on either side. It does not have to come from the attacker: a policy constant or data value such as 100.0 can be matched by an attacker-supplied input value of 1.
All comparison operators are affected, as is equality of arrays, objects and sets, and max/min built-in functions. Rule indexing hides the problem in some rules that compare against a literal (see below), but this must not be relied upon.
In v1.20.0 only numbers longer than 19 characters are affected, e.g. 100000000000000000000.0 == 1.

Examples

Versions v1.10.0 - v1.19.x.
Operators. Literals only, evaluated as queries. The affected operators:
ExpressionExpectedActualCorrectNote
100.0 == 1falsetrue❌100.0 is trimmed to 1. The values are treated as equal
100.0 != 1truefalse❌100.0 is trimmed to 1. The values are treated as equal
100.0 > 1truefalse❌100.0 is trimmed to 1. The values are treated as equal, so neither is greater
100.0 <= 1falsetrue❌100.0 is trimmed to 1. The values are treated as equal, so <= holds
100.0 >= 1truetrue✅Correct, but only because the values are treated as equal and >= accepts equality. 100.0 is still trimmed to 1
100.0 < 1falsefalse✅Correct, but only because the values are treated as equal. 100.0 is still trimmed to 1
[100.0] == [1], {100.0} == {1}, {"a": 100.0} == {"a": 1}falsetrue❌100.0 is trimmed to 1. Elements are compared with the same logic
max([100.0, 1])100.01❌100.0 is trimmed to 1. The values are treated as equal, so max keeps the later element
min([1, 100.0])1100.0❌100.0 is trimmed to 1. The values are treated as equal, so min keeps the later element
max([1, 100.0])100.0100.0✅Correct only because the larger value comes last. 100.0 is still trimmed to 1
max([1, 100.0]) == 1falsetrue❌max returns the correct 100.0; the following == is what fails
100.0 == 10falsefalse✅The stripped value 1 does not match 10
100.1 == 1falsefalse✅100.1 ends in a non-zero digit, so nothing is trimmed
123.0 == 1falsefalse✅The integer part of 123.0 ends in a non-zero digit, so only the .0 is trimmed
Where the number comes from. The affected number may originate from input (typically attacker-controlled), the policy, or data, and may be either operand of the comparison, or both:
Trailing zeros inPolicy expressionInput / dataExpectedActualCorrectNote
inputinput.x == data.limitdata.limit = 1, input.x = 100.0falsetrue❌100.0 is trimmed to 1, which equals data.limit
inputmax([input.x, 1])input.x = 100.0100.01❌The values are treated as equal, so max keeps the later element
policyinput.x >= 100.0input.x = 1falsetrue❌100.0 is trimmed to 1, which equals input.x, so >= holds
policyinput.x >= 100.0input.x = 2falsefalse✅The stripped value 1 does not match 2, so the numeric comparison is used
datainput.x == data.limitdata.limit = 100.0, input.x = 1falsetrue❌100.0 is trimmed to 1
input and datainput.x == data.limitdata.limit = 1000.0, input.x = 10.0falsetrue❌1000.0 and 10.0 are both trimmed to 1

Effect of rule indexing

OPA indexes rules that compare a base document reference with a literal, such as input.x == 1. When a rule is resolved by the index, the rule body is skipped for non-matching input and the faulty comparison is never evaluated. This reduces the exposed surface, but it is an optimization and not a mitigation: whether it applies depends on the shape of the rule, and small changes to a policy can turn it off.
PolicyInput / dataExpectedActualCorrectNote
Query: input.x == 1input.x = 100.0falsetrue❌Queries are not indexed
Rule: allow if input.x == 1input.x = 100.0falsefalse✅Resolved by the index; the body is not evaluated
Rule: allow if { input.x > 0; input.x == 1 }input.x = 100.0falsefalse✅The equality is the last expression on input.x, so it is indexed
Rule: allow if { input.x == 1; input.x > 0 }input.x = 100.0falsetrue❌A later expression that passes input.x to a function or operator, or assigns it, makes the index accept any value for input.x; and the equality is then also evaluated
Rule: allow if input.x == data.limitinput.x = 100.0, data.limit = 1falsetrue❌Only comparisons with literals are indexed
Comparisons that are not == against a literal (ordering operators, !=, data or computed values, collections, max/min) are not indexed and are affected as described above.

Workarounds

If upgrading is not possible:
  • Reject or rewrite numbers in input whose decimal part consists only of zeros (100.0, 1000.00) before they reach OPA. Numbers with a non-zero decimal digit (100.5) need no handling.
  • Avoid writing integral values with a zero-only decimal part in data and policy (100, not 100.0). This does not protect against input values written that way.

Proof of concept

Run with the released opa v1.10.0 binary. Each command prints the wrong result on v1.10.0 – v1.19.x and the correct result on v1.20.1 and later.
1. Literals only
$ opa eval -fpretty '100.0 == 1'
true      # expected: false

$ opa eval -fpretty '100.0 <= 1'
true      # expected: false

$ opa eval -fpretty 'max([100.0, 1])'
1        # expected: 100.0
2. Equality against data: wrongful authorization
policy.rego:
rego
package authz

default allow := false

allow if input.role id == data.admin role id
data.json: {"admin role id": 1}
$ echo '{"role id": 10.0}' | opa eval -fpretty -d policy.rego -d data.json -I data.authz.allow
true      # expected: false

$ echo '{"role id": 10}' | opa eval -fpretty -d policy.rego -d data.json -I data.authz.allow
false      # correct: an integer is not affected
The attacker supplies 10.0, which is stripped to 1 and matches admin role id.

Impact

Who is impacted: anyone running an affected version of OPA (as a server, library or through the Go SDK, including embedded use such as Envoy, Kubernetes admission control or custom authorization services) whose policies compare a number that an attacker can influence with another number. The attacker does not need to control the trailing zeros on both sides: a policy constant or data value such as 100.0 can be matched by a plain integer 1 in the input, and an input value such as 100.0 can match a policy constant 1. Policies that only compare integers written without a decimal point, or that never compare caller-influenced numbers, are not affected.
Consequences: OPA returns an incorrect evaluation result (integrity of the decision). Depending on the policy this is an authorization bypass, a wrongful denial, or other wrongful policy result. There is no direct effect on OPA's own confidentiality, integrity or availability; the impact falls on the relying application, whose protected data and operations are exposed by a wrong allow.
Vendors
Affected products
Related identifiers
DHI-J65I-HFJ6-JZD3-YGPS
Found an issue in the description? Have something to add? Feel free to write us 👾