Skip to content
RCE Write-up Advanced

QNAP Pre-Auth Root RCE Affecting ~312K Devices on the Internet

Three vulnerabilities in QNAP PhotoStation can be chained: a pre-auth local file disclosure that leaks a login token to bypass authentication, an authenticated session tampering flaw that allows writing PHP code into a session, and a pre-auth session write to an arbitrary location. An unauthenticated attacker could chain these to write a webshell and achieve root remote code execution.

medium.com

Published on medium.com

In 2019, I discovered multiple vulnerabilities in QNAP PhotoStation and CGI programs. These vulnerabilities can be chained into a pre-auth root RCE.

Henry Huang, on medium.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

Likely a combination of insufficient access control on a file disclosure endpoint, improper input filtering in the SMTP email setting, and missing validation on where session files can be written.

Impact

An unauthenticated attacker could achieve root remote code execution on all QNAP NAS models running vulnerable PhotoStation versions, potentially compromising approximately 312,000 internet-facing devices.

What the attacker needed

Photo Station enabled on the QNAP NAS; Network access to the Photo Station service

The fix

The vulnerabilities were fixed by QNAP in PhotoStation versions 6.0.3, 5.2.11, and 5.4.9.

How it was found

  1. Use vulnerability 1 to read a cached plaintext login token and authenticate as the built-in user appuser.
  2. Use vulnerability 2 to inject PHP code into the session via the SMTP email setting.
  3. Use vulnerability 3 to write the polluted session to Photo Station's web directory, creating a webshell.

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.

This report describes three bugs in software running on QNAP storage devices. The first bug lets an attacker read a secret file without logging in, which gives them a valid login. The second bug lets a logged-in user put harmful code into their session data. The third bug lets an attacker save that session data to a place where it can be run as a program, giving full control of the device.

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.