SlideShare a Scribd company logo
1 of 37
PHP Security
Two Golden Rules ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Two Golden Rules PHP Script Filter Escape Cookie Forms Referer, etc. xhtml MYSQL
Filtering ,[object Object],[object Object],[object Object]
Filter example $clean =  array (); if ( ctype_alnum ($_POST[ 'username' ])) { $clean[ 'username' ] = $_POST[ 'username' ]; }
Filter example $clean =  array (); if ( ctype_alnum ($_POST[ 'username' ])) { $clean[ 'username' ] = $_POST[ 'username' ]; } $clean =  array (); Initialise an array to store filtered data.
Filter example $clean =  array (); if ( ctype_alnum ($_POST[ 'username' ])) { $clean[ 'username' ] = $_POST[ 'username' ]; } if ( ctype_alnum ($_POST[ 'username' ])) Inspect username to make sure that it is alphanumeric.
Filter example $clean =  array (); if ( ctype_alnum ($_POST[ 'username' ])) { $clean[ 'username' ] = $_POST[ 'username' ]; } $clean[ 'username' ] = $_POST[ 'username' ]; If it is, store it in the array.
Escaping Output ,[object Object],[object Object],[object Object]
Escape example $xhtml =  array (); $xhtml[ 'username' ] =  htmlentities ($clean[ 'username' ], ENT_QUOTES , 'UTF-8' ); echo   &quot;<p>Welcome back,  {$xhtml[ 'username' ]} .</p>&quot; ;
Escape example $xhtml =  array (); $xhtml[ 'username' ] =  htmlentities ($clean[ 'username' ], ENT_QUOTES , 'UTF-8' ); echo   &quot;<p>Welcome back,  {$xhtml[ 'username' ]} .</p>&quot; ; $xhtml =  array (); Initialize an array for storing escaped data.
Escape example $xhtml =  array (); $xhtml[ 'username' ] =  htmlentities ($clean[ 'username' ], ENT_QUOTES , 'UTF-8' ); echo   &quot;<p>Welcome back,  {$xhtml[ 'username' ]} .</p>&quot; ; $xhtml[ 'username' ] =  htmlentities ($clean[ 'username' ], ENT_QUOTES , 'UTF-8' ); Escape the filtered username, and store it in the array.
Escape example $xhtml =  array (); $xhtml[ 'username' ] =  htmlentities ($clean[ 'username' ], ENT_QUOTES , 'UTF-8' ); echo   &quot;<p>Welcome back,  {$xhtml[ 'username' ]} .</p>&quot; ; echo   &quot;<p>Welcome back,  {$xhtml[ 'username' ]} .</p>&quot; ; Send the filtered and escaped username to the client.
That’s it! ,[object Object],[object Object],[object Object]
Register Globals: Eh? ,[object Object],[object Object],[object Object],[object Object],[object Object]
Register Globals: Example ,[object Object],[object Object],[object Object],[object Object]
Register Globals: Solution ,[object Object],[object Object]
Spoofed Forms: Eh? ,[object Object],[object Object]
Spoofed Forms: Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Spoofed Forms: Solution ,[object Object],[object Object]
Session Fixation: Eh? ,[object Object],[object Object]
Session Fixation: Eh? ,[object Object],…  < a href=“http://example.com/index.php ?PHPSESSID=1234 ” …
Session Fixation: Eh? ,[object Object],[object Object],[object Object]
Session Fixation: Solution ,[object Object],[object Object]
Session Fixation: Solution ,[object Object],[object Object]
SQL Injection: Eh? ,[object Object]
SQL Injection: Example ,[object Object],[object Object],[object Object]
SQL Injection: Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SQL Injection: Solution ,[object Object],[object Object],[object Object]
Accessing Credentials ,[object Object],[object Object]
Accessing Credentials ,[object Object],[object Object],[object Object],[object Object],best worst
Cross-Site Scripting (XSS) ,[object Object],[object Object],[object Object]
XXS: The Solution ,[object Object],[object Object],[object Object],[object Object]
The ‘magic’ of PHP ,[object Object],[object Object],[object Object]
The ‘magic’ of PHP: banished! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Phew.. But don’t panic! ,[object Object],[object Object]
Review ,[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

What's hot (18)

What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3
 
Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5Go OO! - Real-life Design Patterns in PHP 5
Go OO! - Real-life Design Patterns in PHP 5
 
XML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARXML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEAR
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
 
Intro to Php Security
Intro to Php SecurityIntro to Php Security
Intro to Php Security
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
Web Security - Hands-on
Web Security - Hands-onWeb Security - Hands-on
Web Security - Hands-on
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
 
Data Types In PHP
Data Types In PHPData Types In PHP
Data Types In PHP
 
User authentication module using php
User authentication module using phpUser authentication module using php
User authentication module using php
 
Jquery 4
Jquery 4Jquery 4
Jquery 4
 
Solr's Search Relevancy (Understand Solr's query debug)
Solr's Search Relevancy (Understand Solr's query debug)Solr's Search Relevancy (Understand Solr's query debug)
Solr's Search Relevancy (Understand Solr's query debug)
 
FYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III JavascriptFYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III Javascript
 
Phphacku iitd
Phphacku iitdPhphacku iitd
Phphacku iitd
 
Inroduction to XSLT with PHP4
Inroduction to XSLT with PHP4Inroduction to XSLT with PHP4
Inroduction to XSLT with PHP4
 
Jsp And Jdbc
Jsp And JdbcJsp And Jdbc
Jsp And Jdbc
 
Php MySql For Beginners
Php MySql For BeginnersPhp MySql For Beginners
Php MySql For Beginners
 

Similar to 12-security.ppt - PHP and Arabic Language - Index

Website Security
Website SecurityWebsite Security
Website Security
Carlos Z
 
Php My Sql Security 2007
Php My Sql Security 2007Php My Sql Security 2007
Php My Sql Security 2007
Aung Khant
 
Joomla security nuggets
Joomla security nuggetsJoomla security nuggets
Joomla security nuggets
guestbd1cdca
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
mirahman
 
Eight simple rules to writing secure PHP programs
Eight simple rules to writing secure PHP programsEight simple rules to writing secure PHP programs
Eight simple rules to writing secure PHP programs
Aleksandr Yampolskiy
 
Open Source Package Php Mysql 1228203701094763 9
Open Source Package Php Mysql 1228203701094763 9Open Source Package Php Mysql 1228203701094763 9
Open Source Package Php Mysql 1228203701094763 9
isadorta
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kian
phelios
 

Similar to 12-security.ppt - PHP and Arabic Language - Index (20)

Concern of Web Application Security
Concern of Web Application SecurityConcern of Web Application Security
Concern of Web Application Security
 
Php security3895
Php security3895Php security3895
Php security3895
 
2009 Barcamp Nashville Web Security 101
2009 Barcamp Nashville   Web Security 1012009 Barcamp Nashville   Web Security 101
2009 Barcamp Nashville Web Security 101
 
Website Security
Website SecurityWebsite Security
Website Security
 
Website Security
Website SecurityWebsite Security
Website Security
 
SQL Injection in PHP
SQL Injection in PHPSQL Injection in PHP
SQL Injection in PHP
 
secure php
secure phpsecure php
secure php
 
Sql Injection Attacks Siddhesh
Sql Injection Attacks SiddheshSql Injection Attacks Siddhesh
Sql Injection Attacks Siddhesh
 
Php My Sql Security 2007
Php My Sql Security 2007Php My Sql Security 2007
Php My Sql Security 2007
 
Joomla security nuggets
Joomla security nuggetsJoomla security nuggets
Joomla security nuggets
 
General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Security
 
Web Security
Web SecurityWeb Security
Web Security
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
 
PHP Security
PHP SecurityPHP Security
PHP Security
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And Anish
 
PHP Secure Programming
PHP Secure ProgrammingPHP Secure Programming
PHP Secure Programming
 
Eight simple rules to writing secure PHP programs
Eight simple rules to writing secure PHP programsEight simple rules to writing secure PHP programs
Eight simple rules to writing secure PHP programs
 
Open Source Package Php Mysql 1228203701094763 9
Open Source Package Php Mysql 1228203701094763 9Open Source Package Php Mysql 1228203701094763 9
Open Source Package Php Mysql 1228203701094763 9
 
SQL Injection Attacks
SQL Injection AttacksSQL Injection Attacks
SQL Injection Attacks
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kian
 

More from webhostingguy

Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
webhostingguy
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
webhostingguy
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
webhostingguy
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
webhostingguy
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
webhostingguy
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreement
webhostingguy
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
webhostingguy
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
webhostingguy
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
webhostingguy
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
webhostingguy
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
webhostingguy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
webhostingguy
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
webhostingguy
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
webhostingguy
 

More from webhostingguy (20)

File Upload
File UploadFile Upload
File Upload
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreement
 
Notes8
Notes8Notes8
Notes8
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
 
OLUG_xen.ppt
OLUG_xen.pptOLUG_xen.ppt
OLUG_xen.ppt
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
 
Reseller's Guide
Reseller's GuideReseller's Guide
Reseller's Guide
 

12-security.ppt - PHP and Arabic Language - Index

  • 2.
  • 3. Two Golden Rules PHP Script Filter Escape Cookie Forms Referer, etc. xhtml MYSQL
  • 4.
  • 5. Filter example $clean = array (); if ( ctype_alnum ($_POST[ 'username' ])) { $clean[ 'username' ] = $_POST[ 'username' ]; }
  • 6. Filter example $clean = array (); if ( ctype_alnum ($_POST[ 'username' ])) { $clean[ 'username' ] = $_POST[ 'username' ]; } $clean = array (); Initialise an array to store filtered data.
  • 7. Filter example $clean = array (); if ( ctype_alnum ($_POST[ 'username' ])) { $clean[ 'username' ] = $_POST[ 'username' ]; } if ( ctype_alnum ($_POST[ 'username' ])) Inspect username to make sure that it is alphanumeric.
  • 8. Filter example $clean = array (); if ( ctype_alnum ($_POST[ 'username' ])) { $clean[ 'username' ] = $_POST[ 'username' ]; } $clean[ 'username' ] = $_POST[ 'username' ]; If it is, store it in the array.
  • 9.
  • 10. Escape example $xhtml = array (); $xhtml[ 'username' ] = htmlentities ($clean[ 'username' ], ENT_QUOTES , 'UTF-8' ); echo &quot;<p>Welcome back, {$xhtml[ 'username' ]} .</p>&quot; ;
  • 11. Escape example $xhtml = array (); $xhtml[ 'username' ] = htmlentities ($clean[ 'username' ], ENT_QUOTES , 'UTF-8' ); echo &quot;<p>Welcome back, {$xhtml[ 'username' ]} .</p>&quot; ; $xhtml = array (); Initialize an array for storing escaped data.
  • 12. Escape example $xhtml = array (); $xhtml[ 'username' ] = htmlentities ($clean[ 'username' ], ENT_QUOTES , 'UTF-8' ); echo &quot;<p>Welcome back, {$xhtml[ 'username' ]} .</p>&quot; ; $xhtml[ 'username' ] = htmlentities ($clean[ 'username' ], ENT_QUOTES , 'UTF-8' ); Escape the filtered username, and store it in the array.
  • 13. Escape example $xhtml = array (); $xhtml[ 'username' ] = htmlentities ($clean[ 'username' ], ENT_QUOTES , 'UTF-8' ); echo &quot;<p>Welcome back, {$xhtml[ 'username' ]} .</p>&quot; ; echo &quot;<p>Welcome back, {$xhtml[ 'username' ]} .</p>&quot; ; Send the filtered and escaped username to the client.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.