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.
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
- Find subdomains and filter for PHP/ASP/JSP technologies.
- Discover a leaked account number via passive URL collection.
- Enter the leaked account number and observe disclosure of another user's payment information.
- Test the account number parameter with a single quote and observe an error.
- Use Burp Intruder with XOR-based blind SQL injection payloads and note delayed responses.
- 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.