SlideShare a Scribd company logo
1 of 51
Download to read offline
Security in PHP Applications:
An absolute must!
Mark Niebergall
About Mark Niebergall
● PHP since 2005
● MS degree in MIS
● Senior Software Engineer
● UPHPU President
● SSCP, CSSLP Certified and SME for (ISC)2
● Drones, fishing, skiing, father, husband
Security Landscape
● Constant attacks: http://map.norsecorp.com/
● Targeting all organizations
● Script kiddies, collectives, nation states,
crackers, thieves, colleagues, insiders,
creative users, and many more
Notable Attacks
● IHG hotels
● Tax returns
● Card skimmers, chip-based cards
● DNC, NRSC
● San Francisco Rail
● UK NHS
Notable Attacks
● Target
● Home Depot
● Sony Pictures
● Anthem
● JP Morgan Chase
● MySpace
● Sony PSN
● Xbox Live
Tech Attacks
● Yahoo!
● IoT devices
○ KrebsOnSecurity.com
○ Dyn DDoS
● Mt. Gox
● Mozilla
● Slack
● Github
PHP Version
PHP Version
● December 2014: only 25.94% of PHP
installs were secure based on PHP version
● Check your version, upgrade to safe version
● Anthony Ferrara
http://blog.ircmaxell.com/2014/12/php-install-
statistics.html
No Organization is Immune
Security Topics Covered
● SQL injection
● Cross-site scripting (XSS)
● Cross-Site Request Forgery (CSRF)
● Authentication and authorization
● Data validation
● Data integrity
SQL Injection
SQL Injection
● SELECT * FROM users WHERE id = $id
● $id = ‘15; UPDATE users SET enabled = 1’
● $this->getDb()->select()->from(‘users’,
‘username’, [‘user_id = ?’ => $id])
SQL Injection
● UPDATE product
SET cost = $_GET[‘cost’]
WHERE id = $_GET[‘id’]
● cost = ‘0.01’
● id = ‘1 OR 1=1’
● $this->getDb()->update(‘product’, [‘cost’ =>
$cost], [‘id = ?’ => $id]);
SQL Injection
● Use prepared statements (PDO, framework)
● Consider misuses
● Validate data
● Use database features when applicable
○ Views
○ Stored Procedures
○ Functions
○ CTE
XSS
XSS
http://www.acunetix.com/blog/articles/blind-xss/
XSS
● Form of code injection
● Attacker injects malicious script into a site
● Malicious script is sent to different user
● Persistent vs Reflected (non-persistent)
● Server vs Client
XSS
● <script>window.location.href=‘http://youtube.
com’</script>
● <script src="http://badsite.com/stealData.js">
XSS
● Send private data to attacker
● Redirect to malicious site
● Perform malicious operation
XSS
● Filter inbound data
○ filter_input for content
○ data validation
● Escape view data
○ strip_tags($string, [$allowedTags])
● Remove unwanted characters http://ascii.cl/
CSRF
CSRF
https://www.incapsula.com/web-application-security/cross-site-scripting-xss-attacks.html
CSRF
● Attacker causes unauthorized code
execution on a web browser against a target
● Target user is unaware of attack
● Target site performs an action
CSRF
● Target logged in on different browser tab
● Hidden form to transfer money to a bank
account
● API to delete accounts
● Perform desired actions that only
authenticated and authorized users can
CSRF
● Referer
● CSRF tokens
● Double Cookie Defense
● Encrypted token pattern
● Custom headers
● CAPTCHA
● Re-authentication
Authentication and Authorization
Authentication and Authorization
● Authentication: user is who they say they are
● Authorization: user has access to resource
Authentication and Authorization
● $_SESSION[‘user’] vs $_COOKIE[‘user’]
● javascript:document.cookie="user=admin"
● https://yoursite.com/users.php?id=7
Authentication and Authorization
● Do not trust data that can be altered by user
○ GET
○ POST
○ COOKIE
○ SERVER
○ ENV
Authentication and Authorization
● Sessions and tokens
● Automatic logouts
● Auditing
Authentication and Authorization
● Never assume user has authorization
● Check values from user
● Considerations for authorization
○ Can user gain access to personal or sensitive data
○ Can user change user ‘admin’ email and password
○ Can user manipulate DOM
○ Can user use SQL injection to get unauthorized data
○ Can user use XSS or CSRF
○ Can user see detailed technical errors
Authentication and Authorization
Data Validation
Data Validation
● Ensure data is clean, correct, and useful
Data Validation
● Data type
○ Integer
○ Float
○ String
○ Date
Data Validation
● Range and constraint
○ Minimum
○ Maximum
○ Length
○ Matches regular expression
Data Validation
● Code and cross-reference
○ Data is useful
○ Database constraints
Data Validation
● Structured validation
○ Data type
○ Conditional requirements
○ Data object
Data Integrity
Data Integrity
● Foreign keys to ensure relational data is
created and kept accurately
● Unique keys to prevent data duplication
● Avoid data corruption and data loss
● Normalization
Data Integrity
● Stability
● Performance
● Re-usability
● Maintainability
● Applies to both database and application
Development Life Cycle
Development Life Cycle
● Analyze application security needs
● Threat modeling
● Risk acceptance level
● Security considerations in requirements
● Project management and developers need
to work closely
Development Life Cycle
● Security testing for acceptance
● Code reviews
● Regular review of security landscape and
emerging threats
● Identify weakest points and make a plan to
strengthen those areas
Convince Management to Invest
Convince Management to Invest
● Explain benefits of investment
○ Brand value
○ Customer loyalty
○ Selling point
● Discuss applicable regulations
● Visibility into current security posture
● Plans and goals
● Get the right people involved
Conclusion
Resources
● Anthony Ferrara
http://blog.ircmaxell.com/2014/12/php-install-statistics.html
● XSS https://www.owasp.org/index.php/XSS
● CSRF https://www.owasp.org/index.php/CSRF
● Php.net
● http://www.acunetix.com/blog/articles/blind-xss/
● https://www.incapsula.com/web-application-security/cross-site-scripting-xs
s-attacks.html
Questions?

More Related Content

What's hot

What's hot (11)

Trusted Types and the end of DOM XSS
Trusted Types and the end of DOM XSSTrusted Types and the end of DOM XSS
Trusted Types and the end of DOM XSS
 
SMIMP Lightning Talk - DEFCON CryptoVillage
SMIMP Lightning Talk - DEFCON CryptoVillageSMIMP Lightning Talk - DEFCON CryptoVillage
SMIMP Lightning Talk - DEFCON CryptoVillage
 
Seyfullah Kilic - Hacking Cryptocurrency Miners with OSINT Techniques
Seyfullah Kilic - Hacking Cryptocurrency Miners with OSINT TechniquesSeyfullah Kilic - Hacking Cryptocurrency Miners with OSINT Techniques
Seyfullah Kilic - Hacking Cryptocurrency Miners with OSINT Techniques
 
Trusted Types @ W3C TPAC 2018
Trusted Types @ W3C TPAC 2018Trusted Types @ W3C TPAC 2018
Trusted Types @ W3C TPAC 2018
 
HTML5 Messaging (Post Message)
HTML5 Messaging (Post Message)HTML5 Messaging (Post Message)
HTML5 Messaging (Post Message)
 
Building your own web based Authenticator
Building your own web based AuthenticatorBuilding your own web based Authenticator
Building your own web based Authenticator
 
Making a SOC Analyst
Making a SOC AnalystMaking a SOC Analyst
Making a SOC Analyst
 
Let's Encrypt
Let's EncryptLet's Encrypt
Let's Encrypt
 
Well-Intentioned Paper Tigers - Misconceptions and Knowledge Gaps in Security
Well-Intentioned Paper Tigers - Misconceptions and Knowledge Gaps in SecurityWell-Intentioned Paper Tigers - Misconceptions and Knowledge Gaps in Security
Well-Intentioned Paper Tigers - Misconceptions and Knowledge Gaps in Security
 
Cryptography
CryptographyCryptography
Cryptography
 
Cryptography & Distributed Systems
Cryptography & Distributed SystemsCryptography & Distributed Systems
Cryptography & Distributed Systems
 

Similar to Security in PHP Applications: An absolute must!

Course_Presentation cyber --------------.pptx
Course_Presentation cyber --------------.pptxCourse_Presentation cyber --------------.pptx
Course_Presentation cyber --------------.pptx
ssuser020436
 

Similar to Security in PHP Applications: An absolute must! (20)

Security .NET.pdf
Security .NET.pdfSecurity .NET.pdf
Security .NET.pdf
 
Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)
 
MobSecCon 2015 - Burning Marshmallows
MobSecCon 2015 - Burning Marshmallows MobSecCon 2015 - Burning Marshmallows
MobSecCon 2015 - Burning Marshmallows
 
Threat Modeling Using STRIDE
Threat Modeling Using STRIDEThreat Modeling Using STRIDE
Threat Modeling Using STRIDE
 
Course_Presentation cyber --------------.pptx
Course_Presentation cyber --------------.pptxCourse_Presentation cyber --------------.pptx
Course_Presentation cyber --------------.pptx
 
Security by Design: An Introduction to Drupal Security
Security by Design: An Introduction to Drupal SecuritySecurity by Design: An Introduction to Drupal Security
Security by Design: An Introduction to Drupal Security
 
Security by design: An Introduction to Drupal Security
Security by design: An Introduction to Drupal SecuritySecurity by design: An Introduction to Drupal Security
Security by design: An Introduction to Drupal Security
 
Application Security - Your Success Depends on it
Application Security - Your Success Depends on itApplication Security - Your Success Depends on it
Application Security - Your Success Depends on it
 
Cloud Security Introduction
Cloud Security IntroductionCloud Security Introduction
Cloud Security Introduction
 
Coding Security: Code Mania 101
Coding Security: Code Mania 101Coding Security: Code Mania 101
Coding Security: Code Mania 101
 
Neoito — Secure coding practices
Neoito — Secure coding practicesNeoito — Secure coding practices
Neoito — Secure coding practices
 
Higher Level Malware
Higher Level MalwareHigher Level Malware
Higher Level Malware
 
Tuenti: Web Application Security
Tuenti: Web Application SecurityTuenti: Web Application Security
Tuenti: Web Application Security
 
Tuenti: Web Application Security
Tuenti: Web Application SecurityTuenti: Web Application Security
Tuenti: Web Application Security
 
Introduction to Web Application Security - Blackhoodie US 2018
Introduction to Web Application Security - Blackhoodie US 2018Introduction to Web Application Security - Blackhoodie US 2018
Introduction to Web Application Security - Blackhoodie US 2018
 
Adversary Playbook Tactical Assessment of Protection Techniques
Adversary Playbook Tactical Assessment of Protection TechniquesAdversary Playbook Tactical Assessment of Protection Techniques
Adversary Playbook Tactical Assessment of Protection Techniques
 
Cassandra Lunch #90: Securing Apache Cassandra
Cassandra Lunch #90: Securing Apache CassandraCassandra Lunch #90: Securing Apache Cassandra
Cassandra Lunch #90: Securing Apache Cassandra
 
APIsecure 2023 - API Security - doing more with less, Nir Paz (Standard.ai)
APIsecure 2023 - API Security - doing more with less, Nir Paz (Standard.ai)APIsecure 2023 - API Security - doing more with less, Nir Paz (Standard.ai)
APIsecure 2023 - API Security - doing more with less, Nir Paz (Standard.ai)
 
Ethical Hacker Training.pdf
Ethical Hacker Training.pdfEthical Hacker Training.pdf
Ethical Hacker Training.pdf
 
Secure Developer Access at Decisiv
Secure Developer Access at DecisivSecure Developer Access at Decisiv
Secure Developer Access at Decisiv
 

More from Mark Niebergall

More from Mark Niebergall (20)

Filesystem Management with Flysystem - php[tek] 2023
Filesystem Management with Flysystem - php[tek] 2023Filesystem Management with Flysystem - php[tek] 2023
Filesystem Management with Flysystem - php[tek] 2023
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023
 
Filesystem Management with Flysystem at PHP UK 2023
Filesystem Management with Flysystem at PHP UK 2023Filesystem Management with Flysystem at PHP UK 2023
Filesystem Management with Flysystem at PHP UK 2023
 
Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022
 
Developing SOLID Code
Developing SOLID CodeDeveloping SOLID Code
Developing SOLID Code
 
Unit Testing from Setup to Deployment
Unit Testing from Setup to DeploymentUnit Testing from Setup to Deployment
Unit Testing from Setup to Deployment
 
Stacking Up Middleware
Stacking Up MiddlewareStacking Up Middleware
Stacking Up Middleware
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and Behat
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and Behat
 
Hacking with PHP
Hacking with PHPHacking with PHP
Hacking with PHP
 
Relational Database Design Bootcamp
Relational Database Design BootcampRelational Database Design Bootcamp
Relational Database Design Bootcamp
 
Starting Out With PHP
Starting Out With PHPStarting Out With PHP
Starting Out With PHP
 
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
 
Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018
 
Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018
 
Defensive Coding Crash Course Tutorial
Defensive Coding Crash Course TutorialDefensive Coding Crash Course Tutorial
Defensive Coding Crash Course Tutorial
 
Inheritance: Vertical or Horizontal
Inheritance: Vertical or HorizontalInheritance: Vertical or Horizontal
Inheritance: Vertical or Horizontal
 
Cybersecurity State of the Union
Cybersecurity State of the UnionCybersecurity State of the Union
Cybersecurity State of the Union
 
Cryptography With PHP - ZendCon 2017 Workshop
Cryptography With PHP - ZendCon 2017 WorkshopCryptography With PHP - ZendCon 2017 Workshop
Cryptography With PHP - ZendCon 2017 Workshop
 
Defensive Coding Crash Course - ZendCon 2017
Defensive Coding Crash Course - ZendCon 2017Defensive Coding Crash Course - ZendCon 2017
Defensive Coding Crash Course - ZendCon 2017
 

Recently uploaded

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Recently uploaded (20)

Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 

Security in PHP Applications: An absolute must!