Skip to content
SQL injection Write-up Intermediate

SQL injection in largest Electricity Board of Sri Lanka

The payment subdomain of a national electricity board was vulnerable to time-based SQL injection in the account number parameter, allowing an attacker to extract the database. Additionally, exposed .env and .git files leaked database credentials and secret keys, and the origin IP was accessible without WAF protection, enabling re-exploitation after a patch.

medium.com

Published on medium.com

SQL Injection is a technique used by attackers to take advantage of vulnerabilities in a websites database. By inserting harmful SQL code into inputs such as forms or search fields they can reach, modify or even erase sensitive information.

π™‡π™€π™¨π™©π™¨π™šπ™˜, 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 concatenated user input directly into SQL queries without parameterisation, and sensitive files were left in the web root.

Impact

An attacker could extract the entire database, access other users' payment information, and make payments on their behalf; the origin IP bypassed the WAF and allowed re-exploitation after a patch.

What the attacker needed

Access to the payment subdomain; a leaked account number; ability to send crafted requests

The fix

The vulnerabilities were patched by the team after the second report, but the text does not specify the exact fix; proper fix would be parameterised queries and removing sensitive files from the web root.

How it was found

  1. Find subdomains and filter for PHP/ASP/JSP technologies.
  2. Discover a leaked account number via passive URL collection.
  3. Enter the leaked account number and observe disclosure of another user's payment information.
  4. Test the account number parameter with a single quote and observe an error.
  5. Use Burp Intruder with XOR-based blind SQL injection payloads and note delayed responses.
  6. Confirm time-based SQL injection with curl and exploit with Ghauri to retrieve the database.

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 is when a website puts user input directly into a database command, so an attacker can trick the database into revealing or changing data. Here, the account number field was not properly sanitised, so a crafted input caused the database to pause for 10 seconds, proving the attacker could run their own database commands. Separately, the site left sensitive files like .env and .git publicly accessible, which contained passwords and secret keys.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.