Skip to content
SSRF Write-up Intermediate

Bypassing Cloud Firewalls: Turning PostgreSQL into an Internal Po

A managed PostgreSQL environment blocked outbound TCP/HTTP but allowed DNS traffic from the dblink extension, letting a standard user exfiltrate data via DNS queries and scan internal ports on localhost using error messages.

Anas Diab Follow

Published on medium.com

Today, I’ll share an interesting finding where I was able to bypass strict network isolation in a cloud database to exfiltrate data and scan internal ports.

Anas Diab, 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

Impact

An attacker could exfiltrate sensitive data via DNS and map internal services on localhost, though the TCP connection itself was blocked.

What the attacker needed

Access to a managed PostgreSQL instance; ability to install the dblink extension; external DNS listener

The fix

The egress firewall should also block UDP port 53 (DNS) traffic from the database, or restrict the dblink extension to trusted users.

How it was found

  1. Enable the dblink extension as a standard user.
  2. Set up an external listener to receive DNS queries.
  3. Use dblink_connect to trigger a DNS lookup, which reaches the external server despite TCP being blocked.
  4. Attempt connections to internal ports on [redacted] and observe different error messages to map open and closed ports.

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 database extension called dblink lets you connect to other databases. The cloud firewall stopped normal internet connections but forgot to stop DNS lookups, which are like asking for a phone number. By making the database do DNS lookups, the attacker could sneak data out and also probe internal services by reading the error messages.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.