Problem
Tests/BestASRKitTests/CLITests.swift 的 subprocess 測試以路徑定位 bestasr-diagnostics-probe(經 Bundle(for:) 找 products directory),唯一的守門是:
try #require(FileManager.default.isExecutableFile(atPath: probe.path))
檢查的是存在,不是新鮮度,也不是身分。
Type
bug(測試基礎設施)
Evidence(round-4 verify 實測)
(a) 正常流程不會 stale。 只改 BestASRKit 後跑 swift build --build-tests:
probe sha before=293b409815e28d51 after=6740a6b931ff78bf changed=YES
SwiftPM 會因 test target 對 probe 的依賴而重連結。
(b) 但沒有任何偵測。 完整建置後把 err: 預設改成 stdout,再跑 swift test --skip-build:
GREEN 466/466
probe binary mtime 比它應當驗證的原始碼早 206 秒
(c) 偽造能撐過完整 swift test。 把 .build/debug/bestasr-diagnostics-probe 換成一支只印期望字串到期望 fd 的 #!/bin/sh 腳本:
Build complete! (2.48s)
Test run with 2 tests in 1 suite passed
.build/debug/bestasr-diagnostics-probe: POSIX shell script text executable
forge SURVIVED a full swift test
SwiftPM 只追蹤自己的 build record,不比對輸出檔內容。測試驗的是磁碟上的 artifact,不是程式碼。
為什麼現在開
Round 4 標為 LOW 並判給「separate issue」,然後沒開。1afa2ee(seam)之後這個 artifact 承載的責任大幅增加:它從「執行 report 的預設值」變成「執行整個 transcribe 指令」,是六個測試唯一的 subject。在此之前所有覆蓋都在行程內——bundle 陳舊是整體性的、比較容易察覺;現在斷言與被斷言的產物分屬兩個 artifact。
曝險(誠實範圍)
窄。正常 swift test 會重建(實測 (a)),偽造需要 out-of-band 動作,而能寫進 .build/ 的人本來就能執行任意程式碼——沒有新增攻擊面。真正的風險是 --skip-build 與任何快取 products 的流程下靜默驗證舊行為。
可能的方向(未定案)
- 讓 probe 有一個
--build-id 模式,回報一個由 library 端常數推導的值,測試比對——把「是不是同一份程式碼」變成可斷言的。
- 或最低限度:比對 probe 與 test bundle 的 mtime,舊的就 fail loud。
後者三行,擋掉 (b);擋不掉 (c),但 (c) 的 attacker model 本來就不成立。
發現於 PR #141 round-4 verify(logic + requirements lens);責任於 round-5 seam 後擴大。相關:#136。
Problem
Tests/BestASRKitTests/CLITests.swift的 subprocess 測試以路徑定位bestasr-diagnostics-probe(經Bundle(for:)找 products directory),唯一的守門是:檢查的是存在,不是新鮮度,也不是身分。
Type
bug(測試基礎設施)
Evidence(round-4 verify 實測)
(a) 正常流程不會 stale。 只改
BestASRKit後跑swift build --build-tests:SwiftPM 會因 test target 對 probe 的依賴而重連結。
(b) 但沒有任何偵測。 完整建置後把
err:預設改成stdout,再跑swift test --skip-build:(c) 偽造能撐過完整
swift test。 把.build/debug/bestasr-diagnostics-probe換成一支只印期望字串到期望 fd 的#!/bin/sh腳本:SwiftPM 只追蹤自己的 build record,不比對輸出檔內容。測試驗的是磁碟上的 artifact,不是程式碼。
為什麼現在開
Round 4 標為 LOW 並判給「separate issue」,然後沒開。
1afa2ee(seam)之後這個 artifact 承載的責任大幅增加:它從「執行report的預設值」變成「執行整個transcribe指令」,是六個測試唯一的 subject。在此之前所有覆蓋都在行程內——bundle 陳舊是整體性的、比較容易察覺;現在斷言與被斷言的產物分屬兩個 artifact。曝險(誠實範圍)
窄。正常
swift test會重建(實測 (a)),偽造需要 out-of-band 動作,而能寫進.build/的人本來就能執行任意程式碼——沒有新增攻擊面。真正的風險是--skip-build與任何快取 products 的流程下靜默驗證舊行為。可能的方向(未定案)
--build-id模式,回報一個由 library 端常數推導的值,測試比對——把「是不是同一份程式碼」變成可斷言的。後者三行,擋掉 (b);擋不掉 (c),但 (c) 的 attacker model 本來就不成立。
發現於 PR #141 round-4 verify(logic + requirements lens);責任於 round-5 seam 後擴大。相關:#136。