Skip to content
RCE Write-up Advanced

What is argument injection?#

The system passed user-supplied filenames to tar without adequate sanitisation, allowing argument injection. An attacker could chain multiple injections to achieve command execution.

staaldraad.github.io

Published on staaldraad.github.io

This is going to be a short write-up about an interesting argument injection I ran into a while ago. There is nothing new here, but it is still worth looking at as argument injection is an oft overlooked attack avenue as everyone is going after the more traditional command injection vulnerabilities.

Etienne Stalmans, on staaldraad.github.io

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

Impact

An attacker could execute arbitrary commands on the system.

What the attacker needed

Ability to supply filenames; ability to host a malicious archive

The fix

The fix was to add an additional check and discard any user-supplied filename that started with a dash.

How it was found

  1. Create a malicious tar archive containing files with absolute paths.
  2. Host the archive remotely and update the build file to download it.
  3. Inject the -P option to extract files to absolute paths.
  4. Inject the -T option to read a file containing further arguments.
  5. The file contains checkpoint options that execute a command.

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.

Argument injection is when user input is passed as command-line options to a program, rather than as data. Here, the program used a function to escape special characters, but it left the dash unescaped, so an attacker could sneak in extra options to the tar command. By chaining these options, the attacker could make tar run arbitrary commands.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.