Skip to content

fix(tool): ledger separates downgraded allows from denials + decode-to-shell ASK rule (#4273) - #4274

Draft
topcheer wants to merge 1 commit into
mainfrom
fix/issue-4273
Draft

topcheer wants to merge 1 commit into
mainfrom
fix/issue-4273

Conversation

@topcheer

Copy link
Copy Markdown
Owner

Fixes #4273 (ledger 语义层 + 解码规则补偿;规则表降级归 #4238)。

修复要点

  1. SecurityLedger.Escalation 分组([business-logic] command gate 注入规则按语法形式而非危险语义判定:bash/PowerShell 普通替换语法全量误报 Ask + bypass 降级放行被记为 denied 滚出虚假 SECURITY ESCALATION #4273 核心):
    • ask-allowed 事件(bypass 降级放行、命令实际执行)不再参与 denied 排名——旧文案 "was denied N times ... sandbox-probing" 对实际执行成功的命令是事实性错误指控(用户实测同会话 186 次)
    • 真拒绝(block/eperm/ask-blocked)保持阈值 3 + 原探测指纹语义,且优先级高于降级组
    • 降级放行组阈值 10 + 中性 SECURITY NOTICE 文案("auto-approved N times ... these commands RAN, they were not denied")
  2. gate 新增 decoded payload piped to shell Ask 规则:(base64|openssl enc -d|xxd -r -p).*\|\s*(ba)?sh\b——裸 $()/${}/backtick 规则唯一真实捕获面(base64 -d x | sh 类混淆载荷),显式内容化,堵住 fix(tool): downgrade shell-substitution ASK rules to informational warnings #4238 降级后扩大的缺口;结尾 \b 吸取 [business-logic] command_gate.go pipe-to-shell rule lacks word boundary - '| sha256sum' flagged as piping to shell #815(sha256sum/shasum 不误报)
  3. zz_issue3282_test.go 适配:探针 echo $(date) → rm -f temp.txt(destructive Ask 源,在 fix(tool): downgrade shell-substitution ASK rules to informational warnings #4238 前后两种规则表形态下都稳定触发 Ask);断言改为分裂阈值语义

与 #4238 的关系(互补,已与 reviewer 对齐)

  • fix(tool): downgrade shell-substitution ASK rules to informational warnings #4238:五条裸符号规则降级为 warning(规则层)
  • 本 PR:ledger 语义层 + 解码规则补偿;调用点零改动(ruleKind 已天然编码 outcome);command_gate.go 仅新增一条规则,无逻辑交叉
  • 叠加终态:注入语法→warning / 解码到 shell→Ask / bypass 降级→中性 notice 不计 denied / 真拒绝→原 ESCALATION 语义

测试证据

  • 新增 zz_issue4273_test.go 5 组:解码到 shell 全形态 Ask(含 fix(tool): downgrade shell-substitution ASK rules to informational warnings #4238 回归面 echo $(printf 'x' | base64 -d) | sh);解码无 shell 消费者不误报;3/9 次降级静默、10 次中性 notice 且禁用 denied 措辞;真拒绝保探测语义;两组不交叉计数+真拒绝优先
  • 定向(4273/3282/SecurityLedger/CommandGate)+ 全包 go test -tags goolm ./internal/tool/ 绿(65s)
  • go build + go vet 绿

🤖 Generated with ggcode

…o-shell ASK rule (#4273)

- SecurityLedger.Escalation now ranks true denials (block/eperm/ask-blocked)
  separately from ask-allowed events: a bypass-downgraded ask RAN, it was not
  denied - the old wording fired 'was denied N times ... sandbox-probing' at
  threshold 3 for commands that executed fine (user-measured 186/session).
  Downgraded allows escalate at threshold 10 with neutral SECURITY NOTICE
  wording; true denials keep the probing fingerprint and outrank.
- New gate ASK rule 'decoded payload piped to shell'
  (base64|openssl enc -d|xxd -r -p ... | sh): the one capture surface the
  bare shell-substitution rules uniquely held, kept as an explicit content
  rule so PR #4238's downgrade of the syntax rules does not widen it.
- zz_issue3282_test.go probe switched to a destructive Ask source (rm -f
  temp.txt) stable under both rule-table shapes; assertions updated to the
  split-threshold semantics.

Complements #4238 (rule-table downgrade); zero overlap in call sites.

This branch has not been deployed

No deployments
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