makecindy / makecindy/cindy

auto-review: core 的受保护路径判据不覆盖 PowerShell 写 cmdlet(Set-Content/Copy-Item/Out-File)

Open
#2,608 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.7k
Forks
395
Avg merge
21h 48m
Merged PRs (30d)
776

Description

## 问题描述 / What happened

`highImpactExecutionNeedsConsent` 的**受保护路径**判据只认 POSIX 写形态。PowerShell 的写
cmdlet(`Set-Content` / `Copy-Item` / `Out-File` / `Add-Content` / `Move-Item` 等)不在目标
提取范围里,于是「往系统路径写」只判灰区 `prompt`,轻量审阅器可以直接放行。

同一件事在其它入口都是必问:

| 入口 | 命令 | 判档 |
|---|---|---|
| `Write` 工具 | `file_path: C:\Windows\System32\drivers\etc\hosts` | `prompt-each-time` |
| Bash(POSIX) | `echo owned > /etc/hosts` | `prompt-each-time` |
| Bash(POSIX) | `echo owned \| tee /etc/hosts` | `prompt-each-time` |
| Bash(POSIX) | `cp payload /etc/hosts` | `prompt-each-time` |
| **PowerShell 工具** | `Set-Content C:\Windows\System32\drivers\etc\hosts owned` | **`prompt`** |
| **PowerShell 工具** | `Copy-Item payload C:\Windows\System32\...` | **`prompt`** |
| **PowerShell 工具** | `'x' \| Out-File C:\Windows\System32\...` | **`prompt`** |
| **Bash 原样同串** | `Set-Content C:\Windows\...\hosts owned` | **`prompt`** |
| **Bash** | `pwsh -Command Set-Content C:\Windows\...\hosts owned` | **`prompt`** |

**后三行说明这是 core 侧缺口、对所有 harness 一致**:把同一串原文交给 `Bash` 工具
(完全不经任何 adapter 改写)结论相同,Codex 今天也一样。

## 环境 / Environment

- 本机 macOS,Cindy `main`(复现方式为 maker-core 单测直接调用判据,不依赖实机会话)
- `workspaceRoots: ['C:\repo']`

## 复现步骤 / Steps to reproduce

```ts
classifyBuiltinToolForAutoReview({
toolName: 'Bash', // 用 Bash 入口即可,证明与 adapter 无关
input: { command: 'Set-Content C:\\Windows\\System32\\drivers\\etc\\hosts owned' },
workspaceRoots: ['C:\\repo'],
})
// 实得 'prompt',期望 'prompt-each-time'(与 `echo > /etc/hosts` 对齐)
```

## 建议修法

在 core 的受保护路径目标提取里补 PowerShell 写 cmdlet 的实参位置,让它与 POSIX 的
`>` / `tee` / `cp` 走同一条判据。要考虑的点:

1. **cmdlet 集合**:`Set-Content` / `Add-Content` / `Out-File` / `Copy-Item` / `Move-Item` /
`New-Item` / `Rename-Item`,以及别名(`sc`(注意与 `sc.exe` 区分)/ `cpi` / `mi` / `ni` / `ren`)。
2. **目标参数位置**:PowerShell 既可位置传参也可 `-Path` / `-LiteralPath` / `-Destination`;
`Out-File` 常出现在管道右侧。
3. **是否只对系统/受保护路径升级**:工作区内写应保持放行,避免把日常开发命令打成必问。

## 风险边界

- 这是**既有缺陷**,不是 PR #2560 引入的:#2560 之前 `PowerShell` 工具的这类请求会被
**静默拒绝**(落兜底 `other` 且无 description → 在调模型前直接 block,用户看不到卡也没有
理由),那不是「硬门禁」而是缺陷本身;`Bash` 入口在 #2560 前后都判 `prompt`。
- 方向是**收严**,会同时改 Codex / Bash 入口的判档,属跨 harness 收严,需独立评审 ——
这也是它必须单独立项、不能塞进 #2560 的原因(#2560 已声明「不收紧任何权限、不加敏感路径
判据」为非目标)。
- 受影响的只有「往系统/受保护路径写」这一类,不涉及普通开发命令。

## 相关

- PR #2560:把 `PowerShell` 从静默拒绝改为交审阅器裁决;review 中由 codex 发现此缺口。
- Issue #2563:core 侧 PowerShell 判据的另一族缺口(解释器解析 / 跨段判断)。

Contributor guide

Open the contributing guide

Research direction

Start at classifyBuiltinToolForAutoReview and the maker-core unit test that reproduces the Bash input; trace the protected-path target extraction used for auto-review. Add coverage for the listed PowerShell cmdlets, aliases, positional and named targets, and pipeline form, then verify protected paths yield prompt-each-time while workspace paths retain their existing result.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, typescript
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.