Files
moloapp/audit/MOLO-CLI-001/README.md
T

1.8 KiB

MOLO-CLI-001: shell command injection in molo new <name>

Scope: audit · README · AGENTS

In-house finding (not a public CVE), CWE-78 ("Improper Neutralization of Special Elements used in an OS Command").

Where

src/cli/cli/cli_app.cpp, cmd_new:

opts.name = args.positionals[0];
...
std::string dir = opts.name;
ScaffoldResult result = scaffolder.scaffold(dir, opts);

src/cli/cli/scaffolder.cpp, Scaffolder::scaffold:

std::string cmd = "git -C \"" + dir + "\" init -q 2>/dev/null";
if (system(cmd.c_str()) != 0) { ... }

dir is the project name exactly as typed on the command line, checked only for length (1-64 chars, kMaxProjectName). It is concatenated inside one pair of double quotes and handed to system(), a real shell. A name containing a " ends that quoted argument early; anything after it is ordinary shell syntax.

Relevance

molo new <name> is the first command in the README's own quickstart. Project names are often copied from elsewhere (a ticket title, a client's brand name, a CI variable) rather than hand-typed, which is exactly the kind of untrusted-but-looks- like-a-filename input this bug class targets.

What the check does

Runs molo new 'x"; touch <marker>; echo "' --force in a scratch directory and checks whether the injected touch created the marker file. PASS means it did not (the name is now escaped or passed to git without a shell); FAIL means the command ran.

Caveats

This proves injection with a benign touch, not a demonstration of what an attacker could do with it; system() runs as the invoking user with that user's full permissions, so the practical impact is whatever that user could already do by hand.

Run: make test in this directory, or make -C audit test from the repo root.