SlideShare a Scribd company logo
Vulnerable Active Record
A tale of SQL Injection in PHP Framework
pichaya@ieee.org
fb.com/index.htmli
linkedin.com/in/pich4ya
Pichaya Morimoto
Thailand PHP User Group Meetup
January 28, 2015
★ What is Active Record ?
★ Secure by Design ?
★ Case Studies
★ Exploitation
★ Input Validation
★ Defence-in-Depth
★ Conclusion
Overview
Active record pattern is an approach to accessing data in a
database. A database table or view is wrapped into a class. Thus,
an object instance is tied to row(s) in the table.
PHP frameworks also bundle their own ORM implementing
the active record pattern. For example, Laravel (Eloquent),
CakePHP, Symfony (Doctrine), CodeIgniter and Yii.
$query = $this->db->select('title, content, date');
$query->from('table1');
$query->where('id', $id);
$query->get();
Source: https://en.wikipedia.org/wiki/Active_record_pattern
What is Active Record ?
Secure by Design ?
That’s Magic !
Case Study #1
Get rows from
table ‘news’ and
order by user input
‘sort’
PHP Framework:
CodeIgniter 2.2
Hacker is here, where is SQLi ?
SQLMap == Failed
Acunetix == Failed
Havij == Failed
‘ or ‘1’=’1 , union all select blah
blah blah == Failed
SQL Injection Pwnage
Pwned !
What if error message is turned off, is it still vulnerable?
Ads: http://slideshare.net/pichayaa/sql-injection-owaspthailand
Stand back I know secure coding!
No more
SQL
Injection
with
Type
Validation !
Case Study #2
Secure Coding !!
Keep calm and Think Again
Numeric = [Integer, Double, Hex, ...]
id value above is hex encoded of “1 and 1>2 union select
CHAR(32,58,32),user(),database(),version(),concat_ws
(0x3a,username,password) from ci220news_db” + data
field is varchar type ***
A list of security techniques that should be included in every software
development project.
★ Parameterize Queries
★ Implement Logging, Error Handling and Intrusion Detection
★ Leverage Security Features of Frameworks and Security Libraries
and more..
https://www.owasp.org /index.php/OWASP_Proactive_Controls
OWASP Proactive Controls
ProTip: PHP is not allowed to parameterize
‘Order By’ clause ;)
Because it isn’t data, it is a column name!
A layered approach to security can be implemented
at any level of a complete information security
strategy.
★ Secure Coding in software requirement
★ OS Hardening, reduce attack surface
★ Perimeter Security (Network Firewall, IPS/IDS)
★ Centralized Log Server / SIEM
★ Patch / Vulnerability Management System
★ Incident Response Plans
★ Web Application Firewall
Source: http://techrepublic.com/blog/it-security/understanding-layered-security-and-defense-in-depth/
Defence-in-Depth
Security Today
!==
Security Tomorrow
Conclusion
http://framework.zend.com/security/advisory/ZF2014-04
http://bakery.cakephp.
org/articles/markstory/2013/04/28/security_release_-
_cakephp_1_2_12_1_3_16_2_2_8_and_2_3_4

More Related Content

PDF
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
PPTX
SQL Injections and Behind...
PPT
How To Detect Xss
PDF
Web Security attacks and defense
PPTX
Secure Programming In Php
PPTX
SQL Injection Defense in Python
PDF
Sql Injection and XSS
PDF
SQL Injection: complete walkthrough (not only) for PHP developers
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injections and Behind...
How To Detect Xss
Web Security attacks and defense
Secure Programming In Php
SQL Injection Defense in Python
Sql Injection and XSS
SQL Injection: complete walkthrough (not only) for PHP developers

What's hot (20)

PDF
Sql Injection - Vulnerability and Security
PDF
SQL Injection Attack Detection and Prevention Techniques to Secure Web-Site
PDF
Web Application Security II - SQL Injection
PDF
XSS And SQL Injection Vulnerabilities
PDF
Secure code
PPT
Advanced Sql Injection ENG
PPT
Sql Injection Tutorial!
KEY
SQL Injection - Mozilla Security Learning Center
PPTX
Sql Injection attacks and prevention
PDF
C days2015
PPTX
Owasp Top 10 - A1 Injection
PPT
Advanced Topics On Sql Injection Protection
PPT
SQL Injection
PPT
Sql injection attack
PDF
SQL Injection Tutorial
PPTX
seminar report on Sql injection
PDF
Web Security - OWASP - SQL injection & Cross Site Scripting XSS
PPT
Web application attacks using Sql injection and countermasures
PDF
Advanced SQL Injection: Attacks
PPTX
Owasp Top 10 A1: Injection
Sql Injection - Vulnerability and Security
SQL Injection Attack Detection and Prevention Techniques to Secure Web-Site
Web Application Security II - SQL Injection
XSS And SQL Injection Vulnerabilities
Secure code
Advanced Sql Injection ENG
Sql Injection Tutorial!
SQL Injection - Mozilla Security Learning Center
Sql Injection attacks and prevention
C days2015
Owasp Top 10 - A1 Injection
Advanced Topics On Sql Injection Protection
SQL Injection
Sql injection attack
SQL Injection Tutorial
seminar report on Sql injection
Web Security - OWASP - SQL injection & Cross Site Scripting XSS
Web application attacks using Sql injection and countermasures
Advanced SQL Injection: Attacks
Owasp Top 10 A1: Injection
Ad

Viewers also liked (20)

PDF
Security Misconfiguration (OWASP Top 10 - 2013 - A5)
PPT
D:\Technical\Ppt\Sql Injection
DOCX
Types of sql injection attacks
PPTX
Sql injection
PDF
Extjs presentation
PPTX
CodeIgniter i18n Security Flaw
PPT
XAJA - Reverse AJAX framework
PDF
Exploiting WebApp Race Condition Vulnerability 101
PDF
From Web Vulnerability to Exploit in 15 minutes
PDF
Art of Web Backdoor - Pichaya Morimoto
PPTX
PHP Frameworks, or how I learnt to stop worrying and love the code
PDF
A5-Security misconfiguration-OWASP 2013
PPTX
A5: Security Misconfiguration
PDF
Exploiting Blind Vulnerabilities
PDF
Lithium: The Framework for People Who Hate Frameworks
PDF
How to scale PHP applications
PDF
CTF คืออะไร เรียนแฮก? ลองแฮก? แข่งแฮก?
PPT
Sql injection attacks
PPTX
Sql injection attack_analysis_py_vo
PDF
Metasearch Outlook 2017
Security Misconfiguration (OWASP Top 10 - 2013 - A5)
D:\Technical\Ppt\Sql Injection
Types of sql injection attacks
Sql injection
Extjs presentation
CodeIgniter i18n Security Flaw
XAJA - Reverse AJAX framework
Exploiting WebApp Race Condition Vulnerability 101
From Web Vulnerability to Exploit in 15 minutes
Art of Web Backdoor - Pichaya Morimoto
PHP Frameworks, or how I learnt to stop worrying and love the code
A5-Security misconfiguration-OWASP 2013
A5: Security Misconfiguration
Exploiting Blind Vulnerabilities
Lithium: The Framework for People Who Hate Frameworks
How to scale PHP applications
CTF คืออะไร เรียนแฮก? ลองแฮก? แข่งแฮก?
Sql injection attacks
Sql injection attack_analysis_py_vo
Metasearch Outlook 2017
Ad

Similar to Vulnerable Active Record: A tale of SQL Injection in PHP Framework (20)

PDF
Coding Security: Code Mania 101
PPTX
SQLi for Security Champions
PPT
PHP Security Basics
PDF
Secure coding presentation Oct 3 2020
PPTX
OWASP Top 10 Proactive Controls
PPT
Php & Web Security - PHPXperts 2009
ODP
Database security for PHP
PPTX
OWASP top 10-2013
PDF
Security in PHP Applications: An absolute must!
PPTX
The path of secure software by Katy Anton
PPT
Advanced sql injection
PPSX
Web application security
PDF
How to Destroy a Database
ODP
My app is secure... I think
PDF
sql-inj_attack.pdf
PDF
Injection techniques conversys
PDF
null Bangalore meet - Php Security
PPTX
OWASP Top 10 - Day 1 - A1 injection attacks
PPTX
Database and Database Security..
PDF
Code securely
Coding Security: Code Mania 101
SQLi for Security Champions
PHP Security Basics
Secure coding presentation Oct 3 2020
OWASP Top 10 Proactive Controls
Php & Web Security - PHPXperts 2009
Database security for PHP
OWASP top 10-2013
Security in PHP Applications: An absolute must!
The path of secure software by Katy Anton
Advanced sql injection
Web application security
How to Destroy a Database
My app is secure... I think
sql-inj_attack.pdf
Injection techniques conversys
null Bangalore meet - Php Security
OWASP Top 10 - Day 1 - A1 injection attacks
Database and Database Security..
Code securely

More from Pichaya Morimoto (8)

PDF
ยกระดับศักยภาพของทีม IT Security องค์กรด้วย CTF & Cybersecurity Online Platfo...
PDF
Securing and Hacking LINE OA Integration
PDF
Docker Plugin For DevSecOps
PDF
Mysterious Crypto in Android Biometrics
PDF
Web Hacking with Object Deserialization
PDF
Burp Extender API for Penetration Testing
PDF
Bug Bounty แบบแมว ๆ
PDF
Pentest 101 @ Mahanakorn Network Research Laboratory
ยกระดับศักยภาพของทีม IT Security องค์กรด้วย CTF & Cybersecurity Online Platfo...
Securing and Hacking LINE OA Integration
Docker Plugin For DevSecOps
Mysterious Crypto in Android Biometrics
Web Hacking with Object Deserialization
Burp Extender API for Penetration Testing
Bug Bounty แบบแมว ๆ
Pentest 101 @ Mahanakorn Network Research Laboratory

Recently uploaded (20)

PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Mushroom cultivation and it's methods.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
1. Introduction to Computer Programming.pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Chapter 5: Probability Theory and Statistics
Web App vs Mobile App What Should You Build First.pdf
Hindi spoken digit analysis for native and non-native speakers
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Mushroom cultivation and it's methods.pdf
DP Operators-handbook-extract for the Mautical Institute
NewMind AI Weekly Chronicles - August'25-Week II
WOOl fibre morphology and structure.pdf for textiles
A comparative analysis of optical character recognition models for extracting...
Unlocking AI with Model Context Protocol (MCP)
Zenith AI: Advanced Artificial Intelligence
A novel scalable deep ensemble learning framework for big data classification...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
1. Introduction to Computer Programming.pptx
1 - Historical Antecedents, Social Consideration.pdf
A comparative study of natural language inference in Swahili using monolingua...
MIND Revenue Release Quarter 2 2025 Press Release
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Chapter 5: Probability Theory and Statistics

Vulnerable Active Record: A tale of SQL Injection in PHP Framework

  • 1. Vulnerable Active Record A tale of SQL Injection in PHP Framework pichaya@ieee.org fb.com/index.htmli linkedin.com/in/pich4ya Pichaya Morimoto Thailand PHP User Group Meetup January 28, 2015
  • 2. ★ What is Active Record ? ★ Secure by Design ? ★ Case Studies ★ Exploitation ★ Input Validation ★ Defence-in-Depth ★ Conclusion Overview
  • 3. Active record pattern is an approach to accessing data in a database. A database table or view is wrapped into a class. Thus, an object instance is tied to row(s) in the table. PHP frameworks also bundle their own ORM implementing the active record pattern. For example, Laravel (Eloquent), CakePHP, Symfony (Doctrine), CodeIgniter and Yii. $query = $this->db->select('title, content, date'); $query->from('table1'); $query->where('id', $id); $query->get(); Source: https://en.wikipedia.org/wiki/Active_record_pattern What is Active Record ?
  • 4. Secure by Design ? That’s Magic !
  • 5. Case Study #1 Get rows from table ‘news’ and order by user input ‘sort’ PHP Framework: CodeIgniter 2.2
  • 6. Hacker is here, where is SQLi ? SQLMap == Failed Acunetix == Failed Havij == Failed ‘ or ‘1’=’1 , union all select blah blah blah == Failed
  • 7. SQL Injection Pwnage Pwned ! What if error message is turned off, is it still vulnerable? Ads: http://slideshare.net/pichayaa/sql-injection-owaspthailand
  • 8. Stand back I know secure coding! No more SQL Injection with Type Validation !
  • 10. Keep calm and Think Again Numeric = [Integer, Double, Hex, ...] id value above is hex encoded of “1 and 1>2 union select CHAR(32,58,32),user(),database(),version(),concat_ws (0x3a,username,password) from ci220news_db” + data field is varchar type ***
  • 11. A list of security techniques that should be included in every software development project. ★ Parameterize Queries ★ Implement Logging, Error Handling and Intrusion Detection ★ Leverage Security Features of Frameworks and Security Libraries and more.. https://www.owasp.org /index.php/OWASP_Proactive_Controls OWASP Proactive Controls ProTip: PHP is not allowed to parameterize ‘Order By’ clause ;) Because it isn’t data, it is a column name!
  • 12. A layered approach to security can be implemented at any level of a complete information security strategy. ★ Secure Coding in software requirement ★ OS Hardening, reduce attack surface ★ Perimeter Security (Network Firewall, IPS/IDS) ★ Centralized Log Server / SIEM ★ Patch / Vulnerability Management System ★ Incident Response Plans ★ Web Application Firewall Source: http://techrepublic.com/blog/it-security/understanding-layered-security-and-defense-in-depth/ Defence-in-Depth