{"id":"CVE-2022-36085","published":"2022-09-08T13:30:16Z","modified":"2025-04-22T17:23:14Z","title":"OPA Compiler: Bypass of WithUnsafeBuiltins using `with` keyword to mock functions","vendor":"open-policy-agent","product":"opa","tier":"tail","description":{"text":"Open Policy Agent (OPA) is an open source, general-purpose policy engine. The Rego compiler provides a (deprecated) `WithUnsafeBuiltins` function, which allows users to provide a set of built-in functions that should be deemed unsafe — and as such rejected — by the compiler if encountered in the policy compilation stage. A bypass of this protection has been found, where the use of the `with` keyword to mock such a built-in function (a feature introduced in OPA v0.40.0), isn’t taken into account by `WithUnsafeBuiltins`. Multiple conditions need to be met in order to create an adverse effect. Version 0.43.1 contains a patch for this issue. As a workaround, avoid using the `WithUnsafeBuiltins` function and use the `capabilities` feature instead.","provenance":"source","from":"CVE.org"},"cvss":{"score":7.4,"severity":"HIGH","version":"3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.01628,"percentile":0.76782,"provenance":"source"},"cwes":[{"id":"CWE-693","name":"Protection Mechanism Failure"},{"id":"CWE-20","name":"Improper Input Validation"}],"references":[{"url":"https://github.com/open-policy-agent/opa/security/advisories/GHSA-f524-rf33-2jjr","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/open-policy-agent/opa/pull/4540","tags":["x_refsource_MISC"]},{"url":"https://github.com/open-policy-agent/opa/pull/4616","tags":["x_refsource_MISC"]},{"url":"https://github.com/open-policy-agent/opa/commit/25a597bc3f4985162e7f65f9c36599f4f8f55823","tags":["x_refsource_MISC"]},{"url":"https://github.com/open-policy-agent/opa/commit/3e8c754ed007b22393cf65e48751ad9f6457fee8","tags":["x_refsource_MISC"]},{"url":"https://github.com/open-policy-agent/opa/releases/tag/v0.43.1","tags":["x_refsource_MISC"]}],"priority":{"score":20.5,"factors":[{"name":"EPSS percentile","points":15.36},{"name":"CVSS severity","points":5.18}]},"vendorSlug":"open-policy-agent","affectedVersions":[{"vendor":"open-policy-agent","product":"opa","versions":[">= 0.40.0, < 0.43.1"]}],"ssvc":{"exploitation":"poc","automatable":"no","technicalImpact":"total","timestamp":"2025-04-22T15:42:09.440338Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"Go","package":"github.com/open-policy-agent/opa","vulnerableRanges":[">=0.40.0, <0.43.1",">=0.40.0, <0.44.0"],"patched":["0.43.1","0.44.0"],"from":["GHSA-f524-rf33-2jjr","GO-2022-0978"],"provenance":"source"}],"summary":{"text":"The Rego compiler in Open Policy Agent (OPA), specifically its deprecated WithUnsafeBuiltins protection, fails to block built-in functions that are invoked through the with keyword used to mock them. An attacker who can supply or influence policy code can therefore reach built-ins the operator meant to reject, but only under several specific conditions, and the network-reachable attack requires high complexity, no privileges, and no user interaction.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T07:14:35Z"},"euvd":{"id":"EUVD-2022-6789","exploited":false,"provenance":"source"},"lineage":{"familyId":"fam-open-policy-agent-opa-cve-2022-33082","parents":[{"from":"CVE-2022-33082","to":"CVE-2022-36085","relation":"related","confidence":"medium","kind":"lineage","evidence":[{"kind":"same-code","provenance":"machine","files":["ast/compile.go"],"commits":["https://github.com/open-policy-agent/opa/commit/064f6168a8dfebdeb2ea147f7882bb9f5d2b7f67","https://github.com/open-policy-agent/opa/commit/25a597bc3f4985162e7f65f9c36599f4f8f55823","https://github.com/open-policy-agent/opa/commit/3e8c754ed007b22393cf65e48751ad9f6457fee8"],"basis":"rarely changed file"}]}]}}