Skip to content
Access control Write-up Intermediate

thisclosed_#2 - PostgreSQL Database Exfiltration through the abuse of PostgREST requests

The application exposed a PostgREST endpoint that allowed querying database tables without proper authorization checks. An attacker could request specific columns from the users table, such as id and email, to exfiltrate sensitive information.

Samuele Gugliotta Follow

Published on blog.hckrt.com

bug-bounty | security-testing | ethical-hacking | writeup

Samuele Gugliotta (@indevi0us), on blog.hckrt.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 application did not enforce proper authorization checks on the PostgREST endpoint, allowing access to database tables and columns that should have been restricted.

Impact

An attacker could exfiltrate sensitive information from database tables that should not be accessible to a regular user.

What the attacker needed

Access to the web application; HTTP Basic Authentication credentials

The fix

The issue was fixed by the customer, as acknowledged in the article.

How it was found

  1. Intercept the GET request to /pg/vw_contract_with_orgs?select=*
  2. Modify the request to point to the users table: /pg/users?select=*
  3. Observe permission denied error for table users
  4. Modify the request to select only the id column: /pg/users?select=id
  5. Receive the contents of the id column
  6. Add more columns such as email, updated_at, created_at to the select parameter

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 application used a tool called PostgREST to turn its database into a web API. The author found that by changing the web address, they could ask for data from tables that should have been private, like the list of users. This let them see information such as user IDs and email addresses.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.