Skip to content
RCE Write-up Advanced

‍Versions Tested

An undocumented PostgreSQL account with a weak password allowed an attacker to execute a custom trigger function that ran shell commands, leading to remote code execution as the postgres user. A setuid root binary then allowed privilege escalation to root via a symbolic link attack, resulting in full system compromise.

cyberonesecurity.com

Published on cyberonesecurity.com

By CyberOne Security TeamThis article was written by members of the CyberOne Security Team, drawing on decades of combined experience in cloud and network security, penetration testing, threat intelligence, and advisory services.

The author, on cyberonesecurity.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 the combination of an undocumented default database account with weak credentials, a trigger function that passed user input to a shell without sanitisation, and a setuid binary that created files in a user-controlled path.

Impact

An attacker with network access to the PostgreSQL port could execute commands as the postgres user and then escalate to root, compromising the entire backup appliance and potentially all backup clients.

What the attacker needed

Network access to PostgreSQL port; knowledge of wguest credentials

The fix

The wguest account was removed and the Perl UDFs were removed.

How it was found

  1. Discover the wguest PostgreSQL account with password wguest.
  2. Connect to PostgreSQL as wguest and identify the vulnerable trigger function run_elk_alert_script().
  3. Create a table in the public schema with a trigger that calls the vulnerable function.
  4. Insert a row with shell metacharacters in the alert_text column to execute commands.
  5. Use the command execution to obtain a reverse shell as the postgres user.
  6. Exploit a setuid root binary via a symbolic link attack to create a malicious shared library and gain root.

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.

The backup appliance had a hidden database account with a very easy password. That account could run a special database function that executed system commands, letting an attacker take control of the database user. A second flaw in a privileged program then allowed the attacker to become the root administrator.

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.