前言¶
DSH 本地環境會承載 API Key、token、會話內容和插件加載邊界。服務監聽公網、憑據文件權限過寬、插件來源不可信、會話文件結構異常等誤配置,都可能帶來真實風險。
現有工具各有側重:plugin-check 只做結構/合規檢查,不評估憑據暴露面、危險能力和路徑逃逸;session-health 只做健康診斷,不涉及來源可信度與安全風險裁定;手工逐項排查則容易遺漏,且難以留檔復現。
下面介紹社區插件 omdsh-dev/dsh-security-audit:以只讀方式審計本機 DSH 環境,輸出脫敏、可復現、可定位的風險報告。它不自動修復、不連接遠程、不執行被審計插件,也不把「沒讀到」當作「安全」。
這是什麼¶
dsh-security-audit 是 DSH 本機安全審計插件,由維護者 omdsh-dev 發佈,分類爲 admin-security。npm 包名爲 @deepseek-ai/dsh-security-audit,row id 爲 security-audit,許可證 MIT。
插件註冊 security_audit 工具,統一輸出 JSON 文本字符串。掃描範圍覆蓋:
- DSH 配置、profile、env/credentials 元數據
- 已安裝插件來源與危險靜態能力
- 會話目錄權限與文件結構
- 監聽配置與網絡暴露面
所有 action 輸出均帶 { tool, version, root, platform, ... } 信封;掃描類 action 附帶 verdict/riskVerdict/coverageVerdict 與 summary。
核心功能¶
安全模型¶
審計器自身有明確邊界:
- 只讀:不修改或刪除任何文件,不執行被審計插件代碼,不主動連接遠程目標
- 祕密脫敏:疑似祕密只返回類型、長度、進程內隨機 HMAC fingerprint、路徑、行號;完整值不出現在 canonical 輸出
- 路徑圍欄:路徑經 lstat → realpath → containment 檢查;
root固定爲進程啓動時解析的$DSH_HOME(或管理員聲明的 allowedRoot),參數不能擴大讀取範圍 - 誠實判定:finding / pass /
skipped/error四態;skipped與error不計爲 pass,coverage 降爲incomplete;capability finding只提示人工確認,不裁定惡意 - 預算限制:文件 ≤ 200、插件 ≤ 200、會話 ≤ 1,000、findings ≤ 1,000;單 action 10s / report 30s
六個 action¶
| action | 作用 |
|---|---|
scan_config |
審計 DSH 配置、profile、env/credentials 元數據(祕密存在性、權限、外部端點) |
scan_plugins |
檢查已安裝插件來源、路徑、patch、危險靜態能力、install script、祕密文件 |
scan_sessions |
檢查會話目錄權限、symlink 逃逸、zstd 幀結構(解壓炸彈預算內) |
scan_network |
解析監聽配置、URL 分類、明文 HTTP、代理路由(不主動聯網) |
report |
彙總四類掃描,輸出 riskVerdict + coverageVerdict 雙維度 |
rules |
列出規則目錄與適用平臺 |
常用參數:
| 參數 | 說明 |
|---|---|
action |
必填:scan_config / scan_plugins / scan_sessions / scan_network / report / rules |
root |
root 覆蓋;必須等於 $DSH_HOME 或管理員聲明的 allowedRoot |
profile |
限定單個 profile(^[A-Za-z0-9._-]{1,64}$,不接受路徑) |
strict |
strict 模式:medium finding 也判 fail,默認 false |
detail |
詳細輸出,默認 true;敏感證據始終脫敏 |
includeSourceScan |
啓用插件靜態源碼能力掃描(更慢、更多誤報),默認 false |
輸出示例¶
report 動作的典型輸出如下。注意 fingerprint 與 redacted:true 是脫敏協議字段,不是截斷提示:
{"tool":"security_audit","version":1,"root":"$DSH_HOME","platform":"win32","strict":false,
"verdict":"fail","riskVerdict":"fail","coverageVerdict":"complete",
"summary":{"critical":0,"high":1,"medium":0,"low":0},
"findings":[{"code":"secret-in-settings","severity":"high","state":"finding",
"evidence":{"path":"$DSH_HOME/.env","line":13,"secretKind":"api-key","secretLength":35,
"fingerprint":"b99e1887d861d7be","redacted":true}}],
"truncated":false}
安裝與啓用¶
本插件已在 DSH 0.1.0-rc.8(npm)下完成全鏈路驗證。DSH 0.1.0-rc.8 下,插件通過 dsh plugin --profile <profile> add <source> 安裝,source 支持 GitHub 倉庫或 npm pack tarball。
從 GitHub 安裝(推薦)¶
交互式 web profile 與一次性 headless profile 需分別安裝:
# 交互式(web)profile
dsh plugin --profile web add github:omdsh-dev/dsh-security-audit
# 一次性任務(headless)profile —— dsh run 默認使用 headless
dsh plugin --profile headless add github:omdsh-dev/dsh-security-audit
從 npm pack tarball 安裝¶
npm pack 產物可直接作爲 source 安裝:
dsh plugin --profile web add dsh-security-audit-*.tgz
包內 dsh.bundle.patch 會在安裝後自動把插件加入 profile 的 layer stack(row id:security-audit)。插件缺失的 peer 依賴(@deepseek-ai/cordis、@deepseek-ai/dsh-tools、@deepseek-ai/dsh-invariants)由 profile 的 healed profiles/node_modules 回退安裝提供。
web 與 headless 是不同 profile:web 安裝不會自動覆蓋 headless;
dsh run默認使用 headless profile。Windows 路徑使用正斜槓(C:/...)。
驗證安裝¶
dsh --profile web --dump-config | grep security-audit
典型用法¶
安裝完成後,可用自然語言讓 DSH 調用審計工具:
dsh run "運行 security_audit 的 report 動作,檢查本機 DSH 環境安全風險"
也可按需分步執行各 action,例如先 scan_config 檢查配置與憑據元數據,再 scan_plugins 覈對插件來源,最後用 report 彙總。需要更嚴格判定時,傳入 strict: true;需要檢查插件源碼靜態能力時,開啓 includeSourceScan(更慢、誤報更多)。
工具參數會記入會話日誌,調用時不要傳入敏感數據。
適用場景與注意¶
適合誰
- 在本地 DSH 環境存放 API Key、token 的開發者,需要定期自查配置與憑據暴露面
- 安裝多個社區插件後,想覈對來源可信度與危險靜態能力
- 需要可復現、可留檔的安全檢查記錄,替代分散的手工排查
使用前注意
- 插件以當前
dsh進程權限運行,能讀到的範圍取決於本機權限與$DSH_HOME佈局 - 安裝前應檢查源碼與 MIT 許可證:https://github.com/omdsh-dev/dsh-security-audit
capability finding僅提示人工確認,不裁定惡意;scan_network的狀態爲配置級推斷,listener 實際狀態可能標註爲unknown-listener-state- 本插件不自動修復問題,發現風險後需人工處理
DSH 生態遵循「一切皆插件」理念;社區目錄 SkillHub 是獨立站點,與 DeepSeek / 幻方無官方從屬關係。
鏈接¶
- 目錄頁:https://www.skillhub.cn/plugins/omdsh-dev/dsh-security-audit
- GitHub:https://github.com/omdsh-dev/dsh-security-audit
經過上面的步驟,你可以在不動本機文件的前提下,對 DSH 配置、插件、會話與網絡暴露面做一次系統性只讀審計,拿到脫敏且可定位的風險報告。