creating-agents-in-medusa
Audited by Socket on Jul 14, 2026
2 alerts found:
SecurityAnomalyThis module functions as a deliberate arbitrary code execution engine: it accepts runtime-provided TypeScript, writes it to disk, executes it via `require()` in the same process, and supplies a privileged Medusa DI container plus a logging-based data return path. There is no sandboxing, no import/permission restriction, and no authorization enforcement within this fragment—security therefore hinges entirely on strict external access control. No explicit malicious payload is evident in the snippet itself, but the capability is severe and would enable data theft or destructive actions if an attacker can reach or influence the tool/endpoint.
This module is orchestration code with no obvious direct malicious logic. However, it intentionally enables a high-privilege MedusaExec capability (executing TypeScript against a live Medusa server) driven by untrusted model tool calls, and it unconditionally logs tool call inputs/args to console. The key security risk is therefore the combination of (a) potential over-privilege and insufficient enforcement/sandboxing of MedusaExec and (b) possible sensitive-data leakage via logging. Recommend verifying medusaExecTool sandboxing, permissioning, strict validation/allowlisting of executable operations, and adding programmatic mutation guardrails and log redaction/controls.