Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e0e1d61
fix(ci): narrow serve-ab's self-hosted wipe to the A/B checkout dirs
qwen-code-dev-bot Aug 15, 2026
2eeb0ce
test(ci): derive serve-ab wipe pin from the checkout paths (#9228)
qwen-code-dev-bot Aug 15, 2026
aa3ab19
test(ci): pin the serve-ab wipe's full executed script and step order…
qwen-code-dev-bot Aug 15, 2026
e765e1a
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 15, 2026
e7bb585
fix(ci): match serve-ab's wipe step name and pin to its narrowed scop…
qwen-code-dev-bot Aug 15, 2026
900221e
fix(ci): exclude the shared root .git from serve-ab's self-hosted wip…
qwen-code-dev-bot Aug 16, 2026
415d980
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 16, 2026
8074297
fix(ci): keep only a real .git and scrub its exec state in serve-ab w…
qwen-code-dev-bot Aug 16, 2026
664f791
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 16, 2026
781a982
fix(ci): follow a symlinked workspace root in the serve-ab wipe (#9228)
qwen-code-dev-bot Aug 17, 2026
50d038c
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 18, 2026
2a2c6c4
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 18, 2026
a8a4ec6
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 19, 2026
d92db6d
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 20, 2026
a861aeb
Merge remote-tracking branch 'origin/main' into fix/serve-ab-narrow-s…
qwen-code-dev-bot Aug 20, 2026
9658f76
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 21, 2026
0323a69
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 22, 2026
c3357ee
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 23, 2026
4fd6a7a
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 23, 2026
51777f4
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 24, 2026
9b5b134
fix(ci): defang the worktreeConfig bypass and anchor the serve-ab wip…
qwen-code-dev-bot Aug 24, 2026
8306207
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 107 additions & 8 deletions .github/scripts/ci-runner-routing.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ const pickRunner = ciDoc.jobs.classify_pr.steps.find(
// author_association.
function simulateRunsOn({ ecsDisabled, sameRepo, assoc, mergeGroup }) {
const trusted = TRUSTED.includes(assoc);
const ecs =
!ecsDisabled && (sameRepo || trusted || mergeGroup);
const ecs = !ecsDisabled && (sameRepo || trusted || mergeGroup);
return ecs ? ECS : HOSTED;
}

Expand Down Expand Up @@ -169,7 +168,10 @@ describe('ci.yml classify_pr runner routing', () => {
classifyRunsOn,
/contains\(fromJSON\('\["OWNER","MEMBER","COLLABORATOR"\]'\), github\.event\.pull_request\.author_association\)/,
);
assert.match(classifyRunsOn, /vars\.MAINTAINER_ECS_RUNNER_DISABLED != 'true'/);
assert.match(
classifyRunsOn,
/vars\.MAINTAINER_ECS_RUNNER_DISABLED != 'true'/,
);
assert.match(classifyRunsOn, /github\.event_name == 'merge_group'/);
});
});
Expand All @@ -188,12 +190,109 @@ describe('serve-ab.yml runner routing', () => {
assert.match(runsOn, /ubuntu-latest/);
});

it('wipes the reused workspace before checking out PR code', () => {
const wipe = serveAbDoc.jobs.ab.steps.find(
(s) => s.name === 'Wipe stale workspace before checkout',
it('wipes the reused workspace except the shared root .git before checking out PR code', () => {
const steps = serveAbDoc.jobs.ab.steps;
const wipeIndex = steps.findIndex(
(s) =>
s.name ===
'Wipe stale workspace except the shared .git before checkout',
);
assert.ok(wipe, 'self-hosted reuse must not bleed one PR into the next');
assert.ok(
wipeIndex !== -1,
'self-hosted reuse must not bleed one PR into the next',
);
const wipe = steps[wipeIndex];
assert.equal(wipe.if, "${{ runner.environment == 'self-hosted' }}");
assert.match(wipe.run, /find "\$WS" -mindepth 1 -maxdepth 1 -exec rm -rf/);
// The script text alone does not decide whether the wipe runs: the
// shell wrapper, continue-on-error (step and job level), and env
// overrides (BASH_ENV, PATH, GITHUB_WORKSPACE) — at step, job, and
// workflow level — all control whether the pinned command executes
// and whether its failure fails the job.
const shell =
wipe.shell ??
serveAbDoc.jobs.ab.defaults?.run?.shell ??
serveAbDoc.defaults?.run?.shell;
assert.ok(
shell === undefined || shell === 'bash',
'the wipe must run under the default bash wrapper',
);
assert.ok(
!('continue-on-error' in wipe),
'a failed wipe must fail the job, not bleed into the next PR',
);
assert.ok(
!('continue-on-error' in serveAbDoc.jobs.ab),
'a job-level continue-on-error would mask a failed wipe',
);
for (const envMap of [wipe.env, serveAbDoc.jobs.ab.env, serveAbDoc.env]) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred to the next round. Critical-only mode is active (5 change-producing rounds complete), and executing the wipe against a synthetic workspace would pin behavior that is pending the maintainer decision on the R9-1 thread — the script under test may change wholesale or disappear depending on that call. Left open for the next round / human follow-up.

中文说明

延后至下一轮。 Critical-only 模式已生效(已完成 5 个产生改动的轮次),而在合成工作区上执行 wipe 会钉住一项正等待 R9-1 线程维护者决策的行为 —— 视该决策而定,被测脚本可能被整体改写或直接删除。保持开放,留待下一轮 / 人工跟进。

assert.ok(
!envMap ||
(envMap.BASH_ENV === undefined &&
envMap.PATH === undefined &&
envMap.GITHUB_WORKSPACE === undefined),
'BASH_ENV, PATH, or GITHUB_WORKSPACE can shadow the pinned wipe command',
);
}
// The sudo-less wipe only works because ownership-restore ran first,
// and it must precede the checkouts or it deletes the freshly
// checked-out code instead of stale leftovers.
const stepIndex = (name) => steps.findIndex((s) => s.name === name);
const ownershipIndex = stepIndex('Restore workspace ownership');
assert.ok(
ownershipIndex !== -1,
'the wipe depends on the ownership-restore step existing',
);
assert.match(
steps[ownershipIndex].run,
/chown -R .* "\$GITHUB_WORKSPACE"/,
'ownership-restore must actually chown the workspace',
);
assert.ok(
ownershipIndex < wipeIndex,
'the wipe depends on ownership-restore running first',
);
const checkouts = steps.filter((s) =>
String(s.uses || '').startsWith('actions/checkout'),
);
for (const checkout of checkouts) {
assert.ok(
steps.indexOf(checkout) > wipeIndex,
'the wipe must run before every checkout it protects',
);
}
assert.ok(checkouts.length >= 2, 'expected at least two checkouts');
// Wiping the shared root .git forces the next job on this runner to
// re-fetch the full history from github.com — on the ECS pool's slow
// link that is the "hung runner" pathology. The checkout-heal path
// guard (#9220, #9265) ahead of it is pinned and exec-verified by
// scripts/tests/serve-ab-workflow.test.js; here pin that the guard is
// present and hands off to the kept-.git tail, line by line, so any
// change forces a deliberate test update.
assert.match(
wipe.run,
/refusing to wipe suspicious workspace path/,
'the wipe must keep the checkout-heal path guard',
);
const executed = wipe.run
.split('\n')
.map((l) => l.trim())
Comment on lines +277 to +278

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined — intentional strictness, not an oversight. This round's rework pins the wipe step's entire executed-line set (see the R2-1 thread), and that pin is deliberately exact: any change to the wipe script — a backslash continuation wrap or a trailing inline comment on the rm line included — must update the pin in the same diff. That friction is the point: an edit to this rm gets a reviewer's eyes on the workflow change and the pin update together. The failure mode is safe: an innocent reformat produces red CI (fixed by re-pinning in the same PR), never a green CI hiding a widened wipe. Adding continuation-joining plus trailing-comment stripping to the guard is shell lexing inside a regression test — complexity for the very scenario the guard exists to catch. Note the strictness is pre-existing: the prior byte-exact pin also failed on a continuation wrap (your witness confirms), so the rework introduces no new friction here.

中文说明

拒绝——这是有意的严格性,并非疏忽。本轮重构将 wipe 步骤的全部执行行集合作为固定对象(见 R2-1 线程),且该固定有意做到精确:wipe 脚本的任何改动——包括续行反斜杠换行或 rm 行尾的行内注释——都必须在同一 diff 中同步更新固定。这种摩擦正是目的所在:对该 rm 的修改会让审阅者同时看到工作流改动与固定更新。失败模式也是安全的:无辜的重排只会导致红色 CI(在同一 PR 中重新固定即可修复),绝不会出现放宽 wipe 却绿灯通过。在守卫中加入续行合并与行尾注释剥离,等于在回归测试里做 shell 词法解析——是为守卫本就要拦截的场景增加复杂度。另外,此严格性并非新增:此前的逐字节固定同样会在续行换行时失败(你的见证也证实了这一点),因此本轮重构没有引入新的摩擦。

.filter((l) => l !== '' && !l.startsWith('#'));
assert.equal(executed[0], 'set -uo pipefail');
const tail = executed.slice(-3);
assert.equal(
tail[0],
'find "$WS" -mindepth 1 -maxdepth 1 ! \\( -name \'.git\' -type d \\) -exec rm -rf {} +',
'the wipe must keep only a REAL .git directory — a symlink or gitfile named .git can point outside the workspace — and only the guarded $WS may reach the rm',
);
assert.equal(
tail[1],
'rm -rf "$WS/.git/hooks" "$WS/.git/info/attributes"',
'the kept .git must lose its hooks and info/attributes exec vectors',
);
assert.equal(
tail[2],
'{ git config --local --name-only --list 2>/dev/null || true; } | { grep -ivE \'^(core\\.(repositoryformatversion|bare|filemode|symlinks|ignorecase|precomposeunicode|logallrefupdates|worktree|hidedotfiles|protecthfs|protectntfs)|remote\\.|branch\\.|extensions\\.|gc\\.|pack\\.|fetch\\.|index\\.|safe\\.|submodule\\.[^.]+\\.(url|active|branch))\' || true; } | while IFS= read -r key; do git config --local --unset-all "$key" 2>/dev/null || true; done',
'the kept .git config must be scrubbed to the qwen-triage.yml config-sanitize allowlist',

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred to the next round. Critical-only mode is active (5 change-producing rounds complete), and this cross-copy allowlist parity pin targets exactly the scrub whose fate is the open maintainer decision on the R9-1 thread — pinning it now would preempt that call and grow a diff that option 1 deletes outright. Left open for the next round / human follow-up.

中文说明

延后至下一轮。 Critical-only 模式已生效(已完成 5 个产生改动的轮次),而这个跨副本 allowlist 一致性钉住的目标,正是 R9-1 线程中待维护者决策的擦洗本身 —— 现在钉住会抢先于该决策,并增大一个在方案 1 下会被整体删除的 diff。保持开放,留待下一轮 / 人工跟进。

);
});
});
37 changes: 28 additions & 9 deletions .github/workflows/serve-ab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,13 @@ jobs:
fi
chmod -R u+rwX "$GITHUB_WORKSPACE" 2>/dev/null || sudo -n chmod -R u+rwX "$GITHUB_WORKSPACE" || echo "::warning::could not restore workspace write permissions; checkout may fail on leftover read-only files"

- name: 'Wipe stale workspace before checkout'
- name: 'Wipe stale workspace except the shared .git before checkout'
if: "${{ runner.environment == 'self-hosted' }}"
run: |-
set -uo pipefail
# The two checkouts clone into head/ and base/ subdirectories;
# leftovers there from a previous run on the same reusable runner
# could bleed into the builds and silently change the posted A/B
# diff. Hosted runners are ephemeral and never see this. After the
# Leftovers from a previous run on the same reusable runner could
# bleed into the builds and silently change the posted A/B diff.
# Hosted runners are ephemeral and never see this. After the
# ownership-restore step everything is user-owned, so no sudo.
#
# Guard, ported from qwen-code-pr-review.yml's checkout heal
Expand Down Expand Up @@ -166,6 +165,8 @@ jobs:
# Canonicalize before matching: the kernel resolves non-canonical
# spellings to the guarded roots (`/home/.` -> /home, `//usr` ->
# /usr), so a raw string match lets them slip past the case arms.
# Realpath also resolves a symlinked workspace root before the
# match, so the wipe below never starts from a link.
WS="$(realpath -m -- "$WS" 2>/dev/null)" || { echo "::error::refusing to wipe: realpath unavailable, cannot canonicalize ${GITHUB_WORKSPACE}"; exit 1; }
while [ "${WS%/}" != "$WS" ]; do WS="${WS%/}"; done
case "$WS" in
Expand All @@ -181,10 +182,28 @@ jobs:
"$RWS"/*) ;;
*) echo "::error::refusing to wipe workspace outside the runner workspace: ${WS} (runner workspace: ${RWS})"; exit 1 ;;
esac
# Bare on purpose: this job runs under `bash -eo pipefail`, so a
# wipe that cannot clear the workspace fails the job here instead
# of building both checkouts on top of the leftovers.
find "$WS" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
# Everything is removed except a real shared root .git directory:
# wiping the .git forces the next job on this runner to re-fetch
# the full ~900 MB of history from github.com. On the ECS pool's
# slow link that stalls checkouts for 20+ minutes and the fetches
# drop mid-pack often enough to read as hung runners. Only a plain
# directory survives the find: a symlink or gitfile named .git can
# point at an attacker-controlled repo outside the workspace, so it
# is removed like any other leftover. The kept repo is then reduced
# to plumbing — hooks and info/attributes deleted, local config
# scrubbed to the same allowlist as qwen-triage.yml's config-
# sanitize (git's exec knobs are an open-ended class; an allowlist
# closes the class instead of denylisting knobs one by one).
# Objects and refs — the reason the .git is kept — are untouched,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Escalated together with the R9-1 thread — same maintainer decision. The refs/replace channel reproduces independently here: after the verbatim wipe, refs/replace/<sha> is ALIVE and the pinned "good" SHA resolves to the evil content (git cat-file -p <good>:f.txt returns the planted payload). Objects and refs are untouched by the config scrub and by this round's find -H fix, so this class closes only via the two options posted on the R9-1 thread: revert to the full wipe, or a fail-closed integrity gate that includes refs/replace removal + git fsck --strict. The decision is pending there.

中文说明

与 R9-1 线程一并升级 —— 同一个维护者决策。 refs/replace 通道已在此独立复现:原样 wipe 之后 refs/replace/<sha> 仍然存活,被钉住的"good" SHA 解析出恶意内容(git cat-file -p <good>:f.txt 返回植入的载荷)。objects 与 refs 不受 config 擦洗和本轮 find -H 修复的影响,因此该类问题只能通过 R9-1 线程中的两个选项关闭:回退为完整清除,或包含 refs/replace 删除 + git fsck --strict 的失败即关闭完整性闸门。决策在该线程中等待。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposition: escalated to a maintainer's decision — same pending decision as the R9-1 thread; this thread is deliberately left open. The finding was re-probed at the reviewed commit and stands.

This round's re-probe on this checkout (a8a4ec65): planted git replace <good> <evil> in a scratch repo, ran the verbatim wipe step (serve-ab.yml:74-144) — the wipe exits 0, git replace -l still lists the mapping afterwards, and a pinned-SHA read of <good>:f.txt materializes attacker content while the --no-replace-objects control resolves trusted content. The structural claim also checks out by inspection: zero matches across all of .github for any handling of refs/replace, git fsck, or GIT_NO_REPLACE_OBJECTS, and the wipe keeps objects/ and refs/ intact by design (line-135 comment). The named pool consumers check out too: ci.yml (line 66) and qwen-code-pr-review.yml (lines 136/193/287/416) route root checkouts to the same ecs-qwen pool with no git-config sanitize step, and qwen-autofix.yml stages its PAT push after pool reuse. The finding stands as written.

Why this is escalated instead of implemented: closing this class structurally — deleting refs/replace (loose + packed-refs), sweeping non-essential ref namespaces, gating reuse on git fsck --strict with rm-on-failure so the next consumer fresh-clones, and consumer-side GIT_NO_REPLACE_OBJECTS=1 for SHA-pinned checkouts — is a redesign of this PR's kept-.git approach, and part of it (the consumer-side env) lives in other workflows outside this PR's footprint; issue #9285 tracks those pool-side follow-ups. The alternative — reverting to the full wipe — abandons this PR's purpose but closes this class structurally, since nothing is kept to reuse. Choosing between those directions is a maintainer's call: the same single question posted on the R9-1 thread (Option A revert vs Option B fail-closed gate, full package) decides this finding too.

Question for the maintainer: see the R9-1 thread — revert to the full wipe, or keep the design and gate the kept .git's reuse on a fail-closed integrity pass (refs/replace sweep + git fsck --strict gate + fail-loud audit)? Recommendation recorded there: Option A if the ~900 MB re-fetch cost is acceptable, Option B (full package) otherwise.

中文说明

处理决定:上交给维护者决策——与 R9-1 讨论串是同一个待定决定;本讨论串有意保持未解决状态。该发现已在被审查提交上重新探测验证,结论成立。

本轮在本检出(a8a4ec65)上重新探测:在临时仓库中植入 git replace <good> <evil>,然后逐字运行 wipe 步骤(serve-ab.yml:74-144)——wipe 以退出码 0 结束,之后 git replace -l 仍列出该映射,且对固定 SHA 的 <good>:f.txt 读取会物化出攻击者内容,而 --no-replace-objects 对照组解析出的是可信内容。结构性论断也经代码检查核实:整个 .github 中没有任何处理 refs/replace、git fsck 或 GIT_NO_REPLACE_OBJECTS 的地方(零匹配),并且 wipe 按设计保留 objects/ 和 refs/ 不动(第 135 行注释)。所列池侧消费者也核实无误:ci.yml(第 66 行)和 qwen-code-pr-review.yml(第 136/193/287/416 行)将根检出路由到同一个 ecs-qwen 池且没有任何 git-config 清洗步骤,而 qwen-autofix.yml 在池复用之后暂存其 PAT 推送。该发现按原文成立。

为什么选择上交而不是直接实现:从结构上闭合这一攻击面——删除 refs/replace(松散 + packed-refs)、清扫非必要 ref 命名空间、以 git fsck --strict 作为复用闸门且失败即 rm 使下一个消费者全新克隆、以及在固定 SHA 的检出侧设置 GIT_NO_REPLACE_OBJECTS=1——属于对本 PR 保留 .git 方案的重新设计,且其中一部分(消费者侧环境变量)位于本 PR 足迹之外的其他工作流中;issue #9285 负责跟踪这些池侧后续项。另一种选择——回退到完整 wipe——会放弃本 PR 的目的,但由于不保留任何可复用内容,能从结构上闭合这一攻击面。在这些方向之间做取舍是维护者的决定:R9-1 讨论串中发布的同一个问题(方案 A 回退 vs 方案 B 失败即关闭闸门、完整一揽子)同样决定本发现的走向。

给维护者的问题: 见 R9-1 讨论串——回退到完整 wipe,还是保留现有设计并对保留 .git 的复用施加失败即关闭的完整性闸门(refs/replace 清扫 + git fsck --strict 闸门 + 失败即高声报错的审计)?建议已记录在那里:如果约 900 MB 重新拉取的代价可以接受则选方案 A,否则选方案 B(完整一揽子)。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still standing at the current head — I re-probed it myself this round: planted git replace <clean-sha> <evil-sha>; the wipe exits 0, the replace ref is ALIVE afterward, and a consumer git checkout --force <clean-sha> reports HEAD = the pinned clean SHA while materializing the attacker's file content. GIT_NO_REPLACE_OBJECTS/--no-replace-objects appears nowhere under .github/. Same pending maintainer decision as the R9-1 thread (triage defer comment 5311584017): full-wipe revert, or a fail-closed integrity gate (refs/replace removal + git fsck --strict with rm -rf .git on failure) — and removing refs/replace costs no re-fetch, since the re-fetch rationale defends object retention, not replace-ref integrity. The loop will not pick between those directions on its own, so this thread stays open for the maintainer's answer.

中文说明

在当前 head 上仍然存在 —— 本轮我亲自重跑了探针:预植 git replace <clean-sha> <evil-sha>;wipe 以 0 退出,之后 replace ref 仍然存活,消费方执行 git checkout --force <clean-sha> 时 HEAD 报告为钉住的干净 SHA,落盘的却是攻击者的文件内容。.github/ 下没有任何地方使用 GIT_NO_REPLACE_OBJECTS/--no-replace-objects。与 R9-1 thread 同属一个待决的维护者决策(triage defer 评论 5311584017):恢复完全清除,或加 fail-closed 完整性闸门(删除 refs/replace + git fsck --strict,失败则 rm -rf .git)—— 且删除 refs/replace 不需要重新 fetch,因为重新 fetch 的理由捍卫的是 objects 的保留,而非 replace-ref 的完整性。循环不会自行在这些方向中做选择,因此本 thread 保持开放,等待维护者答复。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against a861aeb3: the wipe touches neither refs/replace/* nor object integrity — the kept .git's objects and refs are attacker-writable across pool jobs, and a SHA-pinned checkout can materialize substituted content while rev-parse HEAD still prints the pinned SHA. The finding stands, and its surface (objects + refs of the kept repo) closes only structurally, not entrance by entrance.

No code change this round — this is the same pending maintainer decision as the R9-1 thread: revert to the full wipe, or a fail-closed integrity gate (delete loose and packed refs/replace, sweep non-essential ref namespaces, gate reuse on git fsck --strict with rm -rf of the kept .git on failure). Per-entrance config hardening (R9-1) does not close this class, so I have not implemented it as a stand-in. Answering the R9-1 thread settles this finding too.

中文说明

已在 a861aeb3 上核实:wipe 既不触碰 refs/replace/*,也不校验对象完整性——被保留 .git 的 objects 与 refs 在池内任务之间可被攻击者写入,按 SHA 固定的 checkout 可能物化出被替换的内容,而 rev-parse HEAD 仍打印固定的 SHA。该发现成立,且其攻击面(被保留仓库的 objects + refs)确实只能结构性关闭,无法逐入口关闭。

本轮未改代码——这与 R9-1 线程是同一个待维护者决策的问题:恢复完整 wipe,或失效即关的完整性门禁(删除松散与打包的 refs/replace、清扫非必要 ref 命名空间、以 git fsck --strict 作为复用门禁、失败时 rm -rf 被保留的 .git)。逐入口的 config 加固(R9-1)无法关闭该类问题,因此我未拿它顶替。R9-1 线程一有答复,本发现也随之解决。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] R8-9 still stands at 9658f76 and rides the same pending maintainer decision as the R9-1 thread (triage defer comment 5311584017). No code change this round.

R8-9 is the structural half of that decision: refs/replace and pack-index forgery live in the object store, where no config scrub reaches. Option (B) in the R9-1 thread therefore must include the objects/refs integrity gate — delete replace refs (loose + packed-refs), sweep non-essential ref namespaces, gate reuse on git fsck --strict, and rm -rf the kept .git on failure, with consumer-side GIT_NO_REPLACE_OBJECTS=1 as defense in depth. Option (A), reverting to the full wipe, closes this finding unconditionally. Question for the maintainer: (A) or (B)? The thread stays open until answered.

中文说明

[Critical] R8-9 在 9658f76 仍然成立,并与 R9-1 线程共用同一个待定的维护者决策(triage 延后评论 5311584017)。本轮未做代码改动。

R8-9 是该决策的结构性部分:refs/replace 与 pack-index 伪造位于对象库层面,任何 config 清理都无法触及。因此 R9-1 线程中的选项 (B) 必须包含 objects/refs 完整性闸门 —— 删除 replace 引用(loose 与 packed-refs)、清理非必要的 ref 命名空间、以 git fsck --strict 作为复用前置闸门、失败时 rm -rf 保留的 .git,并在消费端辅以 GIT_NO_REPLACE_OBJECTS=1 作为纵深防御。选项 (A) 回退到完整 wipe,则无条件关闭该发现。维护者需要回答的问题:选 (A) 还是 (B)? 在得到答复之前,本线程保持打开。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposition: escalated for a maintainer decision — thread left open; same pending decision as R9-1.

The finding stands at 0323a697 (this round merged main only; the wipe tail is byte-identical since round 8). The round-16 probes are acknowledged: both channels — refs/replace substitution and pack-index blob forgery — survive the verbatim wipe and materialize attacker content under a pinned SHA while rev-parse HEAD prints the clean SHA.

The objects+refs surface cannot be closed entrance-by-entrance — it closes only structurally, with the same decision as the R9-1 thread (triage defer comment 5311584017): (A) revert to the full wipe, or (B) treat objects+refs as untrusted before reuse — delete refs/replace (loose + packed-refs), sweep non-essential ref namespaces, gate reuse on git fsck --strict with fail-closed removal of the kept .git on failure, plus consumer-side GIT_NO_REPLACE_OBJECTS=1 for SHA-pinned checkouts in the consumer workflows. Because the consumer-side arm lives outside this PR's footprint, (B) closes R8-9 and R9-1 together or not at all.

Open question: same as R9-1 — (A) or (B)? No code change on this class until the maintainer answers.

中文说明

处置:已升级给维护者决策 — 线程保持开放;与 R9-1 为同一待决决策。

该发现在 0323a697 处依然成立(本轮仅合并了 main;擦除尾部自第 8 轮起逐字节相同)。第 16 轮的探针结果已确认:两条通道 — refs/replace 替换与 pack 索引 blob 伪造 — 都能在原样擦除后幸存,并在固定 SHA 下呈现攻击者内容,而 rev-parse HEAD 仍打印干净的 SHA。

对象+引用这个面无法逐入口关闭 — 只能在结构上关闭,依赖与 R9-1 线程(triage 延后评论 5311584017)相同的决策:(A) 回退到完整擦除;或 (B) 在复用前把对象+引用视为不可信 — 删除 refs/replace(松散对象 + packed-refs)、清除非必要引用命名空间、以 git fsck --strict 作为复用门控且失败即删除保留的 .git,并在消费端工作流中对按 SHA 固定的检出设置 GIT_NO_REPLACE_OBJECTS=1。由于消费端这一侧位于本 PR 足迹之外,(B) 要么连同 R9-1 一起关闭,要么完全不成立。

开放问题: 与 R9-1 相同 — (A) 还是 (B)?在维护者答复之前,不会对这个类别做任何代码改动。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stands, and deliberately left unresolved — it closes only via the same pending maintainer decision as R9-1 (triage defer comment 5311584017). Verified read-only at head 4fd6a7aa: the wipe tail touches neither refs/ nor objects/ (by design — they are why the .git is kept), and there is no refs/replace deletion, git fsck, or GIT_NO_REPLACE_OBJECTS/--no-replace-objects anywhere under .github/, matching the demonstrated replace-ref channel. No code change this round: the (A)/(B) choice is the maintainer's. Maintainer question: same decision as R9-1 — full wipe (A), or keep-and-defang plus the structural close including replace-ref deletion, an fsck reuse gate, and consumer-side GIT_NO_REPLACE_OBJECTS (B)? Thread stays open until answered.

中文说明

该发现依然成立,并被有意保持未解决——它只能通过与 R9-1 相同的待决维护者决策来闭合(triage 延后评论 5311584017)。已在 head 4fd6a7aa 上只读核实:清除尾部不触碰 refs/ 和 objects/(设计使然——它们正是保留 .git 的原因),且 .github/ 下没有任何 refs/replace 删除、git fsck 或 GIT_NO_REPLACE_OBJECTS/--no-replace-objects,与已被证实的 replace 引用通道一致。本轮无代码改动:(A)/(B) 选择权在维护者。**维护者问题:**与 R9-1 相同的决策——完全清除 (A),还是保留并去威胁加上结构化收口(含 replace 引用删除、fsck 复用门禁、消费者侧 GIT_NO_REPLACE_OBJECTS)(B)?在得到答复前线程保持开放。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stands at this head, and deliberately left unresolved — same escalation as the round-18 thread: closes only via the pending maintainer decision shared with R9-1 (triage defer comment 5311584017). The round-19 re-probe adjudicating the replace-ref dispute is acknowledged: git checkout --force <sha>, the verbatim pinned actions/checkout command, materializes the replaced tree while rev-parse HEAD prints the clean SHA, and refs/replace survives the wipe by design. No code change this round: the fix shape ((A) full wipe, or (B) replace-ref deletion + ref-namespace sweep + git fsck --strict reuse gate with rm -rf fallback + consumer-side GIT_NO_REPLACE_OBJECTS=1) is the maintainer's choice. Maintainer question: (A) or (B)? Thread stays open until answered.

中文说明

在该 head 上依然成立,并被有意保持未解决——与第 18 轮线程相同的升级:只能通过与 R9-1 共享的待决维护者决策来闭合(triage 延后评论 5311584017)。第 19 轮对 replace 引用争议的重新探测裁定已知悉:git checkout --force <sha>(即固定 actions/checkout 的原命令)会实体化被替换的树,而 rev-parse HEAD 仍输出干净的 SHA,且 refs/replace 按设计在清除后存活。本轮无代码改动:修复形态((A) 完全清除,或 (B) replace 引用删除 + 引用命名空间清扫 + git fsck --strict 复用门禁并在失败时 rm -rf 回退 + 消费者侧 GIT_NO_REPLACE_OBJECTS=1)由维护者选择。维护者问题:(A) 还是 (B)?在得到答复前线程保持开放。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposition: escalated — same pending maintainer decision as the R9-1 thread; deliberately left unresolved.

Verified at the reviewed commit: HEAD is 51777f43a2 and git diff 4fd6a7aa..HEAD over the three PR files is empty — the wipe tail is byte-identical to the head this round's probes re-proved the refs/replace and pack-index channels on, so the finding stands by code identity. It closes only structurally (objects and refs of the kept attacker-writable repo cannot be sanitized entrance by entrance), and the choice is the same contested one recorded in triage defer comment 5311584017: revert to the full wipe, or keep the .git and treat objects+refs as untrusted before handoff (delete refs/replace loose + packed, sweep non-essential ref namespaces, gate reuse on git fsck --strict with rm -rf of the kept .git on failure, plus consumer-side GIT_NO_REPLACE_OBJECTS=1 for SHA-pinned checkouts). The consumer-side arm lives in other workflows outside this PR's footprint, which this loop may not modify; if the maintainer chooses keep-and-harden, that part becomes tracked follow-up work. No code change this round; the decision is not preempted.

Question for the maintainer: same as the R9-1 thread — (A) revert to the full wipe, (B) keep-and-harden with the integrity pass above, or (C) record a risk acceptance and merge as-is?

中文说明

处置:已升级——与 R9-1 线程等待同一维护者决策;有意保持未解决。

已在被评审提交核实:HEAD 为 51777f43a2,三个 PR 文件的 git diff 4fd6a7aa..HEAD 为空——wipe 尾部与本轮探针重新证明 refs/replace 与 pack-index 通道所针对的代码逐字节一致,因此该发现依据代码同一性成立。它只能结构性关闭(保留的、攻击者可写的仓库的 objects 与 refs 无法逐入口净化),而选择与 triage 延迟评论 5311584017 所记录者为同一个有争议的决策:恢复全量清理,或保留 .git 并在移交前将 objects+refs 视为不可信(删除松散与 packed 的 refs/replace、清扫非必要 ref 命名空间、以 git fsck --strict 把关复用并在失败时 rm -rf 保留的 .git,外加消费端在 SHA 锚定检出时使用 GIT_NO_REPLACE_OBJECTS=1)。消费端一环位于本 PR 足迹之外的其他工作流中,本循环不得修改;若维护者选择保留并加固,该部分将成为被跟踪的后续工作。本轮无代码改动;未抢占决策。

给维护者的问题:与 R9-1 线程相同——(A) 恢复全量清理,(B) 按上述完整性检查保留并加固,还是 (C) 书面记录风险接受并按现状合并?

# and actions/checkout re-establishes remote/auth when it reuses
# the repo. The find and the defang rm stay bare on purpose: under
# the job's `bash -eo pipefail` a wipe that cannot clear the
# workspace fails the job here instead of building both checkouts
# on top of the leftovers. Only the config scrub is best-effort,
# mirroring qwen-triage.yml's config-sanitize.
find "$WS" -mindepth 1 -maxdepth 1 ! \( -name '.git' -type d \) -exec rm -rf {} +

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No code change this round, and this thread stays open deliberately: R8-9 closes only via the same pending maintainer decision as R9-1 — (A) the full wipe (the kept objects/refs go away with it), or (B) a fail-closed integrity gate on the kept .git (refs/replace removal from loose refs and packed-refs, git fsck --strict, and rm -rf of the kept .git on failure). The round-22 probes re-confirm both content-substitution channels are open at this head, and the class cannot be closed entrance by entrance — adding scrub arms here would be wasted work under decision (A) and incomplete under decision (B). A maintainer answering on the R9-1 thread (shared decision) unblocks both findings.

中文说明

本轮无代码改动,本线程有意保持开放:R8-9 只能通过与 R9-1 相同的、悬而未决的维护者决策关闭 —— (A) 完整清除(保留的 objects/refs 一并消失),或 (B) 对保留的 .git 施加失败即关闭的完整性门禁(从松散 refs 与 packed-refs 中移除 refs/replace、git fsck --strict、失败时 rm -rf 保留的 .git)。round-22 的探针再次证实两条内容替换通道在当前 head 上均为开放状态,且该类无法逐入口关闭 —— 在此添加清扫防线在决策为 (A) 时是无效劳动,在决策为 (B) 时也不完整。维护者在 R9-1 线程上作答(同一决策)即可同时解锁两条发现。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No code change this round, and this thread stays open deliberately: R8-9 closes only via the same pending maintainer decision as R9-1 — (A) the full wipe (the kept objects/refs go away with it), or (B) a fail-closed integrity gate on the kept .git (refs/replace removal from loose refs and packed-refs, git fsck --strict, and rm -rf of the kept .git on failure). The round-22 probes re-confirm both content-substitution channels are open at this head, and the class cannot be closed entrance by entrance — adding scrub arms here would be wasted work under decision (A) and incomplete under decision (B). A maintainer answering on the R9-1 thread (shared decision) unblocks both findings.

中文说明

本轮无代码改动,本线程有意保持开放:R8-9 只能通过与 R9-1 相同的、悬而未决的维护者决策关闭 —— (A) 完整清除(保留的 objects/refs 一并消失),或 (B) 对保留的 .git 施加失败即关闭的完整性门禁(从松散 refs 与 packed-refs 中移除 refs/replace、git fsck --strict、失败时 rm -rf 保留的 .git)。round-22 的探针再次证实两条内容替换通道在当前 head 上均为开放状态,且该类无法逐入口关闭 —— 在此添加清扫防线在决策为 (A) 时是无效劳动,在决策为 (B) 时也不完整。维护者在 R9-1 线程上作答(同一决策)即可同时解锁两条发现。

rm -rf "$WS/.git/hooks" "$WS/.git/info/attributes"
{ git config --local --name-only --list 2>/dev/null || true; } | { grep -ivE '^(core\.(repositoryformatversion|bare|filemode|symlinks|ignorecase|precomposeunicode|logallrefupdates|worktree|hidedotfiles|protecthfs|protectntfs)|remote\.|branch\.|extensions\.|gc\.|pack\.|fetch\.|index\.|safe\.|submodule\.[^.]+\.(url|active|branch))' || true; } | while IFS= read -r key; do git config --local --unset-all "$key" 2>/dev/null || true; done

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This round's only change was find -H (symlinked workspace root), which does not touch the scrub — so I re-verified the class at 781a9822 with my own probe instead of relying on earlier rounds: in a scratch repo I planted extensions.worktreeConfig=true (allowlisted) plus core.hooksPath in .git/config.worktree. The scrub's git config --local --name-only --list never lists the worktree-scoped key, and the verbatim scrub line left the planted exec knob intact (core.hooksPath still set, .git/config.worktree still present). The finding stands, reproduced, at the reviewed commit.

The disposition is unchanged because the fix is a decision that is not mine to make — both closing options materially change or remove this PR's reason to exist (keeping the shared .git to avoid the ~900 MB re-fetch on the ECS pool's slow link):

  1. Revert to the full wipe — provable closure, reviewer-recommended. It empties this PR's change, so it is effectively "close or rework the PR".
  2. Keep .git behind a fail-closed integrity gate — preserves the purpose, but adds substantial machinery whose cost (a per-wipe git fsck --strict over the ~900 MB object store on the very slow link the PR exists to avoid) may itself negate the gain, and whose consumer-side complement (GIT_NO_REPLACE_OBJECTS=1 at SHA-pinned checkouts) lives in other workflows outside this PR's footprint.

Eight consecutive rounds producing new scrub entrances is strong evidence the allowlist approach cannot converge, which supports option 1 — but rework-vs-close, and whether the re-fetch problem gets a different solution, is the maintainer's call. I am implementing neither direction unilaterally. This thread stays open pending that decision; no code change this round.

中文说明

本轮唯一的改动是 find -H(跟随符号链接的 workspace 根目录),并不涉及 scrub,因此我没有依赖之前轮次的结论,而是用自己的探针在 781a9822 重新验证了这一类问题:在一个临时仓库中植入 extensions.worktreeConfig=true(在 allowlist 内)以及写入 .git/config.worktree 的 core.hooksPath。scrub 所用的 git config --local --name-only --list 根本不会列出 worktree 作用域的键,逐字运行 scrub 行之后,植入的执行开关依然完好(core.hooksPath 仍在,.git/config.worktree 仍存在)。该发现成立,且在被审提交上复现。

处置方式不变,因为修复方式是一个不由我做的决定——两个关闭方案都会实质性地改变或移除本 PR 存在的理由(保留共享 .git,避免在 ECS 池慢速链路上重新拉取约 900 MB 历史):

  1. 回退到完整 wipe —— 可证明的彻底关闭,评审者推荐。它会使本 PR 的改动变空,因此实际上等于"关闭或重做本 PR"。
  2. 在 fail-closed 完整性门禁后保留 .git —— 保留了目的,但要追加大量机制,其代价(每次 wipe 都在 PR 本来要规避的慢速链路上对约 900 MB 对象库跑 git fsck --strict)可能抵消收益本身,且其消费端配套(SHA 固定 checkout 处的 GIT_NO_REPLACE_OBJECTS=1)位于本 PR 足迹之外的其他 workflow 中。

连续八轮都能找出新的 scrub 入口,这有力证明 allowlist 方式无法收敛,支持方案 1——但"重做还是关闭"、以及重新拉取问题是否用其他方案解决,是维护者的决定。我不会单方面实现任一方向。本线程保持开放,等待该决定;本轮不改代码。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed still standing at this head. The file is verified unchanged since the round-10 probes: git log 781a9822..HEAD -- .github/workflows/serve-ab.yml is empty, so the scrub is byte-identical. This round I independently re-reproduced three of the entrances against the verbatim pipeline (git 2.39.5, throwaway repos):

  • planted .git/config.lock → scrub exits 0; planted core.hooksPath, core.sshCommand, and remote.origin.uploadpack all survive; removing the lock and re-running the identical scrub removes them — the lock is the blocker;
  • attack keys planted, then core.repositoryformatversion=999 (allowlisted, survives the scrub) → the scrub's own --list exits 128 (swallowed by || true), scrub exits 0, core.hooksPath and alias.pwn survive in the raw .git/config;
  • extensions.worktreeConfig=true (allowlisted) + git config --worktree core.hooksPath → the key lands in .git/config.worktree, is absent from the --local enumeration, scrub exits 0, and the merged view still serves the planted value.

No further guard will be added this round: rounds 8–11 have each found a new entrance into this class, which is the signal to hold for the escalated decision rather than grow the diff with more enumeration guards. The closures remain the two options already on this thread: (1) revert to the full wipe, or (2) a fail-closed integrity gate. My recommendation is option 1 now — the pre-PR behavior with a known safety profile — and the gate as a separately reviewed follow-up, because security-critical pool machinery should fail simple while the optimization is redesigned. The maintainer decision stays pending; this thread stays unresolved until it is answered.

中文说明

确认该问题在当前 head 上依然存在。已核实文件自第 10 轮的探测以来未变:git log 781a9822..HEAD -- .github/workflows/serve-ab.yml 为空,因此该擦洗脚本与之前逐字节一致。本轮我在临时仓库中(git 2.39.5)对原文脚本独立复现了其中三个入口:

  • 植入 .git/config.lock → 擦洗以 0 退出;植入的 core.hooksPath、core.sshCommand、remote.origin.uploadpack 全部存活;移除锁文件后重跑同一条擦洗命令即可将其删除——锁文件正是阻塞原因;
  • 先植入攻击键,再设置 core.repositoryformatversion=999(该键在允许清单内,擦洗后存活)→ 擦洗自身的 --list 以 128 退出(被 || true 吞掉),擦洗以 0 退出,core.hooksPath 与 alias.pwn 在原始 .git/config 中存活;
  • extensions.worktreeConfig=true(允许清单内)+ git config --worktree core.hooksPath → 该键落入 .git/config.worktree,--local 枚举中不可见,擦洗以 0 退出,合并视图仍返回被植入的值。

本轮不会再添加新的防护:第 8–11 轮每一轮都在这一类别中发现新的入口,这正是应当等待已升级的决策、而不是继续用更多枚举式防护使 diff 膨胀的信号。封闭方案仍是本线程中已列出的两个选项:(1) 回退到全量清理;(2) fail-closed 完整性门。我的建议是立即采用选项 1(即 PR 之前的行为,安全性已知),将完整性门作为单独评审的后续工作——在优化方案重新设计期间,安全关键的池级机制应当以简单方式失败。维护者决策仍在等待中;在其得到答复之前,本线程保持未解决。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposition: escalated to a maintainer's decision — this thread is deliberately left open. The finding was re-probed at the reviewed commit and stands.

This round's re-probe ran the verbatim wipe step (extracted unchanged from serve-ab.yml:74-144) against scratch repos on this checkout (a8a4ec65, git 2.39.5). All four config-scrub bypasses reproduce, every wipe exits 0:

  • a planted .git/config.lock makes every --unset-all fail swallowed by || true — the planted core.hooksPath survives;
  • a .git/config.worktree carrying core.hooksPath under the allowlisted extensions.worktreeConfig is invisible to the --local --list sweep yet runtime-honored — both files survive;
  • a planted .git/commondir makes the scrub's own --list die (exit 128 swallowed on git 2.39.5; on round 13's 2.47.3 it redirected onto the attacker's config — either way the real .git/config is never swept) and the commondir itself survives;
  • repositoryformatversion=999 kills the scrub's own --list the same way — planted keys survive.

core.worktree also remains mechanically allowlisted in the line-144 arm. Nothing about the scrub changed since the earlier probes (the only commit since is a merge of main), so the finding stands as written.

Why this is escalated instead of implemented: the finding's two remediations are contested directions for this PR, and the choice between them is a maintainer's call —

  • Option A — revert to the full wipe (pre-PR behavior): keep this PR's path-guard hardening, remove the keep-.git exception and the scrub. Closes the whole class structurally. Cost: every pool job re-fetches ~900 MB of history — the 20+ minute stall this PR set out to fix.
  • Option B — keep the design, gate the kept .git fail-closed: adopt resanitize-git-config.sh's preamble before the sweep (rm -f commondir/shallow/config.worktree/config.lock, unset extensions.worktreeConfig, drop worktree from the core\. arm, narrow remote\. to remote\..+\.(url|fetch|pushurl)), plus a post-state audit that fails the job loud instead of logging success. The repo already ships this hardened sibling at .github/scripts/resanitize-git-config.sh, whose comments document exactly these bypasses. Note the preamble alone does NOT close the objects/refs class raised in R8-9 — that needs the refs/replace sweep + fsck gate in the sister thread, or the revert.

Question for the maintainer: which direction should this PR take? Recommendation: Option A if the re-fetch cost is acceptable — the entrance-by-entrance scrub has now been shown bypassable in five consecutive rounds, and Simplicity First favors the structural close. Option B (full package, fail-loud audit included) otherwise. Pool-side consumer hardening is tracked in issue #9285 under either choice.

中文说明

处理决定:上交给维护者决策——本讨论串有意保持未解决状态。该发现已在被审查提交上重新探测验证,结论成立。

本轮重新探测在本检出(a8a4ec65,git 2.39.5)上用逐字提取自 serve-ab.yml:74-144 的 wipe 步骤对临时仓库进行了实测。四种 config 清洗绕过全部复现,且每次 wipe 均以退出码 0 结束:

  • 植入 .git/config.lock 会使所有 --unset-all 失败并被 || true 吞掉——植入的 core.hooksPath 存活;
  • 在 allowlist 内的 extensions.worktreeConfig 之下、由 .git/config.worktree 携带的 core.hooksPath,对 --local --list 扫描不可见,却在运行时生效——两个文件均存活;
  • 植入 .git/commondir 会使清洗自身的 --list 失败(git 2.39.5 上退出码 128 被吞掉;第 13 轮的 2.47.3 上则被重定向到攻击者的 config——无论哪种情况,真实的 .git/config 都不会被清洗),且 commondir 本身存活;
  • repositoryformatversion=999 以同样方式杀死清洗自身的 --list——植入的键存活。

core.worktree 也仍然被机械地 allowlist 在第 144 行的分支中。自 earlier 探测以来清洗逻辑没有任何变化(其后唯一的提交是合并 main),因此该发现按原文成立。

为什么选择上交而不是直接实现:该发现给出的两种补救方向对本 PR 而言是相互竞争的方向,二者之间的取舍是维护者的决定——

  • 方案 A——回退到完整 wipe(PR 之前的行为):保留本 PR 的路径守卫加固,移除保留 .git 的例外和 config 清洗。从结构上闭合整个攻击面。代价:池上每个作业都要重新拉取约 900 MB 历史——正是本 PR 想要解决的 20 分钟以上卡顿。
  • 方案 B——保留现有设计,但对保留下来的 .git 施加失败即关闭(fail-closed)的完整性闸门:在扫描前采用 resanitize-git-config.sh 的前置处理(rm -f commondir/shallow/config.worktree/config.lock、unset extensions.worktreeConfig、从 core\. 分支中去掉 worktree、把 remote\. 收窄为 remote\..+\.(url|fetch|pushurl)),再加上一个失败时高声报错而不是记录成功的事后状态审计。仓库中已经带有这个加固版同源脚本 .github/scripts/resanitize-git-config.sh,其注释恰好记录了这些绕过。注意:仅前置处理并不能闭合 R8-9 提出的 objects/refs 攻击面——那需要姊妹讨论串中的 refs/replace 清扫 + fsck 闸门,或者直接回退。

给维护者的问题: 本 PR 应走哪个方向?建议:如果重新拉取的代价可以接受,选方案 A——逐入口清洗的做法已连续五轮被证明可被绕过,Simplicity First 原则倾向于结构上闭合;否则选方案 B(完整一揽子措施,包含失败即高声报错的审计)。无论哪种选择,池侧消费者加固都在 issue #9285 中跟踪。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still standing at the current head — I re-probed the shipped wipe script myself this round (extracted from serve-ab.yml, run under the job's bash -eo pipefail against temp fixtures, git 2.39.5) and all three config entrances reproduce: (1) allowlisted extensions.worktreeConfig + planted .git/config.worktree carrying core.hooksPath — config.worktree survives and hooks resolve at the planted directory outside the workspace; (2) planted .git/config.lock — every --unset-all dies swallowed by || true, the planted exec key survives; (3) allowlisted core.repositoryformatversion=999 — the scrub's own --list exits 128 swallowed, the scrub no-ops while the wipe exits 0 (witnessed against the raw .git/config). Disposition unchanged: this stays escalated to the maintainer's decision (triage defer comment 5311584017) — revert to the full wipe for the .git, or gate the kept repo's reuse on a fail-closed integrity pass; if keep-and-defang stays, adopt the sibling sanitizers' defuse lines first. The loop will not pick between those directions on its own, so this thread stays open for the maintainer's answer.

中文说明

在当前 head 上仍然存在 —— 本轮我亲自重跑了探针(从 serve-ab.yml 提取已发布的 wipe 脚本,按该 job 的 bash -eo pipefail 在临时 fixture 上执行,git 2.39.5),三个配置入口均可复现:(1) 白名单内的 extensions.worktreeConfig + 预植的带 core.hooksPath 的 .git/config.worktree —— config.worktree 存活,hooks 解析到 workspace 之外预植的目录;(2) 预植 .git/config.lock —— 每个 --unset-all 都被 || true 吞掉而失败,预植的可执行键存活;(3) 白名单内的 core.repositoryformatversion=999 —— 清扫自身的 --list 以 128 退出被吞掉,清扫形同虚设而 wipe 以 0 退出(以原始 .git/config 为证)。处置不变:维持升级到维护者决策(triage defer 评论 5311584017)—— 对 .git 恢复完全清除,或对保留仓库的复用加 fail-closed 完整性闸门;若保留 keep-and-defang,须先采纳兄弟清扫器的 defuse 行。循环不会自行在这些方向中做选择,因此本 thread 保持开放,等待维护者答复。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against the reviewed commit a861aeb3: the wipe tail sweeps only git config --local keys against the allowlist — it never removes .git/config.worktree, never unsets the allowlist-kept extensions.worktreeConfig, and never removes .git/commondir/.git/shallow — while this repo's own hardened sanitizers (.github/scripts/resanitize-git-config.sh, and the qwen-triage.yml/qwen-autofix.yml config-sanitize preambles) remove exactly those channels before the identical sweep. The finding stands.

No code change this round: this thread is escalated for a maintainer decision, and each candidate fix is a contested design direction — implementing any one of them would silently settle a deliberately open question. Options: (1) revert to the full wipe; (2) keep-and-defang plus a fail-closed integrity gate; (3) keep-and-defang plus per-entrance parity hardening (restore the resanitize-git-config.sh ordering: rm commondir/shallow/config.worktree, unset extensions.worktreeConfig, then sweep).

My read: option 3 alone cannot suffice, because R8-9's objects/refs surface closes only structurally — if keep-and-defang is kept, option 3 is the floor and option 2 is what closes the class; if the gate's cost is unacceptable, option 1 remains the safe default. I have not reverted unilaterally because the performance motivation is real (wiping the .git forces a ~900 MB re-fetch on the ECS pool's slow link, stalling checkouts 20+ minutes).

Open question for the maintainer: revert, integrity gate, or per-entrance hardening? Whichever is chosen will be implemented next round, with mutation-probed test coverage.

中文说明

已在受审提交 a861aeb3 上核实:wipe 收尾仅按允许列表清扫 git config --local 键——它没有删除 .git/config.worktree、没有取消允许列表保留的 extensions.worktreeConfig、也没有删除 .git/commondir/.git/shallow——而本仓库自己的加固清理器(.github/scripts/resanitize-git-config.sh,以及 qwen-triage.yml/qwen-autofix.yml 的 config-sanitize 前置步骤)在同样的清扫之前恰好会删除这些通道。该发现成立。

本轮未改代码:本线程已升级给维护者决策,且每个候选修复都是互斥的设计方向——实现其中任何一个都会悄悄替一个被刻意保持开放的问题拍板。选项:(1) 恢复完整 wipe;(2) 保留并解除武装(keep-and-defang)加失效即关(fail-closed)的完整性门禁;(3) keep-and-defang 加逐入口对齐加固(恢复 resanitize-git-config.sh 的顺序:删除 commondir/shallow/config.worktree、取消 extensions.worktreeConfig,然后再清扫)。

我的判断:仅选项 3 不够,因为 R8-9 的 objects/refs 攻击面只能结构性关闭——若保留 keep-and-defang,选项 3 是底线,选项 2 才是关闭该类问题的手段;若门禁成本不可接受,选项 1 仍是安全默认。我未擅自回退,因为性能动机真实存在(清掉 .git 会在 ECS 池的慢速链路上强制约 900 MB 的重新获取,使 checkout 卡住 20 分钟以上)。

留给维护者的开放问题:回退、完整性门禁、还是仅逐入口加固?选定任一方向,下一轮即实施,并附带经变异探针验证的测试覆盖。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Critical] R9-1 still stands at 9658f76 and remains escalated for a maintainer decision (triage defer comment 5311584017). No code change this round, so the decision is not preempted.

The two safe end states already on the thread:

  • (A) Revert to the full wipe (pre-PR behavior) — closes every enumerated entrance because nothing is kept.
  • (B) Keep the .git only behind a fail-closed integrity pass — the hardened preamble (rm -f of commondir/shallow/config.worktree/config.lock, unset extensions.worktreeConfig), the narrowed remote\..+\.(url|fetch|pushurl) arm, --file .git/config enumeration, a loud post-state audit — plus R8-9's structural objects/refs gate.

The "at minimum" hardening alone does not resolve this finding: it is conditional on the kept-.git design being retained, and R8-9 proves the objects/refs surface closes only structurally. Question for the maintainer: (A) or (B)? The thread stays open until answered.

中文说明

[Critical] R9-1 在 9658f76 仍然成立,且仍处于已升级、等待维护者决策状态(triage 延后评论 5311584017)。本轮未做代码改动,以免抢先该决策。

线程中已列出两个安全的终态:

  • (A) 回退到完整 wipe(PR 之前的行为)——因为不保留任何内容,所有已枚举的入口全部关闭。
  • (B) 仅当保留的 .git 通过失败即关闭的完整性检查时才保留 —— 强化前置清理(rm -f 删除 commondir/shallow/config.worktree/config.lock、取消 extensions.worktreeConfig),将允许项收窄为 remote\..+\.(url|fetch|pushurl),改用 --file .git/config 枚举,加入失败时明确报错的状态后审计 —— 并叠加 R8-9 要求的 objects/refs 结构性闸门。

仅做 "at minimum" 加固并不能解决该发现:它以保留设计被选择保留为前提,且 R8-9 已证明 objects/refs 面只能结构性关闭。维护者需要回答的问题:选 (A) 还是 (B)? 在得到答复之前,本线程保持打开。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposition: escalated for a maintainer decision — thread left open; not settled unilaterally.

The finding stands at 0323a697 (this round merged main only; the scrub line is unchanged since round 8, and the six re-demonstrated entrances are acknowledged). The two remediation paths are genuinely contested directions, so neither is implemented without the maintainer's call on this open thread (triage defer comment 5311584017, still unanswered):

  • (A) revert to the full wipe — closes every entrance because nothing is kept; gives up the ~900 MB re-fetch avoidance this PR exists for.
  • (B) keep the .git behind a fail-closed integrity pass — closes this class only together with R8-9 (objects/refs are equally attacker-writable), and part of that surface (consumer-side GIT_NO_REPLACE_OBJECTS for SHA-pinned checkouts) lives in other workflows, outside this PR's footprint.

Recommendation for the maintainer: the current keep-and-defang design cannot close this class entrance-by-entrance, and 17 rounds have not produced a way to. (A) closes it inside this PR's current footprint; (B) is a scope expansion that needs explicit approval. Both pinned test suites move with whichever end state is chosen.

Open question: (A) revert to the full wipe, or (B) approve expanding this PR (or a follow-up) to the hardened keep? No further code changes will be made on this class until the thread is answered.

This round's diligence on the post-merge HEAD: node --test .github/scripts/ci-runner-routing.test.mjs — 6 passed; vitest scripts/tests/serve-ab-workflow.test.js — 21 passed.

中文说明

处置:已升级给维护者决策 — 线程保持开放,不单方面定夺。

该发现在 0323a697 处依然成立(本轮仅合并了 main;清洗代码自第 8 轮起未变,本轮重新验证的六个入口均已确认)。两条修复路径是真正存在分歧的方向,因此在维护者对这个开放线程(triage 延后评论 5311584017,仍未答复)作出决定之前,两者都不会实施:

  • (A) 回退到完整擦除 — 因为什么都不保留,所以关闭所有入口;代价是放弃了本 PR 的目标,即避免约 900 MB 的重新拉取。
  • (B) 仅在失败即关闭的完整性检查之后保留 .git — 该类只有与 R8-9 一起才能关闭(对象/引用同样可被攻击者写入),且其中一部分面(消费端对按 SHA 固定检出使用 GIT_NO_REPLACE_OBJECTS)位于其他工作流中,超出本 PR 的足迹。

给维护者的建议:当前的「保留并去害化」设计无法逐入口关闭这个类别,17 轮下来也始终没有产生可行办法。(A) 能在本 PR 当前足迹内关闭它;(B) 属于范围扩张,需要明确批准。无论选择哪种最终状态,两个钉住的测试套件都需随之调整。

开放问题: (A) 回退到完整擦除,还是 (B) 批准把本 PR(或后续 PR)扩展为加固后的保留方案?在线程得到答复之前,不会再对这个类别做任何代码改动。

本轮对合并后 HEAD 的核查:node --test .github/scripts/ci-runner-routing.test.mjs — 6 通过;vitest scripts/tests/serve-ab-workflow.test.js — 21 通过。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stands, and deliberately left unresolved — this is escalated for the maintainer decision (triage defer comment 5311584017), not declined or deferred. Verified read-only at head 4fd6a7aa: the scrub line is unchanged since round 8 and the allowlist still carries the re-probed entrances (extensions.worktreeConfig + config.worktree, planted config.lock, core.repositoryformatversion=999, allowlisted core.worktree). No code change this round: neither (A) reverting to the full wipe nor (B) keeping the .git behind the hardened preamble + fail-closed audit is implemented unilaterally — the choice is the maintainer's, and the probes show partial hardening alone closes nothing. Maintainer question: (A) or (B)? This thread stays open until answered.

中文说明

该发现依然成立,并被有意保持未解决——它已升级为维护者决策(triage 延后评论 5311584017),而非拒绝或延后处理。已在 head 4fd6a7aa 上只读核实:清洗行自第 8 轮以来未变,允许清单仍包含被重新探测绕过的入口(extensions.worktreeConfig + config.worktree、植入的 config.lock、core.repositoryformatversion=999、被允许的 core.worktree)。本轮无代码改动:既未单方面实施 (A) 恢复完全清除,也未实施 (B) 保留 .git 但加硬化前置 + 失败即关闭审计——选择权在维护者,且探测表明仅靠部分硬化无法闭合任何问题。维护者问题:(A) 还是 (B)?在得到答复前本线程保持开放。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stands at this head, and deliberately left unresolved — same escalation as the round-18 thread: the maintainer decision (triage defer comment 5311584017) between (A) reverting to the full wipe and (B) keeping the .git only behind the hardened preamble + fail-closed post-state audit. The four re-probed entrances are acknowledged (including the dropped commondir claim, which this thread correctly does not re-assert); the class argument — that git's config namespace, git-dir files, and repo shape cannot be swept entrance by entrance — is exactly why this is a design decision and not an actionable fix: the probes verify no single hardening piece closes the class. No code change this round (Critical-only mode). Maintainer question: (A) or (B)? If (B), this PR would grow to the structural close named in the finding; if (A), the wipe reverts and the keep-.git tests are removed with it. Thread stays open until answered.

中文说明

在该 head 上依然成立,并被有意保持未解决——与第 18 轮线程相同的升级:等待维护者在 (A) 恢复完全清除与 (B) 仅在硬化前置 + 失败即关闭的事后状态审计之后保留 .git 之间作出决策(triage 延后评论 5311584017)。四个被重新探测的入口已知悉(包括被放弃的 commondir 论断,本线程正确地未再主张);类别论点——git 配置命名空间、git-dir 文件与仓库形态无法被逐入口清扫——正是为什么这是设计决策而非可执行修复:探测已验证任何单一硬化部件都无法闭合该类别。本轮无代码改动(仅处理 Critical 模式)。维护者问题:(A) 还是 (B)?若选 (B),本 PR 将扩展到发现中所述的结构化收口;若选 (A),清除逻辑回退,保留 .git 的相关测试一并移除。在得到答复前线程保持开放。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposition: escalated to a maintainer decision — thread deliberately left unresolved; not settled unilaterally.

Verified at the reviewed commit: HEAD is 51777f43a2 and git diff 4fd6a7aa..HEAD over the three PR files is empty — the scrub is byte-identical to the head this round's probes re-proved the five bypasses on, so the finding stands by code identity; no new probe was needed to confirm it this round.

The pending decision is the one recorded in triage defer comment 5311584017 (deferred to @wensao): (A) revert to the full wipe, or (B) keep the .git only behind the hardened preamble (remove commondir/shallow/config.worktree/config.lock + unset extensions.worktreeConfig before the sweep; narrow remote\. to remote\..+\.(url|fetch|pushurl); drop worktree from the core\. arm; fail-loud post-state audit) plus a fail-closed integrity pass. Both directions are contested scope — A abandons this PR's purpose, B adds substantial security machinery — and the triage record shows the maintainer's Aug-16 position ("still recommend merging") reads as accepting the residual risk, so this loop implements neither without an answer. No code change this round; the decision is not preempted.

Question for the maintainer: (A) revert to the full wipe, (B) keep-and-harden behind the preamble above, or (C) record a risk acceptance for the current design and merge as-is?

中文说明

处置:已升级至维护者决策——线程有意保持未解决,不单方面定夺。

已在被评审提交核实:HEAD 为 51777f43a2,三个 PR 文件的 git diff 4fd6a7aa..HEAD 为空——scrub 与本轮探针重新证明五个绕过所针对的代码逐字节一致,因此该发现依据代码同一性成立,本轮无需重新探测。

待定决策即 triage 延迟评论 5311584017(移交 @wensao)所记录者:(A) 恢复全量清理,或 (B) 仅在强化前置步骤后保留 .git(清扫前删除 commondir/shallow/config.worktree/config.lock 并取消 extensions.worktreeConfig;将 remote\. 收窄为 remote\..+\.(url|fetch|pushurl);从 core\. 分支移除 worktree;失败即报错的状态后审计),并加失败即关闭的完整性检查。两个方向均属有争议的范围选择——A 放弃本 PR 主旨,B 增加大量安全机制——且 triage 记录显示维护者 8 月 16 日立场("仍然建议合并")倾向于接受残余风险,故本循环在未获答复前不实施任一方向。本轮无代码改动;未抢占决策。

给维护者的问题:(A) 恢复全量清理,(B) 按上述前置步骤保留并加固,还是 (C) 书面记录对当前设计的风险接受并按现状合并?


- name: 'Checkout PR head'
uses: 'actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10' # v6.0.3
Expand Down
77 changes: 66 additions & 11 deletions scripts/tests/serve-ab-workflow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,52 @@
import { execFileSync, spawnSync } from 'node:child_process';
import {
chmodSync,
existsSync,
lstatSync,
mkdirSync,
mkdtempSync,
readdirSync,
readFileSync,
rmSync,
statSync,
symlinkSync,
writeFileSync,
} from 'node:fs';
import { tmpdir } from 'node:os';
import { basename, join } from 'node:path';
import { basename, dirname, join } from 'node:path';
import { describe, expect, it } from 'vitest';
import { parse } from 'yaml';

const workflow = readFileSync('.github/workflows/serve-ab.yml', 'utf8');

const job = parse(workflow).jobs['ab'];
const steps = job.steps;
const WIPE = 'Wipe stale workspace before checkout';
const WIPE = 'Wipe stale workspace except the shared .git before checkout';
const wipe = steps.find((s) => s.name === WIPE);

// Runs the real wipe script under the runner's shell flags: this job sets
// `defaults.run.shell: bash`, which GitHub Actions executes with
// `-eo pipefail`, so the exec tests must reproduce that instead of hiding
// it behind bare `bash -c`.
const runWipe = (env, options = {}) =>
execFileSync('bash', ['-e', '-o', 'pipefail', '-c', wipe.run], {
const runWipe = (env, options = {}) => {
// The kept-.git config scrub ends in `git config --local`, which reads
// the CWD's repo; pin it to the fixture so a completing wipe never
// scrubs the host checkout's local config. The heal fixtures hand over
// a workspace that is a file or a dangling symlink — no cwd to stand in —
// so pin the parent instead: a mkdtemp dir, never a repo.
let cwd = env.GITHUB_WORKSPACE;
try {
if (!statSync(cwd).isDirectory()) cwd = dirname(cwd);
} catch {
cwd = dirname(cwd);
}
return execFileSync('bash', ['-e', '-o', 'pipefail', '-c', wipe.run], {
encoding: 'utf8',
cwd,
env: { ...process.env, ...env },
...options,
});
};

// `realpath -m` (the script's canonicalization line) is a GNU coreutils
// extension. Probe the host before asserting GNU-specific path behavior.
Expand Down Expand Up @@ -91,11 +106,16 @@ describe('serve-ab pre-checkout workspace wipe', () => {
"refusing runner workspace path containing '..'",
);
expect(wipe.run).toContain('runner workspace resolved to /');
// Exit contract: the wipe stays bare on purpose — under the job's
// `-eo pipefail` a wipe that cannot clear the workspace fails the job
// here instead of building both checkouts on top of the leftovers.
// `|| true` would silently void that.
expect(wipe.run).not.toContain('|| true');
// Exit contract: the guard and the destructive lines stay bare on
// purpose — under the job's `-eo pipefail` a wipe that cannot clear the
// workspace fails the job here instead of building both checkouts on
// top of the leftovers. `|| true` may appear only on the kept-.git
// config scrub, mirroring qwen-triage.yml's config-sanitize.
const loosened = wipe.run
.split('\n')
.filter((line) => line.includes('|| true'));
expect(loosened).toHaveLength(1);
expect(loosened[0]).toContain('git config --local --name-only --list');
});

it('carries the symlink heal, ordered and bounded (#9480)', () => {
Expand Down Expand Up @@ -135,7 +155,7 @@ describe('serve-ab pre-checkout workspace wipe', () => {
});

it.skipIf(!hasGnuRealpath)(
'wipes a legitimate workspace inside the runner workspace',
'wipes a legitimate workspace but keeps and defangs the shared .git',
() => {
const parent = mkdtempSync(join(tmpdir(), 'serve-ab-wipe-ok-'));
const ws = join(parent, 'repo');
Expand All @@ -145,9 +165,44 @@ describe('serve-ab pre-checkout workspace wipe', () => {
mkdirSync(join(ws, 'base'), { recursive: true });
writeFileSync(join(ws, 'head', 'package.json'), '{}');
writeFileSync(join(ws, 'bundle.tgz'), 'x');
// A shared root .git shaped like the real one: objects are the reason
// it is kept; hooks, info/attributes, and non-allowlisted local
// config are the exec vectors that must not survive into the next
// job's checkout.
execFileSync('git', ['init', '--quiet', ws]);
mkdirSync(join(ws, '.git', 'objects', 'pack'), { recursive: true });
writeFileSync(join(ws, '.git', 'objects', 'pack', 'sentinel'), 'x');
writeFileSync(
join(ws, '.git', 'hooks', 'post-checkout'),
'#!/bin/sh\necho pwned\n',
);
writeFileSync(join(ws, '.git', 'info', 'attributes'), '* filter=x\n');
execFileSync('git', ['config', '--local', 'alias.pwned', '!echo pwned'], {
cwd: ws,
});
execFileSync('git', ['config', '--local', 'safe.directory', ws], {
cwd: ws,
});
try {
runWipe({ GITHUB_WORKSPACE: ws, RUNNER_WORKSPACE: parent });
expect(readdirSync(ws)).toEqual([]);
expect(readdirSync(ws)).toEqual(['.git']);
expect(
readFileSync(join(ws, '.git', 'objects', 'pack', 'sentinel'), 'utf8'),
).toBe('x');
expect(existsSync(join(ws, '.git', 'hooks'))).toBe(false);
expect(existsSync(join(ws, '.git', 'info', 'attributes'))).toBe(false);
expect(() =>
execFileSync('git', ['config', '--local', 'alias.pwned'], {
cwd: ws,
stdio: 'pipe',
}),
).toThrow();
expect(
execFileSync('git', ['config', '--local', 'safe.directory'], {
cwd: ws,
encoding: 'utf8',
}).trim(),
).toBe(ws);
// The directory itself survives: the checkouts clone into it next.
expect(wipe.run).toContain('-mindepth 1 -maxdepth 1');
} finally {
Expand Down
Loading