Harden plugin runtime: TLS verify, LSP deadlock, path traversal, ABI exception safety (W14)
Some checks failed
CI / Determine matrix (push) Has been cancelled
CI / ${{ matrix.os }} / ${{ matrix.build_type }} (push) Has been cancelled

W14 addresses the five most critical findings from the W13 plugin audits:

- W14.1 network: enable ssl::verify_peer + SSL_set1_host SNI hostname
  verification (fixes TLS bypass, W13.3 CVSS 7.4); add steady_timer DNS
  timeout and bottom-up catch(...) hardening (engineer-zhou)
- W14.2 lsp: fix reader_loop/stop mutex deadlock via stop_nolock/stop_locked
  split (W13.4); wrap 11 vtable/entry functions in try/catch with cv
  notification on reader exit (engineer-sun)
- W14.3 tools: add is_safe_path() rejecting empty/absolute/.. paths before
  file_io calls (fixes path traversal, W13.5 CVSS 7.5); guard g_tools and
  g_session/g_history under mutex; 9 vtable try/catch (security-cao)
- W14.4 host: add fallback plugin search (../plugins/) so binaries run from
  build/tests/ load current DLLs, resolving the W13.6 R2 stale-DLL false
  alarm (architect-lin)
- W14.5 anthropic+deepseek: wrap 12 ABI boundary functions in try/catch with
  log-guard, preventing exceptions from crossing the C ABI (engineer-chen)

Verified: cmake build 0 error 0 warning, ctest 4/4 pass, smoke R2 now
passes naturally.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 12:03:50 +08:00
parent 47082376ef
commit 102cd3e141
12 changed files with 1230 additions and 702 deletions

View File

@@ -50,5 +50,18 @@ performance_log:
命令注入: 未发现。路径遍历: tools 确认。
评级 session:D+ / tools:D。
报告: agents/audits/W13.5-session-tools-audit.md
- date: 2026-05-27
event: "W14.3: 修复 W13.5 审计发现 — 路径遍历 + 全局状态加锁 + 9 vtable try/catch"
rating: done
detail: |
修改 session_plugin.cpp (294行) + tools_plugin.cpp (292行)。
(1) is_safe_path() 拒绝空路径、绝对路径(/或盘符)、含..段lexically_normal二次校验
builtin_file_read(L50) 和 builtin_file_write(L85) 入口调用不安全→log ERROR + 返回错误JSON。
(2) 加锁: session g_history/g_cached_history→g_session_mutex; tools g_tools→g_tools_mutex;
g_host/g_file_io→std::atomic<T*> load(acquire)/store(release)。
(3) 9 vtable try/catch 覆盖: session_add/save/load/history (session) +
tools_register_tool/unregister_tool/get_tools_json/execute/on_init (tools)。
编译: cmake --build build --config Release → 0 error 0 warning。
ctest -C Release → 4/4 pass。
current_groups: []
---