Skip to content

fix(hooks): merge_guard hardening — bound ReDoS prefixes + output-side process-sub (#1001, #1002)#1003

Merged
michael-wojcik merged 14 commits into
Synaptic-Labs-AI:mainfrom
michael-wojcik:fix/merge-guard-pre-hardening
Jun 21, 2026
Merged

fix(hooks): merge_guard hardening — bound ReDoS prefixes + output-side process-sub (#1001, #1002)#1003
michael-wojcik merged 14 commits into
Synaptic-Labs-AI:mainfrom
michael-wojcik:fix/merge-guard-pre-hardening

Conversation

@michael-wojcik

Copy link
Copy Markdown
Collaborator

Summary

Hardens the merge_guard PreToolUse(Bash) security control by closing two pre-existing defects surfaced during the #933 / PR #1000 review. Both are scoped, INV-D2-aware fixes with non-vacuous regression proofs.

What landed

F1 — bound O(n²) backtracking in global-flag prefixes (#1001) · 45c406cf

F2 — catch output-side process-substitution under-block (#1002) · 1d921b4c

Tests · be4de4ae (#1001 perf), 247c4d22 (#1002 output-side)

  • New test_merge_guard_perf.py: scaling-ratio + generous absolute ceiling on both quadratic paths + the httpie copy.
  • New test_merge_guard_output_side_process_sub.py: 39 cases (output-side positives with dangerous payloads, stderr/non-shell/plain-file exclusions, input-side parity).
  • Bidirectional counter-test-by-revert proves every guarantee is coupled to the fix (removal-revert for the under-block positive; distinct broaden-mutations for each over-block exclusion).
  • Full suite: 9290 passed, 0 failures, 0 errors.

Version · d9ed2379 — PATCH bump to 4.4.34 (hardening, not a new user-facing capability).

Why

merge_guard is a security control governed by INV-D2: never weaken detection of a real executing destructive op; over-block is acceptable, under-block is a hole. F2 closes a real under-block; F1 removes a DoS without changing the match set within the realistic envelope.

Known residual (documented, accepted)

F1's {0,32} bound carries a narrow, threat-model-justified residual under-block: a command with >32 valid global tokens (e.g. git -c k=v × 17 = 34 tokens, push --force) executes yet is missed. Accepted as a documented tradeoff vs the O(n²) DoS under the operator/LLM-authored threat model (not adversarial network input; self-padding to evade one's own guard is self-defeating). _MAX_GLOBAL_FLAG_TOKENS is raisable to 64 (still O(1)) if deemed material.

Closes #1001
Closes #1002

@michael-wojcik michael-wojcik merged commit 7dc6a53 into Synaptic-Labs-AI:main Jun 21, 2026
1 check 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

1 participant