CVE-2022-36085: Protection bypass in github.com/open-policy-agent/opa
Summary
CVE-2022-36085: Protection bypass in github.com/open-policy-agent/opa. Affects github.com/open-policy-agent/opa versions >= 0.40.0, < 0.44.0. Fixed in 0.44.0. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Open Policy Agent (OPA) is an open source, general-purpose policy engine. It provides a Rego compiler that allows users to define policies and compile them into executable code. The WithUnsafeBuiltins function is a deprecated feature in OPA that allows users to specify a set of built-in functions that should be considered unsafe and rejected by the compiler during policy compilation. This vulnerability bypasses the protection provided by WithUnsafeBuiltins when using the with keyword to mock a built-in function that is not accounted for by WithUnsafeBuiltins.
Vulnerability Detail
The vulnerability in OPA allows an attacker to bypass the protection provided by WithUnsafeBuiltins by using the with keyword to mock a built-in function that is not considered unsafe by WithUnsafeBuiltins. This can lead to the execution of potentially malicious code during policy compilation, compromising the integrity and security of the policy engine. The impact of this vulnerability depends on the policies being compiled and the actions allowed by the policy engine.
How To Fix
Latest published version: v1.21.3 as of 23 Oct 2026
go get github.com/open-policy-agent/opa@v1.21.3
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
0.44.0
This is the first release that contains the fix.
go get github.com/open-policy-agent/opa@v0.44.0
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
There is no known workaround for this vulnerability. It is recommended to upgrade to the latest version of OPA to fix the issue.
Conclusion
In conclusion, the vulnerability in OPA allows for the bypass of the protection provided by WithUnsafeBuiltins, potentially leading to the execution of malicious code during policy compilation. Users are advised to upgrade to the latest version of OPA to mitigate this vulnerability. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for github.com/open-policy-agent/opa →
FAQ
Open Policy Agent (OPA) is an open source, general-purpose policy engine that allows users to define and enforce policies across their applications and infrastructure.
WithUnsafeBuiltins is a deprecated function in OPA that allows users to specify a set of built-in functions that should be considered unsafe and rejected by the compiler during policy compilation.
The vulnerability allows an attacker to use the with keyword to mock a built-in function that is not considered unsafe by WithUnsafeBuiltins, thereby bypassing the protection.
The impact of this vulnerability depends on the policies being compiled and the actions allowed by the policy engine. It can potentially lead to the execution of malicious code during policy compilation.
To fix this vulnerability, it is recommended to upgrade to OPA version 0.44.0 or later.
References
Related vulnerabilities
Recent vulnerabilities recorded for github.com/open-policy-agent/opa.