hermes-control-interface icon indicating copy to clipboard operation
hermes-control-interface copied to clipboard

Command injection in getInsights()

Open mayurjobanputra opened this issue 7 months ago • 1 comments

Just sharing what my Hermes found...

Security Audit — hermes-control-interface v2.0.2

✅ What's clean:

  • Zero outbound network calls — no exfiltration, no beaconing, no telemetry
  • No reverse shells, no crypto mining, no hidden iframes
  • No obfuscated code — everything is readable vanilla JS
  • Dependencies are all well-known packages (express, bcrypt, helmet, ws, xterm, etc.) — no typosquatting, no postinstall hooks
  • File system properly sandboxed — isAllowedPath() enforces configured roots, blocks path traversal
  • Auth is solid — bcrypt, timing-safe comparison, HMAC-SHA256 cookies, rate limiting, CSRF protection
  • CSP headers — only allows 'self' scripts + Google Fonts CSS. No external origins
  • No access to ~/.hermes/.env — the dashboard never reads API keys
  • install.sh — no external downloads, pure setup

⚠️ One finding (medium): Command injection in getInsights() at line ~819. The source query parameter is interpolated directly into a shell command: cmd += --source ${source}

days is safe (parsed int), but source is raw string. Requires auth to exploit, so it's an authenticated command injection risk — not a backdoor, just sloppy input handling.

Fix: I can patch it to sanitize source (allowlist alphanumeric + dash, reject ;, |, backticks, $()). Want me to?


Bottom line: This is a clean, well-built dashboard. No malicious intent, no data leaks, good security posture. The one injection bug is a code quality issue, not a trust issue.

mayurjobanputra avatar Apr 11 '26 23:04 mayurjobanputra

Fixed in v2.0.2.

Root cause: User-supplied source query param was interpolated directly into shell command without sanitization:

if (source) cmd += ` --source ${source}`;

Fix: Added allowlist regex validation at the API endpoint level:

if (source && !/^[a-zA-Z0-9_.\-]+$/.test(source)) {
  return res.status(400).json({ ok: false, error: 'invalid source...' });
}

Only alphanumeric, dash, underscore, dot characters allowed. Anything else (semicolons, pipes, backticks, $()) returns 400.

Thanks for the security audit!

xaspx avatar Apr 12 '26 06:04 xaspx