Introduction To Web Application Security in PHP. Security is Big And Often Difficult PHP doesn’t make it any easier.

Slides:



Advertisements
Similar presentations
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems © 2002, Predictive Systems.
Advertisements

Past, Present and Future By Eoin Keary and Jim Manico
Web Security Never, ever, trust user inputs Supankar.
What is code injection? Code injection is the exploitation of a computer bug that is caused by processing invalid data. Code injection can be used by.
© 2008 Security Compass inc. 1 Firefox Plug-ins for Application Penetration Testing Exploit-Me.
HI-TEC 2011 SQL Injection. Client’s Browser HTTP or HTTPS Web Server Apache or IIS HTML Forms CGI Scripts Database SQL Server or Oracle or MySQL ODBC.
Creating Stronger, Safer, Web Facing Code JPL IT Security Mary Rivera June 17, 2011.
The XSS Files Find, Exploit, and Eliminate. Josh Little Security Engineer at global vertical market business intelligence company. 9 years in application.
Cross Site Scripting & SQL injection
By Philipp Vogt, Florian Nentwich, Nenad Jovanovic, Engin Kirda, Christopher Kruegel, and Giovanni Vigna Network and Distributed System Security(NDSS ‘07)
WebGoat & WebScarab “What is computer security for $1000 Alex?”
It’s always better live. MSDN Events Securing Web Applications Part 1 of 2 Understanding Threats and Attacks.
Multiple Tiers in Action
Leveraging User Interactions for In-Depth Testing of Web Applications Sean McAllister, Engin Kirda, and Christopher Kruegel RAID ’08 1 Seoyeon Kang November.
Introduction to the OWASP Top 10. Cross Site Scripting (XSS)  Comes in several flavors:  Stored  Reflective  DOM-Based.
Lecture 16 Page 1 CS 236 Online Cross-Site Scripting XSS Many sites allow users to upload information –Blogs, photo sharing, Facebook, etc. –Which gets.
Varun Sharma Security Engineer | ACE Team | Microsoft Information Security
Introduction to Application Penetration Testing
Workshop 3 Web Application Security Li Weichao March
NETWORK CENTRIC COMPUTING (With included EMBEDDED SYSTEMS)
OWASP Zed Attack Proxy Project Lead
+ Websites Vulnerabilities. + Content Expand of The Internet Use of the Internet Examples Importance of the Internet How to find Security Vulnerabilities.
WEB SECURITY WEEK 3 Computer Security Group University of Texas at Dallas.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
1-Vulnerabilities 2-Hackers 3-Categories of attacks 4-What a malicious hacker do? 5-Security mechanisms 6-HTTP Web Servers 7-Web applications attacks.
Ryan Dewhurst - 20th March 2012 Web Application (PHP) Security.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
Copyright 2007 © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Security Scanners Mark Shtern. Popular attack targets Web – Web platform – Web application Windows OS Mac OS Linux OS Smartphone.
© Copyright 2013 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 1 RubyJax Brent Morris/
OWASP Top Ten #1 Unvalidated Input. Agenda What is the OWASP Top 10? Where can I find it? What is Unvalidated Input? What environments are effected? How.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
SQL INJECTIONS Presented By: Eloy Viteri. What is SQL Injection An SQL injection attack is executed when a web page allows users to enter text into a.
Web Applications Testing By Jamie Rougvie Supported by.
Building Secure Web Applications With ASP.Net MVC.
© 2009 Stephen Wolff Application Security 1 Spring, 2009 OWASP Top Ten  Ten most critical WebApp security flaws. The top 2 are: 1. XSS – Cross Site Scripting.
Web Application Vulnerabilities ECE 4112 Internetwork Security, Spring 2005 Chris Kelly Chris Lewis April 28, 2005 ECE 4112 Internetwork Security, Spring.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
Module: Software Engineering of Web Applications Chapter 3 (Cont.): user-input-validation testing of web applications 1.
What Is XSS ? ! Cross-site scripting (XSS) is a type of computer security vulnerability typically found in Web applications. XSS enables attackers to.
PHP Security Ryan Dunn Jason Pack. Outline PHP Overview PHP Overview Common Security Issues Common Security Issues Advanced Security Issues Advanced Security.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Example – SQL Injection MySQL & PHP code: // The next instruction prompts the user is to supply an ID $personID = getIDstringFromUser(); $sqlQuery = "SELECT.
SQL Injection Josh Mann. What is SQL Injection  SQL injection is a technique for exploiting web applications that use client-supplied data in SQL queries.
By Collin Donaldson. Hacking is only legal under the following circumstances: 1.You hack (penetration test) a device/network you own. 2.You gain explicit,
Web Application with AJAX CS 526 advanced interned and Web system Presenters Faris Kateb Mohammed AbdulAziz Omar Alzahrani.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
CSE509 System Security Attacks against the server-side of web applications Nick Nikiforakis
Google’s Gruyere1 : An XSS Example Presented by: Terry Gregory
Group 18: Chris Hood Brett Poche
Module: Software Engineering of Web Applications
An Introduction to Web Application Security
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Introduction to Dynamic Web Programming
TOPIC: Web Security (Part-4)
Security: Exploits & Countermeasures
Security: Exploits & Countermeasures
Cross-Site Scripting Travis Deyarmin.
Cross Sight scripting: Type-2
PHP + Oracle = Data-Driven Websites
PHP: Security issues FdSc Module 109 Server side scripting and
WWW安全 國立暨南國際大學 資訊管理學系 陳彥錚.
Security: Exploits & Countermeasures
Security: Exploits & Countermeasures
Security: Exploits & Countermeasures
Lecture 27 Security I April 4, 2018 Open news web sites.
Exploring DOM-Based Cross Site Attacks
Presentation transcript:

Introduction To Web Application Security in PHP

Security is Big And Often Difficult PHP doesn’t make it any easier

What we’ll cover What do we mean by security? Application Security Code Configuration OWASP OWASP Top Ten SQL Injection XSS Configuration

Application Security Security in the SDLC as opposed to network security or data security or physical security

Security in Code and in Deployment For our purposes we’ll just stick to this:

OWASP An authority in Web Application Security

Open Web Application Security Project Really, many projects are “under” OWASP OWASP Top Ten ESAPI Development Guide Cheat Sheets Do not bring to exam Testing Guide More

OWASP Top Ten – Top Web Application Security Issues Based on the statistics of a number of scanning tools

OWASP Top – A1 InjectionA1 Injection SQL Injection is the variant of this that we’ll cover here

SQL Injection Confusing the DBMS between logic (written by the developer) and data (provided by the user)

A common query: $query = "SELECT * FROM user WHERE username = '". $_POST["username"]. "' AND password = '". $_POST["password"]. "';";

The intention $query = "SELECT * FROM user WHERE username = 'sue' AND password = 'secret';";

What if $_POST[“username”] is actually SQL Code The vulnerability:

' OR 1 = 1 # Let’s try this:

An SQL Injection $query = "SELECT * FROM user WHERE username = '' OR 1 = 1 #' AND password = '';”;

How to protect our code? Use Prepared Statements (available in all modern languages)

Prepared Statements $stmt = $dbh->prepare("SELECT * FROM user WHERE username = ? and password = ?"); $stmt- >execute(array($_POST["username"], $_POST["password"]));

The Intention $stmt = $dbh->prepare("SELECT * FROM user WHERE username = ? and password = ?"); $stmt->execute(array("sue", ”secret"));

The Exploit Foiled $stmt = $dbh->prepare("SELECT * FROM user WHERE username = ? and password = ?"); $stmt->execute(array("' OR 1 = 1 #", "")); // the logic is clearly separated // in our code and in transmission // to our database

Hence Why We Learned PDOPDO

OWASP Top – A3 XSSA3 XSS Cross Site Scripting

Three Variants of XSS 1.Reflected XSS 2.Stored XSS 3.DOM based XSS

Cross Site Scripting Confusing the browser between the application’s HTML (structure) and Data.

Commonly Used Display Code

The Intended Result sue

What if $_GET[“username”] is actually HTML and JavaScript? The vulnerability:

alert("Hello World") Let’s try this:

Display Code With Injection alert('hello world’) " ?>

Display Code With Injection alert('hello world')

Reflected XSS The vulnerability is exploited only in response to a specific request. Example p?data=%3Cscript%3Ealert(%22hello%20wo rld%22)%3Cscript%3E

Stored XSS Submit request with XSS payload (ex. a blog comment with XSS in the body) Web app stores the comment in Database (with unencoded XSS Code) Victim views the stored data (ex. view a blog post which shows comments) XSS Code is executed by the victim’s browser.

DOM Based XSS Also known as Type 0 XSS Out of the scope of this course Basically, tricking JavaScript to write out code

Protecting from XSS Encode user inputs

htmlentites() $foo = “ ”; $foo = htmlentities($foo, ENT_QUOTES | ENT_HTML5); print $foo; # <script>

html_entity_decode() foo = "<script>"; $foo = html_entity_decode($foo, ENT_QUOTES | ENT_HTML5); print $foo; # " ”

When to encode? Before reflecting Before displaying information you just received Choose either before you persist or after then be consistent. Better yet do both but watch out for double encodingdouble encoding

Configuration Your app is not secure if it’s running on a vulnerable server or otherwise deployed insecurely.

This is a topic in itself Sources to look at: Google et al.

Simple Good Things To Do

Use PHP as Module not CGI

Patch! Your software is only as secure as your latest security patch

Hide your fingerprints ng.phphttp:// ng.php core.html#servertokenshttp://httpd.apache.org/docs/current/mod/ core.html#servertokens

Disable dangerous functions Disable dangerous functions ( eval() ) eval()