Skip to content
RCE Advisory Intermediate CVE-2023-28102

GHSL-2022-094: Remote Code Execution in discordrb - CVE-2023-28102

The encode_file method in discordrb constructs a shell command using the file parameter without sanitisation, allowing command injection if untrusted input is passed. An attacker could execute arbitrary shell commands on the host machine, but only if a client of the library calls the vulnerable method with user-controlled data.

ghsecuritylab Follow

Originally disclosed on GitHub Security Lab

The encodefile method may lead to remote code execution if invoked with untrusted user-controlled data.

ghsecuritylab, on GitHub Security Lab

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 report has not been written yet. The Original tab links to the source.

How it worked

Impact

If a client of the library passes untrusted user input to encode_file, an attacker could execute arbitrary shell commands on the host machine, leading to remote code execution.

What the attacker needed

A client application uses discordrb; client passes untrusted input to encode_file

The fix

The vulnerability was fixed by the maintainer, and code scanning was added to the repository.

How it was found

  1. Set up discordrb and create an Encoder instance.
  2. Call encode_file with a file argument that contains shell metacharacters (e.g., backticks).
  3. The library builds a command string with the file argument and executes it via IO.popen.
  4. The injected command runs, creating a file named 'pwned' in the current working directory.

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 report has not been written yet. The Original tab links to the source.

This is a bug in a Ruby library that builds a command to run a program called ffmpeg. The library puts a file name directly into that command without checking it, so if a file name contains special characters, an attacker could make the computer run other commands. However, the library itself is not directly exploitable; a program using the library must pass user input to the vulnerable method.

What is RCE?

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

More by ghsecuritylab

View all

132 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

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.