Skip to content
Access control Write-up Intermediate

Anatomy of an Attack: How I Hacked StackOverflow

A misconfigured IIS server rewrote the client IP address from the X-Forwarded-For header, so requests made through a local proxy appeared to come from localhost. The attacker gained full administrative access to the chat application, including a database query interface.

blog.ircmaxell.com

Published on blog.ircmaxell.com

Almost two years ago I had stumbled upon a pretty significant vulnerability in the StackExchange network. I say stumbled, because I wasn’t actually trying to attack the site.

The author, on blog.ircmaxell.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

The attacker gained full administrative access to the chat application, including a database query interface, but the issue was reported and fixed quickly.

What the attacker needed

Access to a proxy server; ability to tunnel traffic to the proxy; victim uses the proxy

The fix

The server configuration was corrected so that Remote_Addr is not rewritten from X-Forwarded-For, and the application should not rely on IP-based security.

How it was found

  1. Set up a Squid proxy on a public server, limited to localhost, and connect to it through an SSH tunnel.
  2. Browse StackOverflow through the proxy, so Squid adds an X-Forwarded-For header with the value 127.0.0.1.
  3. Notice a new 'Admin' menu item in the chat application and click it.
  4. Gain full admin access, including the developer console and a database query interface.

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 website tried to restrict admin features to requests coming from the same machine (localhost). A proxy server added a header saying the request came from localhost, and the web server believed it. The attacker used that to get admin access without any password.

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.