Harden plugin runtime: TLS verify, LSP deadlock, path traversal, ABI exception safety (W14)
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:
@@ -38,4 +38,23 @@ current_groups: []
|
||||
核心发现:7 个 C ABI 入口均无 try/catch,畸形 tools_json → json::parse 异常 → std::terminate()。
|
||||
跨 DLL 堆/字符串生命周期 A 级合规;与 anthropic ~55% 重复,~230 行可抽取为 ai_plugin_base。
|
||||
综合评级 C+。报告写入 agents/audits/W13.2-deepseek-audit.md。
|
||||
- date: 2026-05-27
|
||||
event: "W14.2: 修复 lsp_plugin.cpp 致命死锁 (W13.4 审计发现) + vtable 异常包装"
|
||||
rating: completed
|
||||
details: |
|
||||
死锁修复 (Option C — 拆分 stop_locked/stop 双版本):
|
||||
- 原问题: g_lsp_impl_start L534 持 g_lsp.mutex (非递归) 调用 g_lsp_impl_stop, 后者 L570 再次 unique_lock 同 mutex → 自死锁。
|
||||
- 修复: 拆分 g_lsp_impl_stop_nolock() (无锁体) + g_lsp_impl_stop() (公开接口) + g_lsp_impl_stop_locked(lock) (持锁调用者先 unlock 再 delegate _nolock)。
|
||||
- timeout 路径 L541 改为 g_lsp_impl_stop_locked(lock) — 明确 invariant: lock 在调用点释放, _nolock 内部自行加锁。
|
||||
|
||||
异常安全包装 (try/catch 双层, 符合 plugin-abi.md §8):
|
||||
- 7 个 service vtable: start / stop / open_document / close_document / get_diagnostics / get_hover / get_completion
|
||||
- reader_loop: while 循环体入 try, 异常后仍设 running=false + notify_all 防 waiter 永久阻塞
|
||||
- handle_message: 全函数体入 try
|
||||
- on_shutdown: 全函数体入 try, 异常后仍置 g_host=nullptr
|
||||
- int 返回函数: catch → -1; char** 返回函数: catch → *json_out=nullptr, return -1; void 函数: catch → 仅 log。
|
||||
|
||||
构建验证: cmake --build Release 0 error; ctest 4/4 pass。
|
||||
L420-471 reader_loop, L481-559 start, L561-603 stop 三件套, L605-630 open, L632-655 close,
|
||||
L657-683 diagnostics, L685-730 hover, L730-780 completion, L807-821 on_shutdown.
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user