Case File: The Search Box
Arewa Microfinance's old customer-search page builds its database query by pasting in whatever the visitor types. In a safe, simulated copy of the page, break it: prove the bug, count the columns, find a hidden table of credentials and take a key. Then deploy the fix and replay the attack. The database is generated for you alone.
Arewa Microfinance Β· Episode 5
The Search Box
The bank's old customer-search page is still live, and a contractor says it can be made to leak secrets
Halima CISO Β· Email
Hello, itβs Halima. A contractor told Musa that our old customer-search page βcan be talked intoβ showing things it should not. I do not want to take that on trust, and I do not want anyone testing the live page.
We have put a safe copy of it in front of you. Prove it, show me what it leaks, and then show me that the fix works.
The brief
Scope and authorisation. This is a simulated copy of the page running entirely in your browser, with its own invented database. Nothing here connects to a real system, and that is the only kind of target you may test without written permission.
The page runs a query like SELECT name, branch, phone FROM customers WHERE name LIKE '%your text%'. Your text is pasted straight into it. Try the following, in order:
- Search for an ordinary name. Then search for a single quote,
', and read the error. - Work out how many columns the query returns (
ORDER BYwith a number is a classic probe; the error tells you when you go too far). - Ask the database for the names of its tables (
UNION SELECTwith three columns, fromsqlite_master). - Read the hidden table and find the
core-bankingcredential.
A tip from every real tester: begin your payload with text that matches no customer, such as zzz, so that only the rows you ask for appear and are not buried among the real customers.
The flag: the core-banking key is your flag. Submit it at the bottom of this page. Then deploy the fixed version and replay your attack.
Starting the bank's test server in your browserβ¦
Halima, a little later: βThe developer says he already fixed the problem: he now blocks the single quote character in the search box. Is that enough? Please test that claim before we accept it.β
Think about what an attacker can still do if quotes are blocked, and what the real fix is.
π The debrief unlocks when you close the case. Finish the lab above.
The debrief
Halima: βI can put this in front of the board in one page: the cause, the proof, what was exposed, and that the fix works. Thank you.β
What a senior analyst would do next. Report that one search box exposed a table the page never meant to show, with the proof of exactly what was read. Recommend parameterised queries everywhere the application touches the database, an account for the web app that can only read the tables it needs, generic error messages for visitors, and a review of every other query written the same way. Because the credential was readable, treat it as compromised and rotate it.
The ideas to keep.
- The bug is mixing code and data. The fix is to keep them apart. Parameterised queries do that; filtering characters does not.
- Verbose errors helped the attacker. The column count and the table names came from messages the page should never have shown.
- Least privilege limits the damage. The search page should never have been able to read a table of credentials at all.
Where you will build it. The backend development course shows how to write queries safely and design the database account properly. The OWASP Top 10 lesson in this course puts injection in its wider context.
Next episode: the web shell.
Write your finding for Halima
Say what the flaw is, what you were able to read, why it happened, and how to fix it. Do not include the secret value itself.
π§ͺ Want to practise this on your own computer? See how to set up your lab →