Summary
A command injection flaw in the automagik-genie 2.5.27 MCP Server allows arbitrary OS commands to be executed when handling the view_task (aka view) operation in the readTranscriptFromCommit function.
If an attacker can control or influence the external FORGE_BASE_URL or related input consumed by this path, they may execute system commands with the privileges of the MCP server process.
Affected context
This vulnerability occurs in deployments of automagik-genie MCP Server (version 2.5.27) where:
- The
view_task/viewfunctionality is exposed and used to callreadTranscriptFromCommitindist/mcp/server.js - The server reaches out to an external location derived from
FORGE_BASE_URLor similar configuration/input - User-provided or environment-controlled values are used to construct command-line invocations without strict validation or isolation
The issue is most relevant when FORGE_BASE_URL or parameters used with it can be influenced by a less-trusted user, external service, or CI/automation pipeline.
Exploit preconditions
- Attack surface: MCP server endpoint or workflow that invokes the
view_task(akaview) operation. - Required access: Ability to supply or influence data that flows into
readTranscriptFromCommit, especially values derived fromFORGE_BASE_URLor related URL/path parameters. - Trigger point: Execution of the
view_taskoperation that causes the server to build and run a system command (e.g., via shell or process-spawning APIs). - Why exploitation is possible: Untrusted input is incorporated into command strings or arguments without robust sanitization, strict whitelisting, or safe process spawning, enabling injection of additional shell metacharacters or commands.
Why this happens
The root cause is the construction of system-level commands using unvalidated input associated with FORGE_BASE_URL and the view_task request handling.
This aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command, where application logic builds a shell or OS command line by concatenating or interpolating user-controlled data.
When a command is formed as a single string or passed through a shell interpreter, special characters (such as separators, redirection operators, or subshell syntax) are interpreted as additional commands or arguments, enabling unintended execution.
Secure design would treat all external URLs and parameters as untrusted, validate them against strict patterns, and avoid passing them through shell parsing at all.
Potential impact
- Execution of arbitrary OS commands with the privileges of the MCP server process
- Reading, modifying, or deleting local files accessible to the server
- Pivoting to other internal services or hosts reachable from the server environment
- Exfiltration of sensitive information (credentials, tokens, configuration)
- Disruption of service availability through destructive or resource-exhausting commands
General mitigation guidance
Defensive measures focus on eliminating direct command construction and reducing trust in external configuration and URLs:
- Replace shell-based command execution with safe process APIs that accept argument arrays and do not invoke a shell.
- Apply strict input validation and whitelisting for any data used in command parameters (e.g., allowlisted domains, repository names, or paths).
- Avoid embedding untrusted data directly into command strings; if commands are unavoidable, use parameterized invocation and reject special characters.
- Treat
FORGE_BASE_URLand similar configuration values as untrusted unless they are hardcoded or strongly controlled, and validate them against a fixed set of allowed patterns. - Run the MCP server under a least-privilege account with minimal filesystem and network permissions so that impact is constrained if command execution occurs.
How teams detect issues like this
Organizations can identify this class of flaw using a combination of code analysis and operational monitoring:
- Static analysis rules that flag use of shell-executing APIs (e.g.,
exec,spawnwith shell enabled, or similar wrappers) where arguments include request data, environment variables, or configuration derived from user-controlled sources. - Code review checklists emphasizing the separation of command logic from untrusted inputs and requiring justification for any shell invocation.
- Security linters or automated review tools configured to highlight string concatenation used to build commands, especially in network- or user-facing code paths like MCP handlers.
- Runtime monitoring for anomalous command patterns, such as unexpected utilities being run by the MCP server process or unusual outbound network connections originating from that process.

