T05 · Unauthorized Access and Privilege Escalation
- Location
index.js:8- Finding
Unconditional Recommendation of the Privileged Shell Execution Tool
- Content
View full analysis
Vulnerability Details
File Location:
index.js:8-10
Vulnerability Type: Least-privilege violation through unconditional shell-tool exposure
Risk Level: MediumVulnerable Code
js function selectToolNamesFromText(userText, maxTools = 8) { const t = (userText || "").toLowerCase(); const selected = new Set(); selected.add("exec"); if (/天气|温度|华氏|摄氏|weather|wttr|temperature|temp\s*[\(\(]/.test(t) || /^\s*\d+\s*[度°]\s*/.test(t)) selected.add("exec");The
exectool is added to every recommendation before the user's intent is evaluated. Therefore, messages that do not require command execution—including document, search, file, and unmatched requests—still receive a recommendation for a general-purpose shell tool.The subsequent weather-specific condition does not restrict this capability because
exechas already been added. Although this skill only returns recommendations and does not itself run commands, a gateway that uses the returned list to expose or authorize tools would unnecessarily grant the agent access to command execution.Technical Analysis
This behavior violates least privilege. A dynamic tool policy should expose privileged tools only when the current task has a validated need for them. General-purpose shell execution has a substantially broader security boundary than the intent categories this skill handles: it may permit process execution, filesystem access, outbound network requests, and interaction with credentials available to the hosting process.
The risk is amplified for unmatched input. Because
execremains the only recommendation,getHint()can return the following shell-oriented instruction fromindex.js:28:js if (tools.includes("exec") && tools.length <= 2) return "Weather or shell; use exec with wttr.in for weather.";This may encourage shell use even when the input did not match weather or another command-dependent intent. Exploita ...[truncated 1469 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the unconditional
selected.add("exec"). - Add
execonly after a narrowly defined intent requiring command execution has been positively identified. - For weather requests, prefer a constrained weather or HTTP API tool over a general-purpose shell.
- Return an empty or non-privileged recommendation set for unmatched input.
- Change the hint logic so it distinguishes a confirmed weather intent from the mere presence of
exec. - Treat recommendations as advisory rather than authorization. Enforce an independent server-side allowlist and per-tool policy at the gateway.
- If shell execution is unavoidable, run it in a sandbox with minimal filesystem permissions, a restricted environment, network controls, command allowlisting, timeouts, and resource limits.
- Add tests confirming that unrelated, empty, document-only, and search-only messages do not receive
exec.
- Remove the unconditional
