Skip to content

Stop leaking absolute artifact paths in chain API responses - #16

Open
Lvvphole wants to merge 1 commit into
mainfrom
claude/fix-handler-result-path-leak
Open

Stop leaking absolute artifact paths in chain API responses#16
Lvvphole wants to merge 1 commit into
mainfrom
claude/fix-handler-result-path-leak

Conversation

@Lvvphole

Copy link
Copy Markdown
Owner

Problem

HandlerResult.artifacts_created (and evidence_refs) are populated with Artifact.path — an absolute host filesystem path (e.g. /tmp/.../art/run-x/run-x-a1/repo_tree.log). Those fields surface through POST /runs/{id}/chain/execute and GET /runs/{id}/chain/results, exposing server filesystem layout to API callers. This is the same information-disclosure class as the earlier workspace_id fix, in a different field.

It's pre-existing (predates Epic 6) and was surfaced while writing the evidence-persistence tests — kept as its own focused PR rather than folded into the Epic 6 work.

Fix

Strip the path-bearing handler fields from the two chain API responses via a small _result_response() serializer used by both endpoints:

result.model_dump(mode="json",
    exclude={"handler_results": {"__all__": {"artifacts_created", "evidence_refs"}}})
  • Surgical / API-boundary only. Handlers are unchanged; the internal runs.snapshot still stores the full result for audit. (When evidence persistence lands, the evidence_artifacts table is the durable artifact record.)
  • These two routes are the only endpoints that serialize ChainExecutionResult (verified — routes_runs.py exposes neither chain_execution_result nor handler_results).
  • No authority change: output is only narrowed; no merge/deploy/bypass/force-pass surface is added. final_status, verifier_decision, gate_results, etc. are unaffected.

Tests (274 passed, 9 skipped — Postgres-gated)

New test_api_responses_do_not_leak_artifact_paths: the execute and results responses contain neither the artifacts_root path nor the artifacts_created/evidence_refs keys. No existing test relied on those fields being exposed.

🤖 Generated with Claude Code


Generated by Claude Code

HandlerResult.artifacts_created (and evidence_refs) are populated with
Artifact.path — an absolute host filesystem path — which surfaced through
GET /runs/{id}/chain/results and POST /runs/{id}/chain/execute, exposing
server filesystem layout to API callers.

Strip those path-bearing handler fields from the chain API responses via a
small _result_response() serializer used by both endpoints. The internal
runs.snapshot keeps the full result for audit, and (once evidence
persistence lands) the evidence_artifacts table is the durable artifact
record. No authority change: this only narrows output — no merge/deploy/
bypass surface is added.

Test: the execute and results responses contain neither the artifacts_root
path nor the artifacts_created/evidence_refs keys.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015R7wjqoCZDF1pqNp8AiUJ6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants