Prevent SQL injection
Demonstrate an SQL injection exploit on real code, then rewrite the queries with parameterised statements and add input validation as a second defence layer.
Preview
Copy prompt
The following code constructs SQL queries using string concatenation and is vulnerable to SQL injection: [Paste code]. Demonstrate a concrete, runnable exploit payload that would successfully attack the current code. Then rewrite every vulnerable query using parameterised statements or a safe ORM method that prevents injection entirely. Add server-side input validation as an independent second layer of defence and explain why parameterisation alone is the correct primary fix.
More
Security
Prompts
