Skip to content

fix(quarantine): harden provenance and write path - #59

Merged
ManintheCrowds merged 3 commits into
mainfrom
fix/quarantine-provenance-hardening
Oct 7, 2026
Merged

ManintheCrowds merged 3 commits into
mainfrom
fix/quarantine-provenance-hardening

Conversation

@ManintheCrowds

Copy link
Copy Markdown
Owner

Summary

  • Reject symlink quarantine layouts and forged .json self-sidecars; require .txt merge paths.
  • Stage atomic quarantine writes with full UUID hex ids; validate before write and enforce limits only after durable commit.
  • Fail closed on registry fetch when quarantine write fails (quarantine_failed, local SSOT unchanged).
  • Rebased onto main (independent of SSRF PR fix(http_policy): allowlist dial host for SSRF #58).

Test plan

  • PYTHONPATH=src pytest tests/test_security_regressions.py tests/test_registry_fetch_r4.py tests/test_registry_ssot.py -q
  • Confirm symlink registry_fetch layout is refused for write/list/merge
  • Confirm forged .json envelope cannot self-certify as sidecar
  • Confirm disk-full / rename failure does not evict existing pairs

Unapplied review findings

  • Medium — src/scp/scp_utils.py list_quarantine — forged sidecar quarantine_id can point outside the quarantine root. Suggested: derive path from meta_path.stem only and require content_path.resolve().is_relative_to(pair_dir.resolve()).
  • Medium — src/scp/scp_utils.py _new_quarantine_paths + os.replace — concurrent writers can still overwrite after the existence check. Suggested: exclusive create (O_CREAT|O_EXCL) with retry on EEXIST.
  • Low — src/scp/quarantine_limits.py prepare_quarantine_write — legacy path still evicts before durable commit. Suggested: thin wrapper to validate_quarantine_write only, or deprecate.
  • Low/advisory — src/scp/registry_ssot.py — merge trusts dual reason-strings, not a fetch-binding token. Optional follow-up if quarantine dir is not operator-trusted FS.

ManintheCrowds and others added 2 commits October 6, 2026 23:29
Reject symlink layouts and forged .json sidecars; stage atomic
writes with full UUID ids; fail closed before eviction on pressure.

Co-authored-by: Cursor <[email protected]>
Dedupe _safe_existing_layout_dir; skip redundant mkdir; short-circuit
validate when eviction is deferred to enforce.

Co-authored-by: Cursor <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T04:43:10.261142Z 9a8949e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a8949e1e7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/scp/scp_utils.py
Comment on lines +208 to +211
quarantine_limits.enforce_quarantine_limits(
root,
layout_subdirs=_ALLOWED_QUARANTINE_LAYOUTS,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid evicting the just-committed quarantine pair

When quota pressure requires eviction and existing pairs have mtimes later than the current clock (for example after a restore or clock rollback), the newly committed pair is the global oldest entry. enforce_quarantine_limits therefore deletes the new .txt and .json pair, but quarantine() still returns success with its now-nonexistent path; registry fetch can consequently report a usable quarantine ID that cannot be merged. Exclude the pair being written from post-commit eviction (or otherwise verify it survives) before returning success.

Useful? React with 👍 / 👎.

@ManintheCrowds
ManintheCrowds merged commit a39a9b2 into main Oct 7, 2026
5 checks passed
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.

1 participant