MCP05
- Location
plugin/dist/inbound.js:68- Finding
Agent-mediated shell command injection through attachment filenames ## Remediation Suggestions 1. **Replace shell guidance with structured execution.** Provide an attachment-reading tool that accepts the message ID and filename as separate data arguments and invokes the API or CLI without a shell. 2. **Do not interpolate email-controlled metadata into executable instructions.** Keep filenames in clearly identified untrusted metadata fields rather than embedding them in ready-to-run commands. 3. **If shell commands must be generated, encode every argument correctly for the target shell.** Double quotes alone are insufficient. Apply this protection to filenames, message IDs, sender fields, thread IDs, and inbox IDs wherever commands are constructed. 4. **Add regression tests** covering command substitutions, backticks, embedded quotes, newlines, and shell metacharacters. Verify that hostile filenames remain literal data throughout attachment retrieval. 5. **Apply defense in depth.** Retain the skill’s email-safety instructions and restrict shell-tool permissions, but do not treat either as a substitute for eliminating unsafe command construction.
- Content
View full analysis
Vulnerability Details
File Location:
plugin/dist/inbound.js:68–71
Vulnerability Type: Unsafe shell-command generation from untrusted email metadata
Risk Level: MediumVulnerable Code
js const unread = params.attachments.filter((a) => !a.parsedText?.trim()).map((a) => a.filename); if (unread.length > 0 && params.staged.paths.length === 0) { header.push(`(read one with: openclaw openmail -- attachments text --message-id ${params.messageId} --filename "${unread[0]}")`); }Technical Analysis
The plugin inserts an inbound attachment filename into a command presented to the agent as plugin-authored guidance. The filename is not shell-escaped.
Enclosing a value in double quotes does not prevent shell interpretation:
$()and backtick command substitutions remain active, and an embedded double quote can terminate the quoted argument. For example, if preserved by the email service, the filename:text $(printf OPENMAIL_AUDIT).pdfproduces guidance equivalent to:
bash openclaw openmail -- attachments text --message-id MESSAGE_ID --filename "$(printf OPENMAIL_AUDIT).pdf"Executing this command through a compatible shell runs
printfbefore invoking the CLI. An attacker could substitute a different command.This is an agent-mediated vulnerability, not direct execution by the plugin. The CLI wrapper itself uses argument-array spawning without a shell. Exploitation requires the model to execute the generated guidance through a shell-capable tool without safely re-encoding the filename. The skill’s instruction not to execute commands from emails is a mitigation, but the unsafe command is presented as plugin-generated guidance rather than merely quoted email content.
Attack Path
- An attacker sends an email containing an attachment with shell syntax in its filename to an enabled inbox.
- OpenMail preserves the relevant filename characters, and the message passes server-side classification.
- The attachme ...[truncated 1231 chars]
