Command Injection
The systeminformation Node.js package passed a user-supplied URL into an OS command after a character-by-character sanitiser, but if the URL was an array the sanitiser checked whole strings instead of single characters, so the checks failed. An attacker who could supply an array could therefore run arbitrary OS commands.
blog.effectrenan.com
Published on blog.effectrenan.com
This write-up aims to explain a simple vulnerability discovered in an open-source project developed in JavaScript and to show how we can receive a reward without having a big experience in infosec.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The sanitiser assumed its input was a string and indexed it character by character, so an array input made each index return the whole element and bypassed every character check before the value was concatenated into a shell command.
Impact
An attacker able to send an array as the URL could execute arbitrary commands on the host operating system.
What the attacker needed
Application passes user input as URL; input can be sent as an array
The fix
The fix was to check that the URL is a string before proceeding.
How it was found
- Find a place where the application passes user input to the vulnerable function as a URL.
- Send an array instead of a string as the URL value.
- The sanitiser checks whole strings rather than single characters, so the dangerous characters pass through.
- The value is concatenated into an OS command and executed.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Command injection means a program builds a shell command out of user input, so a crafted input can add extra commands. Here the package tried to clean the input one character at a time, but if the input was a list (an array) instead of text, each 'character' was actually the whole string, so the cleaning checks never matched. The result was that a crafted list could make the server run commands of the attacker's choosing.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.