SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Concern of Web Application Security ” First and foremost, you must realize and accept that  any user-supplied data is inherently unreliable  and can't be trusted.” Md. Mahmud Ahsan Zend Certified Engineer http://mahmudahsan.wordpress.com/ http://www.ftechdb.com/
Contents of presentation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Security Overview ,[object Object],[object Object],[object Object],What is security?
Security Overview ,[object Object],[object Object],[object Object],[object Object],[object Object],Principles of security?
Best Practice ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Basic Steps
Best Practice Basic Steps
Input filtering ,[object Object],[object Object],[object Object],[object Object],[object Object]
Input filtering Filter input example: <?php $clean = array(); switch($_POST['color']){ case 'red': case 'green': case 'blue': $clean['color'] = $_POST['color']; break; } ?>
Input filtering Filter input example: <?php $clean = array();   switch($_POST['color']){  case 'red': case 'green': case 'blue': $clean['color'] = $_POST['color']; break; } ?> Initialize array for storing filter data
Input filtering Filter input example: <?php $clean = array();  switch($_POST['color']){  case 'red': case 'green': case 'blue': $clean['color'] = $_POST['color']; break; } ?> Use switch statement to filter sets
Input filtering Filter input example: <?php $clean = array();  switch($_POST['color']){   case 'red': case 'green': case 'blue': $clean['color'] = $_POST['color']; break; } ?> Create cases for the valid values
Input filtering Filter input example: <?php $clean = array();  switch($_POST['color']){   case 'red': case 'green': case 'blue': $clean['color'] = $_POST['color']; break; } ?> Color is definately valid so store in the array
Most common attacks Filter input example 2: <?php $clean = array(); if (ctype_alnum($_POST['username'])){ $clean['username'] = $_POST['username']; } ?>
Most common attacks Filter input example 2: <?php $clean = array(); if (ctype_alnum($_POST['username'])){ $clean['username'] = $_POST['username']; } ?> Create an array to store filtered data
Input filtering Filter input example 2: <?php $clean = array(); if (ctype_alnum($_POST['username'])){ $clean['username'] = $_POST['username']; } ?> Username must be  alphanumeric
Input filtering Filter input example 2: <?php $clean = array(); if (ctype_alnum($_POST['username'])){ $clean['username'] = $_POST['username']; } ?> If username is alphanumeric store it in the array
Escaping Output ,[object Object],[object Object],[object Object],[object Object]
Escaping Output ,[object Object],[object Object],[object Object]
Escaping Output Escaping output example: <?php $html = array(); $html['username'] = htmlentities($clean['username'], ENT_QUOTES); echo &quot;<p>Welcome back, {$html['username']}.</p>&quot;; ?>
Escaping Output Escaping output example: <?php $html = array(); $html['username'] = htmlentities($clean['username'], ENT_QUOTES); echo &quot;<p>Welcome back, {$html['username']}.</p>&quot;; ?> Initialize array for storing escaped data
Escaping Output Escaping output example: <?php $html = array(); $html['username'] = htmlentities($clean['username'], ENT_QUOTES); echo &quot;<p>Welcome back, {$html['username']}.</p>&quot;; ?> Escaped the filtered username and store in the array
Escaping Output Escaping output example: <?php $html = array(); $html['username'] = htmlentities($clean['username'], ENT_QUOTES); echo &quot;<p>Welcome back,  {$html['username']} .</p>&quot;; ?> Send the filtered and escaped username to the client
Escaping Output Escaping output example 2: <?php $mysql = array(); $mysql['username'] = mysql_real_escape_string($clean['username']); $sql = &quot;SELECT * FROM profile    WHERE username = '{$mysql['username']}'&quot;; $result = mysql_query($sql); ?>
Escaping Output Escaping output example 2: <?php $mysql = array(); $mysql['username'] = mysql_real_escape_string($clean['username']); $sql = &quot;SELECT * FROM profile    WHERE username = '{$mysql['username']}'&quot;; $result = mysql_query($sql); ?> Initialize an array for storing escaped data
Escaping Output Escaping output example 2: <?php $mysql = array(); $mysql['username'] = mysql_real_escape_string($clean['username']); $sql = &quot;SELECT * FROM profile    WHERE username = '{$mysql['username']}'&quot;; $result = mysql_query($sql); ?> Escaped the filter username and store it in the array
Escaping Output Escaping output example 2: <?php $mysql = array(); $mysql['username'] = mysql_real_escape_string($clean['username']); $sql = &quot;SELECT * FROM profile    WHERE username =  '{$mysql['username']}' &quot;; $result = mysql_query($sql); ?> Use the filtered and escaped username in the SQL query
Escaping Output Escaping output example 2: <?php $mysql = array(); $mysql['username'] = mysql_real_escape_string($clean['username']); $sql = &quot;SELECT * FROM profile    WHERE username = '{$mysql['username']}'&quot;; $result =  mysql_query($sql) ; ?> SQL Query is now safe
SQL Injection ,[object Object],[object Object],[object Object],[object Object],[object Object]
SQL Injection SQL Injection attacking example: http://example.com/db.php?id=0 http://example.com/db.php?id=0 ;DELETE%20FROM%20users <?php $id = $_GET['id']; //  $id = 0;DELETE FROM users $result = mysql_query(&quot;SELECT * FROM  users  WHERE id={$id}&quot;); SQL Inject code User table data destroyed
SQL Injection SQL Injection attacking example 2: <?php $query = &quot;SELECT * FROM users WHERE  user='{$_POST['username']}' AND  password='{$_POST['password']}'&quot;; mysql_query($query); //$_POST['username'] = 'manzil'; //$_POST['password'] = &quot;' OR ''='&quot;; echo $query; ?>   output: SELECT * FROM users  WHERE user='manzil' AND password='' OR ''='' SQL Inject code
SQL Injection SQL Injection Protection: <?php $name = mysql_real_escape_string($_POST['username']); $pass = mysql_real_escape_string($_POST['password']); $query = &quot;SELECT * FROM users WHERE  user='{$name}' AND password='{$pass}'&quot;; mysql_query($query); ?>
Cross-Site Scripting What is XSS ? It is a popular attacking to web application as web application largely echo user input. <?php echo &quot;<p>Welcome back, { $_GET['username'] }.</p>&quot;; ?>
Cross-Site Scripting Attacking Example: <?php echo &quot;<p>Welcome back,  <script> ... </script>  .</p>&quot;; ?> XSS Attacking !!!
Cross-Site Scripting ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Cross-Site Scripting htmlentities(): <?php $name = $_GET['username'];  // <script> ... </script> echo  htmlentities($name, ENT_QUOTES) ; ?> output: &lt;script&gt; ... &lt;/script&gt;
Session Hijacking ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Session Hijacking Example of Session Fixation: http://example.org/login.php?PHPSESSID=1234 Prevention of Session Fixation: Use  session_regenerate_id()  whenever there is a change in the level of privilege: if ($authenticated) { $_SESSION['logged_in'] = TRUE; session_regenerate_id(); }
Session Hijacking Another session security technique: Compare the browser signature headers. <?php session_start(); $chk = @md5( $_SERVER['HTTP_ACCEPT_CHARSET'] . $_SERVER['HTTP_ACCEPT_ENCODING'] . $_SERVER['HTTP_ACCEPT_LANGUAGE'] . $_SERVER['HTTP_USER_AGENT']); if (empty($_SESSION)) $_SESSION['key'] = $chk; else if ( $_SESSION['key'] != $chk ) session_destroy(); ?>
Session Hijacking ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Cross Site Request Forgeries What is CSRF? An attacker can send arbitrary HTTP requests from avictim. Because the requests originate from the victim, they can bypass traditional  safeguards, including firewalls and access control.
Cross Site Request Forgeries ,[object Object],[object Object],[object Object],[object Object]
Cross Site Request Forgeries ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Cross Site Request Forgeries ,[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],[object Object]
Cross Site Request Forgeries ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thank You

Weitere ähnliche Inhalte

Was ist angesagt?

Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
guest5d87aa6
 

Was ist angesagt? (20)

Sorting arrays in PHP
Sorting arrays in PHPSorting arrays in PHP
Sorting arrays in PHP
 
Proposed PHP function: is_literal()
Proposed PHP function: is_literal()Proposed PHP function: is_literal()
Proposed PHP function: is_literal()
 
Top 10 php classic traps php serbia
Top 10 php classic traps php serbiaTop 10 php classic traps php serbia
Top 10 php classic traps php serbia
 
PHP Tutorial (funtion)
PHP Tutorial (funtion)PHP Tutorial (funtion)
PHP Tutorial (funtion)
 
SQL Injection in PHP
SQL Injection in PHPSQL Injection in PHP
SQL Injection in PHP
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
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
 
OWASP TOP 10 for PHP Programmers
OWASP TOP 10 for PHP ProgrammersOWASP TOP 10 for PHP Programmers
OWASP TOP 10 for PHP Programmers
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
 
Open Source Search: An Analysis
Open Source Search: An AnalysisOpen Source Search: An Analysis
Open Source Search: An Analysis
 
Refactoring using Codeception
Refactoring using CodeceptionRefactoring using Codeception
Refactoring using Codeception
 
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
 
Dip Your Toes in the Sea of Security (PHP South Africa 2017)
Dip Your Toes in the Sea of Security (PHP South Africa 2017)Dip Your Toes in the Sea of Security (PHP South Africa 2017)
Dip Your Toes in the Sea of Security (PHP South Africa 2017)
 
Error Reporting in ZF2: form messages, custom error pages, logging
Error Reporting in ZF2: form messages, custom error pages, loggingError Reporting in ZF2: form messages, custom error pages, logging
Error Reporting in ZF2: form messages, custom error pages, logging
 
Climbing the Abstract Syntax Tree (PHP South Africa 2017)
Climbing the Abstract Syntax Tree (PHP South Africa 2017)Climbing the Abstract Syntax Tree (PHP South Africa 2017)
Climbing the Abstract Syntax Tree (PHP South Africa 2017)
 
PHPUnit Episode iv.iii: Return of the tests
PHPUnit Episode iv.iii: Return of the testsPHPUnit Episode iv.iii: Return of the tests
PHPUnit Episode iv.iii: Return of the tests
 
Introduction to Clean Code
Introduction to Clean CodeIntroduction to Clean Code
Introduction to Clean Code
 
Crafting beautiful software
Crafting beautiful softwareCrafting beautiful software
Crafting beautiful software
 
Learning Perl 6 (NPW 2007)
Learning Perl 6 (NPW 2007)Learning Perl 6 (NPW 2007)
Learning Perl 6 (NPW 2007)
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
 

Andere mochten auch

Web application security & Testing
Web application security  & TestingWeb application security  & Testing
Web application security & Testing
Deepu S Nath
 
Wikis and Blogs: When, Why, and How to Use Them
Wikis and Blogs: When, Why, and How to Use ThemWikis and Blogs: When, Why, and How to Use Them
Wikis and Blogs: When, Why, and How to Use Them
LeslieOflahavan
 
2013 01 24 learning sessions 4 presentation meca
2013 01 24 learning sessions 4 presentation   meca2013 01 24 learning sessions 4 presentation   meca
2013 01 24 learning sessions 4 presentation meca
jvielman
 
2012.06.28 Learning Sessions 2 - VBB
2012.06.28 Learning Sessions 2 - VBB2012.06.28 Learning Sessions 2 - VBB
2012.06.28 Learning Sessions 2 - VBB
jvielman
 
Session4 pl online_course_30_september2011
Session4  pl online_course_30_september2011Session4  pl online_course_30_september2011
Session4 pl online_course_30_september2011
LeslieOflahavan
 
AQA English Unit 1 Section B
AQA English Unit 1 Section BAQA English Unit 1 Section B
AQA English Unit 1 Section B
missbec
 
Judaica europeana dovwinerjudaicalibrarians
Judaica europeana dovwinerjudaicalibrariansJudaica europeana dovwinerjudaicalibrarians
Judaica europeana dovwinerjudaicalibrarians
Dov Winer
 

Andere mochten auch (20)

Application development using Zend Framework
Application development using Zend FrameworkApplication development using Zend Framework
Application development using Zend Framework
 
Network Security
Network SecurityNetwork Security
Network Security
 
Web application security: how to start?
Web application security: how to start?Web application security: how to start?
Web application security: how to start?
 
Improving web application security, part ii
Improving web application security, part iiImproving web application security, part ii
Improving web application security, part ii
 
Web application security & Testing
Web application security  & TestingWeb application security  & Testing
Web application security & Testing
 
Majalah INFO-UFO no 04
Majalah INFO-UFO no 04Majalah INFO-UFO no 04
Majalah INFO-UFO no 04
 
Wikis and Blogs: When, Why, and How to Use Them
Wikis and Blogs: When, Why, and How to Use ThemWikis and Blogs: When, Why, and How to Use Them
Wikis and Blogs: When, Why, and How to Use Them
 
Geek Meet - Boot to Gecko: The Future of Mobile?
Geek Meet - Boot to Gecko: The Future of Mobile?Geek Meet - Boot to Gecko: The Future of Mobile?
Geek Meet - Boot to Gecko: The Future of Mobile?
 
Rencana Pembentukan Program Studi Ekonomi ITB
Rencana Pembentukan Program Studi Ekonomi ITBRencana Pembentukan Program Studi Ekonomi ITB
Rencana Pembentukan Program Studi Ekonomi ITB
 
That's not what he said!
That's not what he said!That's not what he said!
That's not what he said!
 
2013 01 24 learning sessions 4 presentation meca
2013 01 24 learning sessions 4 presentation   meca2013 01 24 learning sessions 4 presentation   meca
2013 01 24 learning sessions 4 presentation meca
 
Alexandria winer20100623
Alexandria winer20100623Alexandria winer20100623
Alexandria winer20100623
 
2012.06.28 Learning Sessions 2 - VBB
2012.06.28 Learning Sessions 2 - VBB2012.06.28 Learning Sessions 2 - VBB
2012.06.28 Learning Sessions 2 - VBB
 
ViziCities: Making SimCity for the Real World
ViziCities: Making SimCity for the Real WorldViziCities: Making SimCity for the Real World
ViziCities: Making SimCity for the Real World
 
Samsung mp3 YP-S3
Samsung mp3 YP-S3Samsung mp3 YP-S3
Samsung mp3 YP-S3
 
Hw fdb(2)
Hw fdb(2)Hw fdb(2)
Hw fdb(2)
 
Session4 pl online_course_30_september2011
Session4  pl online_course_30_september2011Session4  pl online_course_30_september2011
Session4 pl online_course_30_september2011
 
AQA English Unit 1 Section B
AQA English Unit 1 Section BAQA English Unit 1 Section B
AQA English Unit 1 Section B
 
YPT10J BENUTZERHANDBUCH
YPT10J BENUTZERHANDBUCHYPT10J BENUTZERHANDBUCH
YPT10J BENUTZERHANDBUCH
 
Judaica europeana dovwinerjudaicalibrarians
Judaica europeana dovwinerjudaicalibrariansJudaica europeana dovwinerjudaicalibrarians
Judaica europeana dovwinerjudaicalibrarians
 

Ähnlich wie Concern of Web Application Security

12-security.ppt - PHP and Arabic Language - Index
12-security.ppt - PHP and Arabic Language - Index12-security.ppt - PHP and Arabic Language - Index
12-security.ppt - PHP and Arabic Language - Index
webhostingguy
 
Php Security3895
Php Security3895Php Security3895
Php Security3895
Aung Khant
 
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
 
Php My Sql Security 2007
Php My Sql Security 2007Php My Sql Security 2007
Php My Sql Security 2007
Aung Khant
 

Ähnlich wie Concern of Web Application Security (20)

12-security.ppt - PHP and Arabic Language - Index
12-security.ppt - PHP and Arabic Language - Index12-security.ppt - PHP and Arabic Language - Index
12-security.ppt - PHP and Arabic Language - Index
 
Security.ppt
Security.pptSecurity.ppt
Security.ppt
 
Php security3895
Php security3895Php security3895
Php security3895
 
PHP Security
PHP SecurityPHP Security
PHP Security
 
Php Security3895
Php Security3895Php Security3895
Php Security3895
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With Php
 
2009 Barcamp Nashville Web Security 101
2009 Barcamp Nashville   Web Security 1012009 Barcamp Nashville   Web Security 101
2009 Barcamp Nashville Web Security 101
 
Ubi comp27nov04
Ubi comp27nov04Ubi comp27nov04
Ubi comp27nov04
 
Web Security Mistakes: Trusting The Client
Web Security Mistakes: Trusting The ClientWeb Security Mistakes: Trusting The Client
Web Security Mistakes: Trusting The Client
 
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
 
Php My Sql
Php My SqlPhp My Sql
Php My Sql
 
General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Security
 
Framework
FrameworkFramework
Framework
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
SQL Injection Part 2
SQL Injection Part 2SQL Injection Part 2
SQL Injection Part 2
 
Php My Sql Security 2007
Php My Sql Security 2007Php My Sql Security 2007
Php My Sql Security 2007
 
Sql Injection Myths and Fallacies
Sql Injection Myths and FallaciesSql Injection Myths and Fallacies
Sql Injection Myths and Fallacies
 
Sql Injection Attacks Siddhesh
Sql Injection Attacks SiddheshSql Injection Attacks Siddhesh
Sql Injection Attacks Siddhesh
 
What's New in ZF 1.10
What's New in ZF 1.10What's New in ZF 1.10
What's New in ZF 1.10
 
PHP Secure Programming
PHP Secure ProgrammingPHP Secure Programming
PHP Secure Programming
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

Concern of Web Application Security

  • 1. Concern of Web Application Security ” First and foremost, you must realize and accept that any user-supplied data is inherently unreliable and can't be trusted.” Md. Mahmud Ahsan Zend Certified Engineer http://mahmudahsan.wordpress.com/ http://www.ftechdb.com/
  • 2.
  • 3.
  • 4.
  • 5.
  • 7.
  • 8. Input filtering Filter input example: <?php $clean = array(); switch($_POST['color']){ case 'red': case 'green': case 'blue': $clean['color'] = $_POST['color']; break; } ?>
  • 9. Input filtering Filter input example: <?php $clean = array(); switch($_POST['color']){ case 'red': case 'green': case 'blue': $clean['color'] = $_POST['color']; break; } ?> Initialize array for storing filter data
  • 10. Input filtering Filter input example: <?php $clean = array(); switch($_POST['color']){ case 'red': case 'green': case 'blue': $clean['color'] = $_POST['color']; break; } ?> Use switch statement to filter sets
  • 11. Input filtering Filter input example: <?php $clean = array(); switch($_POST['color']){ case 'red': case 'green': case 'blue': $clean['color'] = $_POST['color']; break; } ?> Create cases for the valid values
  • 12. Input filtering Filter input example: <?php $clean = array(); switch($_POST['color']){ case 'red': case 'green': case 'blue': $clean['color'] = $_POST['color']; break; } ?> Color is definately valid so store in the array
  • 13. Most common attacks Filter input example 2: <?php $clean = array(); if (ctype_alnum($_POST['username'])){ $clean['username'] = $_POST['username']; } ?>
  • 14. Most common attacks Filter input example 2: <?php $clean = array(); if (ctype_alnum($_POST['username'])){ $clean['username'] = $_POST['username']; } ?> Create an array to store filtered data
  • 15. Input filtering Filter input example 2: <?php $clean = array(); if (ctype_alnum($_POST['username'])){ $clean['username'] = $_POST['username']; } ?> Username must be alphanumeric
  • 16. Input filtering Filter input example 2: <?php $clean = array(); if (ctype_alnum($_POST['username'])){ $clean['username'] = $_POST['username']; } ?> If username is alphanumeric store it in the array
  • 17.
  • 18.
  • 19. Escaping Output Escaping output example: <?php $html = array(); $html['username'] = htmlentities($clean['username'], ENT_QUOTES); echo &quot;<p>Welcome back, {$html['username']}.</p>&quot;; ?>
  • 20. Escaping Output Escaping output example: <?php $html = array(); $html['username'] = htmlentities($clean['username'], ENT_QUOTES); echo &quot;<p>Welcome back, {$html['username']}.</p>&quot;; ?> Initialize array for storing escaped data
  • 21. Escaping Output Escaping output example: <?php $html = array(); $html['username'] = htmlentities($clean['username'], ENT_QUOTES); echo &quot;<p>Welcome back, {$html['username']}.</p>&quot;; ?> Escaped the filtered username and store in the array
  • 22. Escaping Output Escaping output example: <?php $html = array(); $html['username'] = htmlentities($clean['username'], ENT_QUOTES); echo &quot;<p>Welcome back, {$html['username']} .</p>&quot;; ?> Send the filtered and escaped username to the client
  • 23. Escaping Output Escaping output example 2: <?php $mysql = array(); $mysql['username'] = mysql_real_escape_string($clean['username']); $sql = &quot;SELECT * FROM profile WHERE username = '{$mysql['username']}'&quot;; $result = mysql_query($sql); ?>
  • 24. Escaping Output Escaping output example 2: <?php $mysql = array(); $mysql['username'] = mysql_real_escape_string($clean['username']); $sql = &quot;SELECT * FROM profile WHERE username = '{$mysql['username']}'&quot;; $result = mysql_query($sql); ?> Initialize an array for storing escaped data
  • 25. Escaping Output Escaping output example 2: <?php $mysql = array(); $mysql['username'] = mysql_real_escape_string($clean['username']); $sql = &quot;SELECT * FROM profile WHERE username = '{$mysql['username']}'&quot;; $result = mysql_query($sql); ?> Escaped the filter username and store it in the array
  • 26. Escaping Output Escaping output example 2: <?php $mysql = array(); $mysql['username'] = mysql_real_escape_string($clean['username']); $sql = &quot;SELECT * FROM profile WHERE username = '{$mysql['username']}' &quot;; $result = mysql_query($sql); ?> Use the filtered and escaped username in the SQL query
  • 27. Escaping Output Escaping output example 2: <?php $mysql = array(); $mysql['username'] = mysql_real_escape_string($clean['username']); $sql = &quot;SELECT * FROM profile WHERE username = '{$mysql['username']}'&quot;; $result = mysql_query($sql) ; ?> SQL Query is now safe
  • 28.
  • 29. SQL Injection SQL Injection attacking example: http://example.com/db.php?id=0 http://example.com/db.php?id=0 ;DELETE%20FROM%20users <?php $id = $_GET['id']; // $id = 0;DELETE FROM users $result = mysql_query(&quot;SELECT * FROM users WHERE id={$id}&quot;); SQL Inject code User table data destroyed
  • 30. SQL Injection SQL Injection attacking example 2: <?php $query = &quot;SELECT * FROM users WHERE user='{$_POST['username']}' AND password='{$_POST['password']}'&quot;; mysql_query($query); //$_POST['username'] = 'manzil'; //$_POST['password'] = &quot;' OR ''='&quot;; echo $query; ?> output: SELECT * FROM users WHERE user='manzil' AND password='' OR ''='' SQL Inject code
  • 31. SQL Injection SQL Injection Protection: <?php $name = mysql_real_escape_string($_POST['username']); $pass = mysql_real_escape_string($_POST['password']); $query = &quot;SELECT * FROM users WHERE user='{$name}' AND password='{$pass}'&quot;; mysql_query($query); ?>
  • 32. Cross-Site Scripting What is XSS ? It is a popular attacking to web application as web application largely echo user input. <?php echo &quot;<p>Welcome back, { $_GET['username'] }.</p>&quot;; ?>
  • 33. Cross-Site Scripting Attacking Example: <?php echo &quot;<p>Welcome back, <script> ... </script> .</p>&quot;; ?> XSS Attacking !!!
  • 34.
  • 35. Cross-Site Scripting htmlentities(): <?php $name = $_GET['username']; // <script> ... </script> echo htmlentities($name, ENT_QUOTES) ; ?> output: &lt;script&gt; ... &lt;/script&gt;
  • 36.
  • 37. Session Hijacking Example of Session Fixation: http://example.org/login.php?PHPSESSID=1234 Prevention of Session Fixation: Use session_regenerate_id() whenever there is a change in the level of privilege: if ($authenticated) { $_SESSION['logged_in'] = TRUE; session_regenerate_id(); }
  • 38. Session Hijacking Another session security technique: Compare the browser signature headers. <?php session_start(); $chk = @md5( $_SERVER['HTTP_ACCEPT_CHARSET'] . $_SERVER['HTTP_ACCEPT_ENCODING'] . $_SERVER['HTTP_ACCEPT_LANGUAGE'] . $_SERVER['HTTP_USER_AGENT']); if (empty($_SESSION)) $_SESSION['key'] = $chk; else if ( $_SESSION['key'] != $chk ) session_destroy(); ?>
  • 39.
  • 40. Cross Site Request Forgeries What is CSRF? An attacker can send arbitrary HTTP requests from avictim. Because the requests originate from the victim, they can bypass traditional safeguards, including firewalls and access control.
  • 41.
  • 42.
  • 43.
  • 44.