T09 · Insecure Skill Coding Practices
- Location
bridge.js:103- Finding
Shell Command Injection Through Hermes Message Routing
- Content
View full analysis
!l.startsWith("session_id:")) .join("\n") .trim(); } catch (e) { return `(hermes error: ${e.message})`; } } ``` ### Technical Analysis The `message` value is placed directly into a command string passed to `execSync()`. Node.js executes string commands through a system shell. The implementation only adds backslashes before double quotes, which does not prevent shell evaluation inside double-quoted strings. For example, shell command substitutions such as `$(command)` and backtick expressions can still be evaluated. Depending on the shell and payload, newline and other metacharacter-based injection techniques may also be possible. The current reference implementation never calls `routeToAgent()`, so this path is dormant in the submitted version. However, it becomes directly exploitable if the function is connected to the advertised Nostr message-processing flow or otherwise called with attacker-controlled messages. ### Attack Path 1. The bridge is started with the `--hermes` option. 2. The advertised message-processing implementation is completed or otherwise connected to `routeToAgent()`. 3. An authorized Nostr sender submits a message containing shell command substitution, such as `$(id)` or a command that writes a file. 4. `routeToAgent()` interpolates the message into the `hermes chat` command. 5. `execSync()` invokes a shell. 6. The shell evaluates the injected expression before or while launching Hermes. 7. The in ...[truncated 733 chars]- Remediation
View remediation
