policy: FallbackEvaluate disagrees with the OPA engine on enabled defaults, AND/OR semantics, and rootDirectory
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start by comparing enabledForRego and enabledForFallback in rego.go:42, then read the constraint checks in policy.go:360 and policy.go:375 alongside the Rego evaluator's corresponding behavior. Check the existing path-containment logic and tests for rootDirectory. Done means both evaluators agree on defaults and AND semantics, and fallback evaluation enforces root-directory boundaries.
Written by the indexing model from the issue text.
Description
Problem
Three related semantic-drift issues between the primary Rego/OPA evaluator and the pure-Go FallbackEvaluate path in packages/policy:
rego.go:42—enabledForRegoandenabledForFallbackdisagree on which features/rules are considered enabled by default, so the same configuration can be interpreted differently depending on which evaluator handles it.policy.go:375—FallbackEvaluatecombines multiple constraints with OR logic where the Rego policy combines the equivalent constraints with AND, so a rule that should require all conditions to hold can be satisfied by just one of them under the fallback evaluator.policy.go:360—rootDirectoryconstraint checking is entirely unimplemented inFallbackEvaluate(a no-op / always-true), while the Rego engine enforces it.
Impact
Whenever the fallback evaluator is used instead of OPA (e.g. OPA unavailable, or a deployment configured to run fallback-only), policies can be enforced with meaningfully looser semantics than intended: features assumed disabled by default may be enabled, AND-combined constraints degrade to OR, and rootDirectory confinement does nothing at all. This is a silent policy-weakening bug whose effect is invisible to anyone validating policy behavior solely against the Rego engine.
Repro
- Compare
enabledForRegoandenabledForFallback's default-enabled sets directly; find at least one rule/feature where they differ. - Write a policy rule with two constraints that must both hold (AND semantics in Rego); evaluate the same policy via
FallbackEvaluatewith only one constraint satisfied and observe it is allowed, where the Rego path would deny it. - Set a
rootDirectoryconstraint and evaluate a path outside it viaFallbackEvaluate; observe it is allowed, where the Rego engine would deny it.
Suggested fix
Audit enabledForRego vs enabledForFallback and make them share a single source of truth for default-enabled rules rather than two independently maintained lists. Change FallbackEvaluate's constraint combination at :375 from OR to AND to match the Rego semantics (or, better, extract the combination logic into a shared helper exercised by both evaluators). Implement rootDirectory checking in FallbackEvaluate using the same path-containment logic as the Rego engine (see the related rootDirectory issue for the Rego side's own boundary bug, which the fallback implementation should not blindly copy).
- Dominant language
- Go
- Stars
- 157
- Forks
- 19
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 96
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from solongate/agent-security
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 91/100
solongate/agent-security#226 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
solongate/agent-security#223 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
solongate/agent-security#220 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
solongate/agent-security#215 ·
Maintainers usually reply within 1 day
-
hooks: baked guard-binary path isn't quote-escaped, can produce invalid JS for the OpenCode pluginOpenbug help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
solongate/agent-security#207 ·
Maintainers usually reply within 1 day
All issues in solongate/agent-security
Similar issues
-
Headerless responses block while skipping duplicate status linesPossibly taken @mynhe claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
projectdiscovery/rawhttp#554 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
lognorman20/monaco#7428 ·
-
docs(prompts): IF BLOCKED workflow-scope branch says to comment on the issue on jira/local trackersOpenagent-butler-finding bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
jordansmall/spindrift#6238 ·
Maintainers usually reply within 1 day