I Hired a Penetration Tester to Attack My FastAPI App. He Owned Everything in 45 Minutes

Open original

A developer hired a penetration tester to attack his FastAPI staging environment and within 45 minutes the tester exploited leaked OpenAPI docs, an unprotected IDOR endpoint, a hard-coded JWT secret, a raw-SQL reporting endpoint, and lax webhook verification to gain full admin access and dump the database. The report lists critical flaws and warns of exposed production keys in staging.

  • Auto-generated OpenAPI/Swagger docs left public let the tester map the entire schema and find a forgotten admin-role endpoint in just 8 minutes.
  • An unprotected GET /users/{user_id} endpoint let him swap IDs to steal the admin's email, bcrypt hash, and API keys.
  • A hardcoded JWT secret found via Google cache of a deleted GitHub issue let him forge tokens and impersonate admin.
  • A raw f-string SQL "reports" endpoint was UNION-injectable, dumping every user's credentials and Stripe IDs, and he then hijacked the Stripe webhook to redirect payments—all in 45 minutes total.

Ramesh built a FastAPI app over six months, convinced his JWT tokens, HTTPS setup and Pydantic validation made it safe. He hired a penetration tester for two hours at $120/hour. In just eight minutes, the tester read the auto-generated Swagger docs and mapped the database schema, spotted a forgotten POST /admin/users/{user_id}/role endpoint in the public schema, and discovered an error response that leaked whether an email existed. Six minutes later he found an unprotected GET /api/v1/users/{user_id} endpoint. By swapping his own user ID for Ramesh’s admin ID, he pulled down the admin email, bcrypt-hashed password and API keys. At minute 22, he forged a JWT by finding a hardcoded secret in Ramesh’s staging docker-compose.yml via a Google cache of a deleted GitHub issue. That let him impersonate admin across the board. By minute 31, the tester ran a UNION-based SQL injection against a “custom reports” endpoint built with raw f-string concatenation. He sucked out every user’s email, password hash and Stripe customer ID. Two minutes later he reached the Stripe webhook URL and set it to his own server, ready to divert payments. In 45 minutes, every major security control Ramesh trusted was bypassed.

Ask about this article