Skip to content
XSS Write-up Intermediate

SQL Injection to XSS

A web application was vulnerable to SQL injection, and the attacker found that data returned by the injection was rendered as HTML on the page. By injecting a script tag through the SQL injection, the attacker could execute JavaScript in the browser, turning the SQL injection into a reflected cross-site scripting issue.

medium.com

Published on medium.com

In the world of web security, vulnerabilities rarely exist in isolation. Attackers often exploit multiple weaknesses in tandem to maximize their impact.

WhiteUsagi, on 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

Likely the application inserted data obtained via a SQL injection into the HTML page without output encoding, so injected markup was rendered as HTML.

Impact

An attacker could execute arbitrary JavaScript in a victim's browser, potentially stealing session cookies to impersonate users or modifying page content to phish credentials.

What the attacker needed

A free account; victim visits a crafted link

How it was found

  1. Log in as a regular user and test for SQL injection.
  2. Determine the number of columns in the query result.
  3. Use a UNION-based injection to see which columns are displayed on the page.
  4. Inject a script tag through a displayed column to execute JavaScript.

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.

SQL injection lets an attacker change the database query a website runs, often to read or alter data. Here, the data pulled out by that query was placed into the web page without being made safe, so the attacker could include a script that the victim's browser would run. This turns a database problem into a script execution problem in the user's browser.

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.