Anže Žitnik SQL Injection
XLAB 22 September 2020
Co-funded by the European Commission
Horizon 2020 – Grant # 786668
SQL injection
Attack type targeting database-backed applications
SQL statements inserted as input and run by the
application
Parameters, form input, URL, cookies...
Most common web application attack
First mentioned in 1998
Injection #1 on OWASP Top 10 since 2010
20/09/23 – [Link] - @cyberwiser 2
SQL injection: latest attacks
20/09/23 – [Link] - @cyberwiser 3
SQL injection: example
Example code:
String query = “SELECT * FROM accounts WHERE custID = ’” +
[Link](“id”) + “’”;
Example URL: [Link] or ‘1’=’1
Resulting query:
SELECT * FROM accounts WHERE custID = ’’ or ‘1’=‘1’
Modify, delete data, call arbitrary code (DB and
system!)
20/09/23 – [Link] - @cyberwiser 4
SQL injection: prevention
Sanitize, verify inputs (server side)
Escape special characters
Use ORM frameworks
Limit access as much as possible (permissions for DB
user)
Include security testing in development/release
Regularly update CMS (WordPress, Drupal, Joomla)
20/09/23 – [Link] - @cyberwiser 5
Demo
SQL injection
Red team and blue team
[Link] tools
Red team:
Can use prepared vuln.
detection script
Goal: Exploit SQLi to
find secret flag
Blue team:
Can use tools for attack detection, risk assessment
Goal: Choose correct mitigation among the offered ones
20/09/23 – [Link] - @cyberwiser 6
Demo
20/09/23 – [Link] - @cyberwiser 7
Demo
20/09/23 – [Link] - @cyberwiser 8
Demo
20/09/23 – [Link] - @cyberwiser 9
Demo
20/09/23 – [Link] - @cyberwiser 10
Thank you for your attention! Questions?
Main contact:
Anže Žitnik
XLAB
[Link]@[Link]
[Link] @cyberwiser