Fix critical SCP safety regressions#8
Conversation
Co-authored-by: Andre Schu <Art.Int.Interface@gmail.com>
Co-authored-by: Andre Schu <Art.Int.Interface@gmail.com>
Workflow name alone does not satisfy the required status named CI; add a gate job with that id. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eda013bd84
ℹ️ 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".
| "registry_bucket", | ||
| "containment", | ||
| "source_ref", |
There was a problem hiding this comment.
Constrain metadata before allowing structured records
In a structured contribution, this allow-list accepts registry_bucket and source_ref, but neither _validate_contribute_abstraction() nor validate_pattern_record() constrains their values (or even requires source_ref to be an object), and _build_snapshot() later emits records verbatim. So patterns_json can move a raw customer prompt into source_ref or registry_bucket and still be staged/published, which leaves the metadata leak this gate is intended to block.
Useful? React with 👍 / 👎.
Bug and impact
inspect()auto-logged injection/reversal content by default, which could persist secrets or PII from blocked tool output intodocs/encounter_bestiary.scp_validate_outputandrun_pipelineclassify malicious content as safe.Root cause
SCP_ENCOUNTER_AUTO_LOGabsent meant enabled).Path.write_text()followed by chmod instead of creating with private mode from the first write.Fix
SCP_ENCOUNTER_AUTO_LOG=1.source_refmetadata.0600mode from the initialos.open; use private temp + replace for forced rotation.Validation
PYTHONPATH=src python3 -m pytest -q tests/test_registry_contribute_r3.py::test_structured_patterns_accepts_source_ref_metadata-> 1 passed.PYTHONPATH=src python3 -m pytest -q tests/test_encounter_auto_log.py tests/test_sanitize_encoding_evasion.py tests/test_registry_contribute_r3.py tests/test_setup_mycelium_nostr_key.py tests/test_scp_registry_mcp_r5.py tests/test_mcp_contract_v1.py-> 101 passed.git diff --checkpassed.PYTHONPATH=src python3 -m pytest -qran 269 passed / 3 skipped / 3 failed; failures are existing vendored contract hash mismatches intests/test_contract_document_hash.pywith no local docs/contracts diffs.