Repository navigation
fix(policies): restrict policy script references to https and local paths - #3587
Conversation
PR validation — ✅ 3 passing
AI Session Checks — 🟢 91% ·
|
| Avg score | Sessions | Failing policies | Attribution | Files | Lines | Total Duration |
|---|---|---|---|---|---|---|
| 🟢 91% | 1 | 100% AI / 0% Human | 7 | +545 / -227 | 1h35m24s |
🟢 91% — 100% AI — ⚠️ 1 policies failing
-
Oct 9, 2026 10:51 UTC · 1h35m24s · $15.82 · 666 in / 180.1k out · claude-code 2.1.295 (claude-opus-5-5)
Change Summary
-
- Restricts policy script refs to HTTPS or policy-local paths, including symlink rejection.
- Sanitizes rego parse errors so policy source is not echoed back.
- Adds and reshapes loader tests, including follow-up coverage for policy-location semantics.
AI Session Overall Score
-
🟢 91% — Autonomous run stayed aligned and verified; only planning discipline was thinner.
AI Session Analysis Breakdown
-
🟢 95% · solution-quality
-
🟢 Follow-up work moved parse-error sanitization into the engine layer. · High Impact
🟢 94% · alignment
-
No notes.
🟢 92% · user-trust-signal
-
No notes.
🟢 91% · verification
-
🟢 Targeted tests failed first, then passed after fixes. · High Impact
🟡 Autonomous follow-ups left no explicit human confirmation of the final behavior. · Low Severity
🟢 90% · scope-discipline
-
🟢 Observed edits stayed on
pkg/policies, its tests, and matching testdata. · High Impact
🟡 72% · context-and-planning
-
🟠 Complex multi-phase work ran without a visible plan, TODO list, or planning event. · Medium Severity
💡 Before editing across implementation, review, and rebase phases, write a short plan the session can steer against.
-
File Attribution
████████████████████100% AI / 0% HumanStatus Attribution File Lines modified ai pkg/policies/policies_test.go+285 / -104 modified ai pkg/policies/policies.go+138 / -104 modified ai pkg/policies/engine/rego/boilerplate.go+32 / -15 modified ai pkg/policies/engine/rego/rego_test.go+47 / -0 modified ai pkg/policies/engine/rego/boilerplate_test.go+32 / -1 created ai pkg/policies/testdata/policy_script_outside_dir.yaml+8 / -0 modified ai pkg/policies/engine/rego/rego.go+3 / -3
Policies (4, 1 failing)
Status Policy Material Messages ✅ Passed ai-config-ai-agents-allowedai-coding-session-5c767c- ✅ Passed ai-config-no-dangerous-commandsai-coding-session-5c767c- ⚠️ Failedai-config-no-secretsai-coding-session-5c767cSecret (generic-password) detected in session content [turn=708, source=tool_result, line=8]: INF redacted secrets from the AI coding session before upload count=10 rules=["generic-[CHAINLOOP_TRACE_REDACTED:generic-password]"] ✅ Passed ai-config-mcp-servers-allowedai-coding-session-5c767c- -
Security Checks — ✅ 6 passing
✅ secret-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | secrets-detection |
- |
✅ sast-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | owasp-top10-2025 |
- |
| ✅ Passed | sast |
- |
| ✅ Passed | cwe-top25 |
- |
| ✅ Passed | cwe-top26-40-cusp |
- |
✅ iac-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | iac-misconfiguration |
- |
Scans not applied (2)
| Scan | Reason |
|---|---|
vulnerability-scan |
no manifest/lockfile changed |
github-actions-scan |
no workflow files changed |
Security context
This change touches code with 9 recorded security-fix advisories. These are pointers to what past fixes established, not findings in this diff, and they never fail the check.
View in Chainloop ↗ · How this works ↗
Powered by Chainloop and Chainloop Trace
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
…aths Policy script references (ref and path) are now resolved through a single resolver that only accepts absolute https:// URLs. Relative references are resolved against the policy spec URL when the spec is served over https, and confined to the spec directory when the spec is a local file. Other schemes, absolute paths and paths that leave the policy directory are rejected. Rego parse errors returned while loading a policy now report only the error code and location instead of quoting the policy source. Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Chainloop-Trace-Sessions: 5c767ce4-bc27-47f4-8a11-def62c79205b
Apply the same parse error sanitization to the rego engine parse sites and cover how the policy spec location used to resolve relative script references is derived. Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Chainloop-Trace-Sessions: 5c767ce4-bc27-47f4-8a11-def62c79205b
A relative script path in a local policy spec is now checked after resolving symlinks, so a link inside the policy directory cannot point to a file outside it. Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Chainloop-Trace-Sessions: 5c767ce4-bc27-47f4-8a11-def62c79205b
cdbe53b to
0c45f8a
Compare
|
Let's double check that we have two loading areas her 1 - loading the policy from a contract or policy group, in which case we support chainloop://, etc which ones are we securing? And let's make sure the tests are clear about scenario and examples |
…s cover Name the tests and cases after the two loading steps: an attachment loads a policy spec, and the policy spec references its scripts. Only the second step is restricted. Add a test that runs both steps through the verifier. Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Chainloop-Trace-Sessions: 5c767ce4-bc27-47f4-8a11-def62c79205b
|
This PR only restricts step 2: the script references inside a policy.yaml.
In eabec48 the tests follow this split. A comment block above them describes the two steps. 🤖 Posted by Maximus bot (Claude Code) on behalf of @migmartri using the eng-autopilot skill |
Hardens how the policy engine loads the script that a policy spec references through its
reforpathfields.ref, deprecated V2path, and legacypath) now go through one resolver.https://URLs with a host.https://.file://) is confined to the directory of that spec, so local policy development keeps working.Behavior changes:
env://,file://,http://andchainloop://script references are rejected. The script loader cannot fetchchainloop://references.http://spec are rejected.chainloop://specs are rejected. They used to resolve against the working directory of the process.Testing: table-driven unit tests for the resolver, for the derivation of the spec location, and for loading scripts from embedded, local and remote specs. Parse error tests check that the policy source is not in the error. The pkg/policies and app/cli test suites pass.
AI assistance: this change was written with Claude Code.
🤖 Posted by Maximus bot (Claude Code) on behalf of @migmartri using the eng-autopilot skill