rescue: V-011 obfuscation fix + compressor tuning (cherry-pick from #131) #178

Closed
claude wants to merge 2 commits from rescue/v011-obfuscation-fix into main

2 Commits

Author SHA1 Message Date
Ezra
3c8510cc0a fix(context_compressor): reduce default protect_last_n from 20 to 5
Some checks failed
Forge CI / smoke-and-build (pull_request) Failing after 2s
The previous default of 20 protected messages was overly conservative,
preventing meaningful compression on long sessions. Reducing to 5
strikes a better balance between preserving recent conversational
context and allowing the compressor to actually reduce token pressure.

Updates both ContextCompressor default and AIAgent integration,
plus adds a regression test verifying the last 5 turns are never
summarized away.
2026-04-07 02:20:34 -04:00
Ezra
5a47056073 feat(skills_guard): V-011 obfuscation bypass detection
Adds defense-in-depth against obfuscated malicious skill code:
- normalize_input() with NFKC normalization, case folding, and zero-width
  character removal to defeat homoglyph and ZWSP evasion.
- PythonSecurityAnalyzer AST visitor detecting eval/exec/compile,
  getattr dunder access, and imports of base64/codecs/marshal/types/ctypes.
- Additional regex patterns for getattr builtins chains, __import__
  os/subprocess, and nested base64 decoding.
- Integrates all patterns into scan_file(); Python files now get both
  normalized regex scanning and AST-based analysis.

Includes full test coverage in tests/tools/test_skills_guard.py.
2026-04-07 02:20:31 -04:00