本卡屬 FR-187(母卡 CM-3711),第 1 批 J1:長輪詢通道(套件端)(套件 repo
jedi-python-package(jedi-remote-agent),7 檔/約 1173 行)。只掃不修。工作坊會用.claude/workshop-prompts/dispatch-<本卡號>.md當開場 prompt 直接啟動掃描,小弟不必自己打指令。
用 Claude Code 官方 claude-security plugin 掃「長輪詢通道(套件端)」這一塊,找出資安問題,寫成 PM 與新手工程師都看得懂的報告。只找問題、不修問題,修是另外開卡的事。
掃 jedi-remote-agent 套件裡長輪詢的另一頭:Agent 打進來的三支端點(拿指令 GET /agents/commands、回答 POST /agents/replies/<id>、拿暫存檔 GET /agents/files/<id>),以及每個請求都要過的「持有證明」檢查(確認來的真的是那台 Agent,不是拿到通行證複本的人)。
這是 Agent 進主系統的正門。證明檢查有洞,偷到一張通行證就能冒充那台 Agent 拿工單(工單裡可能有受檢主機的明文帳密);端點沒限量,一台 Agent 就能把主系統的連線吊滿。主系統那一頭在 A1。
背景:這一輪掃的是 2026-11-01(FR-172 開案)到 11-09 之間主專案與 jedi-remote-agent 新寫或大改的程式(FR-171/172/178/179/180/181/182),這些程式都沒掃過。
jedi-remote-agent/jedi_remote_agent/api/routes/agent_commands_route.py
jedi-remote-agent/jedi_remote_agent/app/service/agent_command_channel_service.py
jedi-remote-agent/jedi_remote_agent/app/ports/command_channel.py
jedi-remote-agent/jedi_remote_agent/common/agent_auth/possession.py
jedi-remote-agent/jedi_remote_agent/app/service/agent_ticket_service.py
jedi-remote-agent/jedi_remote_agent/plugin/assembly.py
jedi-remote-agent/jedi_remote_agent/api/routing.py
檔數 7、約 1173 行。驗檔數:git -C <工作目錄> ls-files -- jedi-remote-agent/jedi_remote_agent/api/routes/agent_commands_route.py jedi-remote-agent/jedi_remote_agent/app/service/agent_command_channel_service.py jedi-remote-agent/jedi_remote_agent/app/ports/command_channel.py jedi-remote-agent/jedi_remote_agent/common/agent_auth/possession.py jedi-remote-agent/jedi_remote_agent/app/service/agent_ticket_service.py jedi-remote-agent/jedi_remote_agent/plugin/assembly.py jedi-remote-agent/jedi_remote_agent/api/routing.py | wc -l 應為 7。scope 外的檔不要讀,除非下面「重點看什麼」明寫「只追這幾行」;越界的發現首腦驗收時會挑掉。
首腦讀過程式碼後認為最容易出事的地方,是思考起點不是檢查清單,行號以 2026-11-09 的主線為準,對不上就以內容為準。工具不會照這份走,掃完後你要自己逐條對一遍:工具沒報的,開檔看一眼,寫「人工查過:成立/不成立/為什麼」。
agent_commands_route.py:38-42 的 wait 上限 30 秒;preempt 只踢同一台的舊連線。不同 Agent、或同一張通行證開很多條,能不能把主系統的執行緒吊滿(主系統這次改成 gthread、每個 worker 16 條執行緒)。agent_command_channel_service.py:155-176 accept_reply 寫「先核歸屬再落檔」,但 multipart 檔在 route 的 _reply_body()(agent_commands_route.py:76-84)解析時 Werkzeug 就已經整份收下來了;上傳大小上限在哪一層。possession.py:133-142 htu 只比對路徑結尾(為了反向代理加前綴):A 端點簽的證明能不能拿去打另一支路徑結尾相同的端點;iat 容許差多大;jti 防重放記在哪裡,那個儲存掛掉時是放行還是擋。possession.py:155-200 的檢查順序:憑證屬於這台 → 簽章 → htm/htu/iat/ath → jti。確認 x5c 帶的憑證有被要求是主系統 CA 簽、且 CN 等於這台的指紋。_assert_owned(:187-195)與 load_callable_agent:pending(還沒核准)或停用的 Agent 能不能拿指令、回答、拿檔。plugin/assembly.py、api/routing.py:新掛的端點有沒有每一支都套 agent_pass_required+持有證明,有沒有漏掛的。_task_commands(:142-151)交出的工單 payload 可能含明文帳密(檔頭第 10 行寫了):主系統的 api 日誌中介層(common/middleware/app_mw.py)會不會把這個回應原樣記下來。agent_ticket_service.py:Agent 主控台票證的有效期、綁哪一台、能不能重複使用。