Skip to content

fix(audit): extract injection patterns to versioned config, include version in audit events (INJECT-006) - #257

Merged
imran-siddique merged 2 commits into
mainfrom
fix/inject-006-versioned-patterns
Jun 8, 2026
Merged

fix(audit): extract injection patterns to versioned config, include version in audit events (INJECT-006)#257
imran-siddique merged 2 commits into
mainfrom
fix/inject-006-versioned-patterns

Conversation

@imran-siddique

Copy link
Copy Markdown
Member

Summary

  • Moves hardcoded fallback regex injection-detection patterns out of pipeline.py into src/cmcp_gateway/inspection/patterns_v1.json with a top-level version field ("1.0.0")
  • Loads patterns at module init via _load_patterns(); logs version, count, and file path at INFO on each load
  • Replaces InspectionResult.injection_pattern_set_hash (a sha256 hash) with patterns_version (semantic version string from the config); both return sites in InspectionPipeline.run() now emit patterns_version=_PATTERNS_VERSION so every audit record is tied to the exact pattern set that made the decision

Test plan

  • test_patterns_version_present_on_allowpatterns_version set on allow result
  • test_patterns_version_present_on_denypatterns_version set on deny result
  • test_patterns_version_stable_across_instances — version is the same across two pipeline instances
  • test_patterns_version_matches_config_file — version in audit result equals version field in patterns_v1.json
  • test_patterns_version_present_on_non_utf8_deny — non-UTF-8 early-return path also carries patterns_version
  • All 40 existing inspection tests pass

Closes #190.

🤖 Generated with Claude Code

imran-siddique and others added 2 commits June 8, 2026 10:45
…chain substitution (AUDIT-002)

verify_chain() now checks the chain_root against an externally-committed
anchor value that is derived from a per-session TEE attestation nonce
(SHA-256 of chain_root_bytes || session_id_bytes).  An attacker who
discards _entries and constructs a fresh self-consistent chain will get a
different root that fails the anchor check even though all internal hash
links pass.  In dev / Level-0 mode (software-only TEE) verify_chain emits
a warning instead of failing.  Closes #146.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ersion in audit events (INJECT-006)

Move the hardcoded fallback regex patterns out of pipeline.py into
src/cmcp_gateway/inspection/patterns_v1.json with a top-level "version"
field ("1.0.0"). Load at module init via _load_patterns(); log the version
and file path at INFO level on each load.

Replace InspectionResult.injection_pattern_set_hash (a sha256 hash) with
patterns_version (the human-readable semantic version string). Both return
sites in InspectionPipeline.run() — the normal path and the non-UTF-8
early-return — now carry patterns_version=_PATTERNS_VERSION, so every
audit record is tied to the exact pattern set that made the decision.

Tests: replace the three old sha256-hash assertions with five new tests
covering allow, deny, stability across instances, config-file round-trip
(version in result equals version in JSON), and the non-UTF-8 path.

Closes #190.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@imran-siddique
imran-siddique merged commit 1436ce6 into main Jun 8, 2026
1 of 8 checks passed
@imran-siddique
imran-siddique deleted the fix/inject-006-versioned-patterns branch July 29, 2026 23:19
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.

LOW: Injection detection patterns not version-controlled — pattern changes are not auditable (INJECT-006)

1 participant