A pentest report shows SQL injection in a search endpoint of a Java service. How do you handle it end to end?
BeginnerScenarioVulnerability Management and OWASP
Answer
Situation read → Confirmed injection (OWASP A03) in production code. Fix the code, check whether it was exploited, and stop the same class of bug from coming back.
What I'd do →
- Reproduce from the report in staging and confirm the vulnerable query.
- Replace string concatenation with a parameterised query:
PreparedStatement ps = conn.prepareStatement( "SELECT id, name FROM products WHERE name LIKE ?"); ps.setString(1, "%" + term + "%"); - Search access and database logs for injection payloads (
' OR 1=1,UNION SELECT,sleep() to see if it was already abused. - Add a Semgrep or CodeQL rule for string-built SQL so the pattern fails in PR.
- Make sure the app's DB user has no DDL rights, so the next bug has a smaller blast radius.
Why → One fix closes one hole; the rule closes the class; least-privilege DB access limits what an attacker can do with the next one.
Interview tip → Always mention checking logs for prior exploitation, not just patching.
More on Vulnerability Management and OWASP
A scanner reports 4,000 open CVEs across 300 images. The team can fix maybe 100 a month. How do you prioritise?IntermediateA user reports they can see another customer's invoice by changing the ID in the URL. What do you do?BeginnerA webhook feature lets users enter a URL, and a pentester used it to read the cloud metadata endpoint. How do you fix it?AdvancedA team still runs Log4j 2.14 in an internal service and says it is not internet-facing. How do you respond?IntermediateA security review finds passwords stored as unsalted MD5 hashes. How do you migrate without forcing every user to reset?AdvancedYour DAST scan in staging finds reflected XSS in a React app. The developers say React escapes everything. Who is right?Intermediate