Repository navigation
feat(a8n-attached): host script 内で project identity を再検証する guard を追加 (#385) - #389
Merged
Merged
Conversation
rebuildup
marked this pull request as ready for review
November 20, 2026 20:59
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Issue #385。PR #379 CodeRabbit Major finding の follow-up。
a8n-attached lane の
targetGuard(revalidateTarget)は consent 承認直後・dispatch 直前に target identity を再証明するが、guard 通過から generated ExtendScript が host で評価されるまでの間に user が AE で project を切り替える TOCTOU 窓が残っていた。本 PR で consent-bound source の内側 に host-readable な project identity 検証を注入し、同一評価内で write 前に refuse する。設計
app.project.file.fsName。ae-a8n のproject.infoが返すfileはまさにこの文字列(host/a8n-host.jsのString(project.file.fsName))なので、session が attest した値をそのまま期待値に使える。未保存 project(file null)・identity 読み取り不能時は guard 値を持たない。scripting-adapters/execute.mjs:withHostProjectGuard(programSource, expectedFsName)— consent-bound program を(function(){ guard; return <op program> })()でラップ。guard は op body の前にapp.project.file.fsNameを期待値と比較し、不一致なら adapter failure shape({ok:false, error:{code:"PROJECT_IDENTITY_MISMATCH"}})を JSON 文字列で返す → outcome FAILED +adapterError.codeで構造化され、write は一切実行されない。ES3 のみ(var/typeof/三項)。hostProjectGuardRequired === trueかつ mutating op かつ guard 値なし → consent 前にPROJECT_GUARD_UNAVAILABLEで refuse(read op は影響なし)。toProgramSource直後・consent scope 計算より前 — guard literal は consent が approve する source の一部であり、実行される文字列と一致する。a8n-transport/attached-session.mjs: attest 済みproject.file(非空 string の時のみ)をhostProjectGuardとして公開、hostProjectGuardRequired: true。dev-loop/session-open.mjs: 3 session kind 全てでhostProjectGuard/hostProjectGuardRequiredをマップ(fake/a8n は null/false)。dev-loop/devloop.mjsverify(): 新フィールドを forwarding。devtools-cli/cli.mjs/mcp-server/tools.mjs: session の guard 値をrunOperation/verifyに転送。projectIdentityもhostProjectGuard ?? 従来の静的 labelに変更 — consent scope が実 project を名指すようになる(attached lane のみ実値、他 lane は不変)。適用範囲(正直な記載)
runOperation)を通る CLI / MCP / VSCode(controller→tools.mjs 経由)の a8n-attached session が対象。agent-loopは runner 直叩きの別 path で registry op を dispatch しないため対象外。hostProjectGuard: null— guard は注入されず従来動作(owned は使い捨て自前 AE で実害小、issue の検討事項どおり)。テスト(fake/mock レベル)
execute.test.mjs+4 tests:PROJECT_IDENTITY_MISMATCH、items.length === 0で write 未実行を確認hostProjectGuardRequired+ guard なし → mutating op は consent/dispatch 前にPROJECT_GUARD_UNAVAILABLErefuse、read op は COMPLETEDcheck-syntax 140 files、scripting-adapters 3/3、dev-loop 4/4、mcp-server、devtools-cli 53 tests、a8n-transport attached-session 25/25 — 全 green。
検証レベル
app.project.file.fsNameの形式は ae-a8n host script と同一ソース(String(project.file.fsName))だが、実機での pin 動作確認は今後の real-host run で要検証。