Skip to content
RCE Write-up Advanced

QNAP QTS: QNAPping At The Wheel (CVE-2024-27130 and friends)

A stack buffer overflow in the QNAP QTS file-sharing CGI script allows an attacker with a valid share link (ssid) to execute arbitrary code on ARM-based NAS devices. The overflow occurs because a user-supplied filename is copied into a fixed-size buffer without bounds checking.

labs.watchtowr.com

Published on labs.watchtowr.com

This research is a glimpse into the capability powering the watchTowr Platform, a Preemptive Exposure Management solution. We enable organizations to autonomously validate and mitigate their exposure to emerging threats, ahead of in-the-wild exploitation.

The author, on labs.watchtowr.com

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 function copies a user-controlled string into a fixed-size stack buffer without checking its length, and the binary lacks stack cookies.

Impact

An attacker with a valid share link could execute arbitrary code and gain root access on ARM-based QNAP NAS devices, but the provided proof-of-concept required ASLR to be manually disabled.

What the attacker needed

A valid share link (ssid); ARM-based QNAP device; ASLR disabled for the PoC

The fix

The vulnerability was fixed in QTS and QuTScloud according to the vendor's advisory.

How it was found

  1. Obtain a valid ssid by having a NAS user share a file with you.
  2. Send a POST request to the share.cgi endpoint with the ssid and a long name parameter.
  3. Observe the crash and control of the program counter.
  4. Craft a payload that sets the program counter to the system function and places a command string in a register.
  5. Send the payload to execute the command.
  6. Use the command execution to add a user, modify sshd config, and add sudoers entry.

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.

A NAS is a small computer used to store and share files. The QNAP software has a bug where a long filename can overflow a fixed-size memory area, letting an attacker run their own commands. The attacker needs a valid file-sharing link, which is often publicly posted.

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.