Skip to content
XSS Write-up Intermediate

Exploiting Incorrectly Configured Load Balancer With Xss To Steal Cookies

The load balancer trusted a client-supplied X-Forwarded-Host header when deciding where to send cookies for validation, so an attacker could redirect a victim's cookies to their own server. Chained with a Drupal CKEditor XSS, this let the attacker steal cookies that were otherwise protected by security flags and take over an admin account.

Serj Novoselov Follow

Published on infosecwriteups.com

In this article, we will explore a real-world scenario involving the exploitation of a load balancer vulnerability and cross-site scripting (XSS) to hijack cookies in an application. While specific names and screenshots will be omitted due to non-disclosure agreements (NDAs), we will examine the attack flow and its…

Serj Novoselov, 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

Impact

The attacker could bypass cookie security flags and gain unauthorised access to an admin account, though the text does not state whether any defence limited the attack in practice.

What the attacker needed

Victim visits a page with the XSS payload; attacker-controlled server to receive cookies; XSS vulnerability in the application

The fix

The load balancer should not derive the authz server's address from a client-supplied header such as X-Forwarded-Host; it should use a fixed, trusted configuration, and the XSS should also be fixed.

How it was found

  1. Send a request with a custom X-Forwarded-Host header pointing to an attacker-controlled server.
  2. Observe that the load balancer forwards the request's cookies to that server instead of the legitimate authz server.
  3. Find an XSS vulnerability in the application (Drupal CKEditor) and obfuscate the payload to bypass filters.
  4. Use the XSS to make the victim's browser issue a same-domain GET request that includes the X-Forwarded-Host header.
  5. The load balancer, confused by the header, sends the victim's cookies to the attacker's collaborator server.

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 load balancer sits in front of a website and checks each visitor's cookie with a separate login-checking server. This one believed a header the visitor's browser could set, which told it where that login-checking server was, so it sent the cookie to the attacker's server instead. The attacker also found a cross-site scripting (XSS) bug, which lets them run their own JavaScript in a victim's browser, and used it to make the victim's browser send that misleading header automatically.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Serj Novoselov

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.