Skip to content
XSS Write-up Intermediate

Laravel Source Code Review: How XSS Lead to Privilege Escalation

A Laravel HR application stored vacation reasons without escaping and rendered them raw in the admin panel, creating a blind XSS. An attacker could submit a malicious vacation reason that, when viewed by an admin, executed JavaScript to perform a privileged user update and escalate the attacker's account to admin.

Moustafa Yasser Follow

Published on kh3dr.medium.com

Before diving into the code review, I’d like to clarify that this was my first time reading code written in the Laravel framework. So, I first had to understand how Laravel works and how its code is structured in order to grasp the overall logic of the application.

Moustafa Yasser, on kh3dr.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

Root cause

The developer used Blade's raw output syntax instead of the escaped output syntax when displaying the vacation reason, and the user update endpoint lacked an authorization check.

Impact

An attacker with a low-privileged account could escalate their privileges to administrator when an admin views the malicious vacation request, and the report also notes a separate shell_exec call that could lead to RCE.

What the attacker needed

A low-privileged user account; admin views the vacation requests page

The fix

The application should escape the vacation reason output using the double-brace syntax and enforce the missing authorization check in the user update controller.

How it was found

  1. Log in as a low-privileged user and submit a vacation request containing a script in the reason field.
  2. Wait for an administrator to view the vacation requests page in the admin panel.
  3. The script runs in the admin's browser, reads the CSRF token from the page, and sends a request to update the attacker's user account.
  4. The update request succeeds because the authorization check is missing, and the attacker's account becomes an administrator.

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 application let users type a vacation reason and later showed it to administrators without cleaning it up. Because the text was inserted directly into the page, it could contain a small script that ran in the administrator's browser. That script could then quietly change the attacker's account to an administrator account.

What is XSS?

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

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.