Skip to content

v0.2.5 — P0 Safety Fixes: Git Sandbox, Installer Protection & apply_edits Rollback

Choose a tag to compare

@INK-Q INK-Q released this 21 Nov 05:02
· 27 commits to main since this release

Security & Safety Release (v0.2.5)

Fixes three P0 safety and data-integrity issues (#5, thanks @ErrantSnow):

Fixed

  • Read-only git branch / git tag sandbox bypass (src/tools/batch-search.ts, src/benchmark-core.ts):
    • Separated Git optional-value flags (--merged, --no-merged, --abbrev, --color, --column) from value-consuming flags so they accept =-attached values without setting expectValue = true to skip validation on the next space-separated token (blocking bypasses like branch --color -D --column target, branch --color -m main hacked, branch --abbrev new-branch, and tag --color -d --column v0.2.2).
    • Removed --abbrev, --color, and --column from GIT_BRANCH_VALUE_FLAGS in src/benchmark-core.ts.
  • Installer source-repo protection & --target ownership verification (scripts/install.mjs):
    • Resolves fs.realpath with case folding on win32/darwin to prevent same-repo deletion across symlinked paths or case variants.
    • Refuses deleting REPO_ROOT or any strict ancestor directory of REPO_ROOT.
    • Requires non-empty, non-symlink target directories to contain plugin.json with "name": "agy-fast" before deletion, and unlinks symlinks/junctions (including broken links) directly without touching link targets.
  • apply_edits Phase-2 fallback truncation & create rollback safety (src/tools/apply-edits.ts):
    • Isolates temp-file writeFile/chmod failures (cleans up the temp file and rethrows without falling back to O_TRUNC direct writes on the target).
    • Records the file in written before the rename-fallback direct write so any mid-write failure rolls back the target's original content/permissions or removes a newly created file.
    • Treats only ENOENT as missing in Phase-1 create, failing fast on EACCES/EBUSY/ENOTDIR instead of misclassifying an existing file as non-existent.

简体中文更新摘要(v0.2.5)

安全与数据完整性加固版本,修复三项 P0 级安全与防误删漏洞(#5,感谢 @ErrantSnow):

  • 封堵只读 git branch / git tag 沙箱绕过:将 Git 可选值参数(--merged、--no-merged、--abbrev、--color、--column)拆离消费下个参数的白名单,彻底拦截 branch --color -D --column target、branch --color -m ...、tag --color -d ... 等绕过,并同步修正 benchmark-core.ts。
  • 安装器防误删源仓库与 --target 归属校验:通过 fs.realpath + win32/darwin 大小写归一化避免软链/大小写变体误删源仓库;拦截对源仓库及任意祖先目录的删除;删除非空非软链目录前强校验 plugin.json 的 name === "agy-fast";软链/Windows junction/死链直接 fs.unlink 不触碰目标目录。
  • 修复 apply_edits 写盘截断与 create 回滚误删:将临时文件写入/chmod 失败与 rename 隔离,不再触发回退直写截断原文件;真正 rename 失败走回退直写前先加入回滚队列;Phase-1 create 仅将 ENOENT 视为文件不存在,遇到 EACCES/EBUSY 等错误直接快速失败,避免回滚误删已有文件。

Full Changelog: v0.2.4...v0.2.5