mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 14:16:34 +09:00
terminal_create accepted a Record<string,string> of env vars and merged it
straight into execSync's process env for every subsequent command in the
session. A caller that controls MCP input could set LD_PRELOAD,
DYLD_INSERT_LIBRARIES, or NODE_OPTIONS=--require ./evil.js — functionally
RCE on the host running the MCP server.
Added validateEnv() in validate-input.ts:
- names must match /^[A-Za-z_][A-Za-z0-9_]{0,127}$/ (POSIX shape)
- rejects LD_PRELOAD, LD_LIBRARY_PATH, LD_AUDIT, DYLD_INSERT_LIBRARIES,
DYLD_LIBRARY_PATH, DYLD_FALLBACK_LIBRARY_PATH, DYLD_FORCE_FLAT_NAMESPACE,
NODE_OPTIONS, NODE_PATH (loader/runtime hijack vectors)
- values must be string, no null bytes, ≤32K
- undefined/null env yields {} (preserves existing API)
Wired through terminal_create. Replaced unchecked cast with sanitized output.
Verified via tsx fixture: 11 cases — empty/undefined/valid pass, all three
loader-hijack vectors rejected, bad names (= in key, digit-first) rejected,
non-object/non-string-value/null-byte rejected.
Closes audit_1776853149979 finding "missing input validation on session.update/
memory.set" — the session/memory tools already validate identifiers and value
sizes via validateMemoryInput / validateText / validateIdentifier; the actual
hole was env passthrough in terminal_create, which the audit's wording missed
but which has the same root cause (untrusted input reaches a privileged
context unfiltered).