Skip to content
SSRF Write-up Advanced

From Ssrf To Rce A 7 Step Chain Against Posthog

PostHog's webhook save endpoint bypassed SSRF validation, and the Rust webhook worker followed redirects, allowing access to ClickHouse. A SQL escaping bug in ClickHouse table functions enabled SQL injection into PostgreSQL, which had default credentials, leading to remote code execution.

Pawan Jaiswal Follow

Published on infosecwriteups.com

This chain demonstrates how modern microservice architectures can amplify the impact of seemingly low-severity issues when combined. It underscores the importance of consistent input validation, secure defaults, and defense-in-depth for distributed systems.

Pawan Jaiswal, on infosecwriteups.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 inconsistent input validation (SSRF checks bypassed on save), redirect following in the webhook worker, improper SQL escaping in ClickHouse table functions, and default PostgreSQL credentials.

Impact

An attacker could achieve remote code execution on the PostgreSQL instance, potentially compromising the entire system.

What the attacker needed

Access to webhook save endpoint; ability to trigger webhook worker; default PostgreSQL credentials

How it was found

  1. Use the webhook save endpoint to bypass SSRF validation.
  2. The Rust webhook worker follows HTTP redirects, converting POST to GET for ClickHouse access.
  3. Send crafted input to ClickHouse table functions that is improperly escaped for PostgreSQL.
  4. Use dollar quoting to bypass ClickHouse's backslash escaping and inject SQL into PostgreSQL.
  5. Use static Docker names and default PostgreSQL credentials to pivot.
  6. Execute a reverse shell via COPY FROM PROGRAM on PostgreSQL.

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 a chain of security weaknesses in PostHog, a product analytics platform. An attacker could use a webhook feature to make the server connect to internal services, then exploit a database bug and weak default passwords to run commands on the server. Each step alone might be low risk, but together they allowed full control.

What is SSRF?

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

More by Pawan Jaiswal

View all

1 more disclosed report, best first.

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.