This repository was archived by the owner on Oct 26, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 26, 2026. It is now read-only.
Security audit: dependency ReDoS, OAuth XSS/cmd injection, unbounded memory, and more #225
Copy link
Copy link
Closed
Labels
area:coreCore runtime and session stateCore runtime and session statearea:securityApproval, sandbox, and security policyApproval, sandbox, and security policyarea:toolsBuilt-in tools and tool runtimeBuilt-in tools and tool runtimearea:tuiTerminal UI and interaction layerTerminal UI and interaction layerneeds-triageIssue needs initial triageIssue needs initial triage
Description
Security audit of the repo on branch refactor/ai-sdk (current working tree). This is a local CLI agent tool, so the main threat model is: prompt-injected models abusing tools / malicious MCP servers / malicious web content. No remotely-exploitable criticals found. Findings ordered by severity.
High
H1. minimatch@10.2.0 ReDoS (model-controlled input)
packages/core/package.json(minimatch: ^10.0.1); used atpackages/core/src/tools/tools/filesystem/lib.ts:336,lib.ts:340(search_filestool)- GHSA-3ppc-4f35-3m26 / GHSA-7r86-cg39-jmmj / GHSA-23c5-xmqv-rm74 — fixed in 10.2.3
search_filespattern/excludePatternsare model-controlled and passed straight tominimatch(relativePath, pattern). Patterns like**/**/**/xor nested extglobs can trigger exponential backtracking and hang the agent process (local DoS).- Fix: upgrade
minimatchto>=10.2.3; consider limiting pattern length/complexity (e.g. reject >3**).
H2. Transitive ReDoS: brace-expansion / picomatch
pnpm-lock.yaml:minimatch@10.2.0 > brace-expansion@5.0.2(GHSA-f886-m6hf-6m8v, GHSA-3qgp-pqcv-9wcr; fixed in 5.0.8);fast-glob@3.3.3 > micromatch@4.0.8 > picomatch@2.3.1(GHSA-c2c7-rcm5-vvqj; fixed in 2.3.2)- brace-expansion triggers via minimatch
{a{0..N}}patterns (same model-controlled surface as H1). picomatch only used with static**/SKILL.mdpatterns inskills.ts:307— not directly model-triggerable. - Fix: upgrading minimatch to 10.2.3 pulls brace-expansion fix; upgrade fast-glob/micromatch for picomatch.
H3. undici outdated (11 paths, multiple high advisories)
- Direct dep
undici@6.23.0(packages/core/package.json, used for webfetchProxyAgent); transitive@ai-sdk/provider-utils > undici@5.29.0(11 paths) andjsdom > undici@7.22.0 - Advisories: WebSocket / HTTP smuggling / CRLF injection. Reachability is low (webfetch uses native
globalThis.fetch; undici only forProxyAgentatwebfetch.ts:312), but CRLF/smuggling becomes reachable when proxying remote MCP servers. - Fix: direct
undici→>=6.27.0; track@ai-sdk/provider-utilsandjsdomupgrades.
Medium
M1. Reflected XSS in OAuth callback page (localhost)
packages/core/src/tools/router/mcp/oauth.ts:634—error_description/errorfrom the OAuth server is concatenated into HTML without escaping (res.end('<html>...<p>' + message + '</p>...'))- A malicious MCP server can put
<script>in the callback URL; when the user opens127.0.0.1:<port>/callback, the script runs on the localhost origin and can hit other local ports / read same-origin storage. - Fix: HTML-escape
message, or respond withtext/plain.
M2. Command injection on Windows: cmd /c start for OAuth URL
packages/core/src/tools/router/mcp/oauth.ts:274(win32 branch{ command: 'cmd', args: ['/c', 'start', '', url] })- The authorization URL comes from the MCP server's OAuth discovery endpoint (attacker-controlled).
cmd.exe /cparses the whole command line — URL metacharacters (&,|,") can act as command separators; a"in the URL breaks spawn's quoting → arbitrary command execution. (macOS/Linux argv passing is safe.) - Fix: use
rundll32 url.dll,FileProtocolHandlerwith quote validation, or PowerShellStart-Process; reject URLs containing"/|/&.
M3. Unbounded exec session output accumulation (memory DoS)
packages/core/src/tools/tools/exec_runtime.ts:278(session.output += ...); sessions capped at 64 (lines 20, 151) but each session'soutputis never freedexec_commandhas no defaultexecution_timeout_ms(onlyshell_commandsets one).yesorcat /dev/urandom | base64can exhaust memory;write_stdinkeeps appending.- Fix: hard cap output (e.g. 16MB) and kill on exceed; free
outputfor completed sessions; default timeout forexec_command.
M4. No file size limit on reads
packages/core/src/tools/tools/filesystem/lib.ts:130(fs.readFilefull read),lib.ts:158(applyFileEdits);read_media_file.ts:47(full base64 read)- Truncation (
sdk_tools.ts:63guardToolResultOutput, 20k chars) happens only after the whole file is in memory. Large files in the workspace → memory DoS. - Fix:
stat-based size cap (e.g. 50MB) or streaming truncation; same forread_media_file.
M5. webfetch SSRF: DNS rebinding TOCTOU (known limitation)
packages/core/src/tools/tools/webfetch.ts:138(assertPublicHostresolves DNS once, then fetch)- Domain can re-resolve to internal IP between check and request;
MEMO_WEBFETCH_BLOCK_PRIVATE_NET=0disables the whole guard (webfetch.ts:99). Redirect hops are re-checked (webfetch.ts:204). Baseline protection is solid; this is a known residual gap. - Fix (optional): re-validate IP at the connection layer / pin the resolved IP.
Low
- L1. Session files default permissions too wide —
packages/core/src/features/history/history_sink.ts:27:appendFilewithout mode → 0o644;~/.memo/sessions/*.jsonlcontains full conversations/tool args/command output (may include secrets). OAuth creds use 0o600 (oauth.ts:196). Fix:{ mode: 0o600 }. - L2. exec env/workdir unbounded —
exec_runtime.ts:259passes fullprocess.env(API keys, cloud creds) to children;exec_runtime.ts:245allows../escapes from workspace. Inconsistent with the sandboxed read/write tools; document, or validate allowed roots / filter env. - L3.
memo initapproval whitelist bypass via*** Move to:—packages/tui/src/shared/lib/initApproval.ts:4only matches*** Add/Update File:; a prompt-injected model can*** Update File:+*** Move to:another path inside the workspace. Fix: parse and validateMove totargets. - L4. Dangerous-command guard is a bypassable blacklist —
packages/core/src/tools/tools/command_guard.tscovers only a small set (rm -rfkey paths, mkfs/dd, ...).find / -delete, fork bombs,tar --to-command, nestedsudo bash -c '...'all bypass it. It's a speed bump, not a security boundary — document that the approval gate is the real boundary. - L5. Misc — TOML section names unescaped in
config.ts:201/175(self-harm only);get_memory(get_memory.ts:22) always returns the entire~/.memo/Agents.mdto any agent regardless ofmemory_id(sensitive context leak surface);new Function('specifier', ...)in oauth.ts:152 (hardcoded'keytar', cosmetic);sandbox_permissions: 'require_escalated'is a no-op (exec_command.ts:31 / exec_runtime.ts don't consume it).
Verified safe
spawn(file, args, { shell: false })— no shell injection; argv quoting correct inshell.ts:21-27- FS sandbox:
realpathsymlink checks (filesystem/lib.ts:97),canonicalWritePath(apply_patch.ts:565), atomic writes withwx - webfetch SSRF baseline: private/loopback/link-local blocked by default, per-hop redirect validation, robots.txt, body size caps
- No eval/dynamic exec (except hardcoded keytar import), no unsafe deserialization, no TLS disabled, no install-script hooks in lockfile
crypto.randomUUIDfor session/agent ids;site/is a static export, no server code
Suggested priority
pnpm update minimatch(≥10.2.3) — fixes H1+H2, the only model-input-triggerable high- Fix M1 (one-line HTML escape) + M2 (Windows URL handling)
- Fix M3/M4 (memory caps)
- Upgrade undici (H3); tighten L1 file permissions
(This issue was generated from a subagent security audit — details may be worth verifying against the current tree before fixing.)
Metadata
Metadata
Assignees
Labels
area:coreCore runtime and session stateCore runtime and session statearea:securityApproval, sandbox, and security policyApproval, sandbox, and security policyarea:toolsBuilt-in tools and tool runtimeBuilt-in tools and tool runtimearea:tuiTerminal UI and interaction layerTerminal UI and interaction layerneeds-triageIssue needs initial triageIssue needs initial triage
Activity
minorcell commentedon Aug 2, 2026
All findings fixed in 97fefac on branch refactor/ai-sdk, open as PR #226. Deps upgraded (minimatch 10.2.6, brace-expansion 5.0.9, picomatch 2.3.2, undici 6.28.0); OAuth callback XSS and Windows cmd injection fixed; exec output capped at 16 MiB with kill; file/media reads capped at 50/10 MiB; session files now 0o600. M5 (DNS rebinding) left as a documented known limitation.