SlideShare a Scribd company logo
SQL Injection Attacks:
Is Your Data Secure?
Cleveland C#/VB.Net User Group | Bert Wagner | February 22, 2018
Objective
SQL injection prevention does not have an “easy” solution
Disclaimers
• Try this at home
• Not at work
• Not on other people’s systems
Background
• Business Intelligence Developer
• Tech security enthusiast
• Saw my first injection attempts in ~2001 – MySQL logs
Demo code and slides available at bertwagner.com
Overview
1. Importance of SQL injection protection
2. Dynamic SQL
3. What does SQL injection look like?
4. Common misconceptions
5. Preventing SQL injection
• Data Leaks
• Data Validity
• Server Availability
Dynamic SQL
“Just because you can, doesn’t mean you should.”
• Can’t parameterize
everything
• Adaptable Queries
• Performance
However…
What is SQL Injection?
• Dynamic string execution
• Unsanitized input (could be from a column or parameter)
• Performing something the query wasn’t originally intended to do
What is SQL Injection?
Concatenating a parameter into our query string
What is SQL Injection?
SQL injection can occur without concatenated parameters too
Let’s go back to 1998…
OWASP 2004
OWASP – Present Day
Common Misconceptions
“The structure of my
database isn’t public”
You don’t have a Users table? Products?
Inventory? etc...
“The Amazing Bert”
Common Misconceptions
“I obfuscate my table names”
sys.objects? Errors displayed in app?
Logs, emails, social engineering…?
Common Misconceptions
“Isn’t it the DBAs job to protect the database?”
True. But multiple layers of security are better than one.
Front end validation doesn’t stop malicious users Server side validation does
Common Misconceptions
“I’m not important enough to get hacked”
Automated injection tools target everyone
https://github.com/sqlmapproject/sqlmap/wiki/Techniques
Common Misconceptions
“I use an ORM to code my SQL queries”
ORMs are still vulnerable if you need to pass an argument that can’t be
parameterized by SQL Server or if you use a vulnerable stored procedure
Other libraries, like the LINQ Dynamic Query Library, try to mitigate this but are also not perfect
https://stackoverflow.com/questions/8738953/is-injection-possible-through-dynamic-linq
Protecting Against SQL Injection
Must take a multi-layered approach.
Demos:
• Don’t write dynamic SQL
• sp_executesql
• QUOTENAME()
• REPLACE()
• EXECUTE AS
• Limit inputs
• Homoglyph attacks
• Proactively find injection vulnerabilities
Other Tools
• sqlmap
• Azure SQL
• Continuous monitoring tools
• Troy Hunt’s “hackable” website:
https://hackyourselffirst.troyhunt.com/
Recap
• No easy, single-approach solution
• Validate, sanitize, escape
• Developers and DBAs both responsible
• Limit executing account privileges
• Use other software to help test, find vulnerabilities
Thank you!
@bertwagner
bertwagner.com
youtube.com/c/bertwagner
bert@bertwagner.com
22
New posts and videos
every Tuesday!

More Related Content

PPTX
SQL Injection Attacks - Is Your Data Secure? SQL Saturday Rochester
PPTX
SQL Injection Attacks - Is Your Data Secure? GroupBy Conference
PPTX
SQL Server Security and Intrusion Prevention
PPTX
Denali Sql Server Security
PPTX
Hacker Proof web app using Functional tests
PPT
Securing you SQL Server - Denver, RMTT
PPTX
Automating security tests for Continuous Integration
PPTX
Security guidelines
SQL Injection Attacks - Is Your Data Secure? SQL Saturday Rochester
SQL Injection Attacks - Is Your Data Secure? GroupBy Conference
SQL Server Security and Intrusion Prevention
Denali Sql Server Security
Hacker Proof web app using Functional tests
Securing you SQL Server - Denver, RMTT
Automating security tests for Continuous Integration
Security guidelines

What's hot (19)

PDF
Automated Security Testing
PPTX
Microsoft Enterprise Communications Event
PDF
From Gates to Guardrails: Alternate Approaches to Product Security
PDF
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...
PPTX
Security testautomation
PDF
Python + MPP Database = Large Scale AI/ML Projects in Production Faster
PDF
[OWASP Poland Day] Security knowledge framework
PPTX
Top 5 Priorities for Cloud Security
PPTX
CSS 17: NYC - Stories from the SOC
PDF
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
PPTX
CSS 17: NYC - Realities of Security in the Cloud
PPTX
PDF
The Case For Continuous Security
PPTX
Microsoft Fakes, Unit Testing the (almost) Untestable Code
PDF
Autonomous Incident and Root Cause Detection
PPTX
Dev ops toronto
PDF
T23 HTML5 Security Testing at Spotify
PPTX
Continuous Security Testing in a Devops World #OWASPHelsinki
PDF
CIS13: Identity is the New Currency
Automated Security Testing
Microsoft Enterprise Communications Event
From Gates to Guardrails: Alternate Approaches to Product Security
Lavorare con codice legacy “non testabile” - Incontro DevOps - 8 marzo 2019 -...
Security testautomation
Python + MPP Database = Large Scale AI/ML Projects in Production Faster
[OWASP Poland Day] Security knowledge framework
Top 5 Priorities for Cloud Security
CSS 17: NYC - Stories from the SOC
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
CSS 17: NYC - Realities of Security in the Cloud
The Case For Continuous Security
Microsoft Fakes, Unit Testing the (almost) Untestable Code
Autonomous Incident and Root Cause Detection
Dev ops toronto
T23 HTML5 Security Testing at Spotify
Continuous Security Testing in a Devops World #OWASPHelsinki
CIS13: Identity is the New Currency
Ad

Similar to SQL Injection Attacks: Is Your Data Secure? .NET Edition (20)

PPTX
SQL Injection Attacks: Is Your Data Secure?
PPTX
Web security
PPTX
Sql server security in an insecure world
PDF
Sql injection whitepaper
PPTX
Sql injection
PDF
Unsafe Deserialization Attacks In Java and A New Approach To Protect The JVM ...
PPTX
Cyber crime an eye opener 144 te 2 t-7
PDF
Luis Grangeia IBWAS
PDF
IBWAS 2010: Web Security From an Auditor's Standpoint
PPTX
Sql injections (Basic bypass authentication)
PPTX
csf_ppt.pptx
PDF
Practical Approach towards SQLi ppt
PDF
Geek Sync | Field Medic’s Guide to Database Mirroring
PPTX
Java application security the hard way - a workshop for the serious developer
PPTX
Application Security 101 (OWASP DC)
PDF
How to Destroy a Database
KEY
DevOpsSec: Appling DevOps Principles to Security, DevOpsDays Austin 2012
PDF
Op2423922398
PPT
Dr. Jekyll and Mr. Hyde
PPT
SQLCLR For DBAs and Developers
SQL Injection Attacks: Is Your Data Secure?
Web security
Sql server security in an insecure world
Sql injection whitepaper
Sql injection
Unsafe Deserialization Attacks In Java and A New Approach To Protect The JVM ...
Cyber crime an eye opener 144 te 2 t-7
Luis Grangeia IBWAS
IBWAS 2010: Web Security From an Auditor's Standpoint
Sql injections (Basic bypass authentication)
csf_ppt.pptx
Practical Approach towards SQLi ppt
Geek Sync | Field Medic’s Guide to Database Mirroring
Java application security the hard way - a workshop for the serious developer
Application Security 101 (OWASP DC)
How to Destroy a Database
DevOpsSec: Appling DevOps Principles to Security, DevOpsDays Austin 2012
Op2423922398
Dr. Jekyll and Mr. Hyde
SQLCLR For DBAs and Developers
Ad

More from Bert Wagner (7)

PPTX
DBAs vs Developers - JSON in SQL Server
PPTX
DBAs vs Developers: JSON in SQL Server - CBusPASS
PPTX
High Performance SSRS
PPTX
DBAs vs Developers: JSON in SQL Server
PPTX
JSON in SQL Server 2016
PDF
Json usage and performance in sql server 2016
PDF
High Performance SSRS
DBAs vs Developers - JSON in SQL Server
DBAs vs Developers: JSON in SQL Server - CBusPASS
High Performance SSRS
DBAs vs Developers: JSON in SQL Server
JSON in SQL Server 2016
Json usage and performance in sql server 2016
High Performance SSRS

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Electronic commerce courselecture one. Pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
sap open course for s4hana steps from ECC to s4
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
cuic standard and advanced reporting.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPT
Teaching material agriculture food technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
A Presentation on Artificial Intelligence
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
NewMind AI Weekly Chronicles - August'25-Week II
Diabetes mellitus diagnosis method based random forest with bat algorithm
Electronic commerce courselecture one. Pdf
Programs and apps: productivity, graphics, security and other tools
Dropbox Q2 2025 Financial Results & Investor Presentation
sap open course for s4hana steps from ECC to s4
“AI and Expert System Decision Support & Business Intelligence Systems”
cuic standard and advanced reporting.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Teaching material agriculture food technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MYSQL Presentation for SQL database connectivity
Digital-Transformation-Roadmap-for-Companies.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Advanced methodologies resolving dimensionality complications for autism neur...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Assigned Numbers - 2025 - Bluetooth® Document
A Presentation on Artificial Intelligence
Reach Out and Touch Someone: Haptics and Empathic Computing
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

SQL Injection Attacks: Is Your Data Secure? .NET Edition

  • 1. SQL Injection Attacks: Is Your Data Secure? Cleveland C#/VB.Net User Group | Bert Wagner | February 22, 2018
  • 2. Objective SQL injection prevention does not have an “easy” solution
  • 3. Disclaimers • Try this at home • Not at work • Not on other people’s systems
  • 4. Background • Business Intelligence Developer • Tech security enthusiast • Saw my first injection attempts in ~2001 – MySQL logs Demo code and slides available at bertwagner.com
  • 5. Overview 1. Importance of SQL injection protection 2. Dynamic SQL 3. What does SQL injection look like? 4. Common misconceptions 5. Preventing SQL injection
  • 6. • Data Leaks • Data Validity • Server Availability
  • 7. Dynamic SQL “Just because you can, doesn’t mean you should.” • Can’t parameterize everything • Adaptable Queries • Performance However…
  • 8. What is SQL Injection? • Dynamic string execution • Unsanitized input (could be from a column or parameter) • Performing something the query wasn’t originally intended to do
  • 9. What is SQL Injection? Concatenating a parameter into our query string
  • 10. What is SQL Injection? SQL injection can occur without concatenated parameters too
  • 11. Let’s go back to 1998…
  • 14. Common Misconceptions “The structure of my database isn’t public” You don’t have a Users table? Products? Inventory? etc... “The Amazing Bert”
  • 15. Common Misconceptions “I obfuscate my table names” sys.objects? Errors displayed in app? Logs, emails, social engineering…?
  • 16. Common Misconceptions “Isn’t it the DBAs job to protect the database?” True. But multiple layers of security are better than one. Front end validation doesn’t stop malicious users Server side validation does
  • 17. Common Misconceptions “I’m not important enough to get hacked” Automated injection tools target everyone https://github.com/sqlmapproject/sqlmap/wiki/Techniques
  • 18. Common Misconceptions “I use an ORM to code my SQL queries” ORMs are still vulnerable if you need to pass an argument that can’t be parameterized by SQL Server or if you use a vulnerable stored procedure Other libraries, like the LINQ Dynamic Query Library, try to mitigate this but are also not perfect https://stackoverflow.com/questions/8738953/is-injection-possible-through-dynamic-linq
  • 19. Protecting Against SQL Injection Must take a multi-layered approach. Demos: • Don’t write dynamic SQL • sp_executesql • QUOTENAME() • REPLACE() • EXECUTE AS • Limit inputs • Homoglyph attacks • Proactively find injection vulnerabilities
  • 20. Other Tools • sqlmap • Azure SQL • Continuous monitoring tools • Troy Hunt’s “hackable” website: https://hackyourselffirst.troyhunt.com/
  • 21. Recap • No easy, single-approach solution • Validate, sanitize, escape • Developers and DBAs both responsible • Limit executing account privileges • Use other software to help test, find vulnerabilities

Editor's Notes

  • #12: Hard to pin point exactly who first discovered SQL injection. DO know that in 1998 already appearing in hacker zines. This examples is showing a SQL query that’s variabalized in some app code
  • #13: - Web 2.0, shiny buttons and every company trying to make money online. Problem was, no one knew how to do security. Unless you had a really security conscious developer, you were out of luck. Open Web Application Security Project was formed because a group of people realized needed to create education, information about the types of attacks out there. Put together top 10 list In the initial years, these ranked by guessing/first hand experience – no statistics available SQL and other injection attacks ranked as #6.