C HAPTER 7 Client-State Manipulation Slides adapted from "Foundations of Security: What Every Programmer Needs To Know" by Neil Daswani, Christoph Kern,

Slides:



Advertisements
Similar presentations
Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
Advertisements

Lecture 6/2/12. Forms and PHP The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input When dealing with HTML forms.
Bypassing Client-Side Protection CSE 591 – Security and Vulnerability Analysis Spring 2015 Adam Doupé Arizona State University
Parameter Tampering. Attacking the Ecommerce Shopping Cart In the above image we see that a user who wants to purchase a Television visits an online Store.
ATTACKING AUTHENTICATION The Web Application Hacker’s Handbook, Ch. 6 Presenter: Jie Huang 10/31/2012.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
CMSC 414 Computer and Network Security Lecture 19 Jonathan Katz.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
Online Security Tuesday April 8, 2003 Maxence Crossley.
Chapter 9 Web Applications. Web Applications are public and available to the entire world. Easy access to the application means also easy access for malicious.
Computer Security and Penetration Testing
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Handling Security Threats in Kentico CMS Karol Jarkovsky Sr. Solution Architect Kentico Software
Cookies COEN 351 E-commerce Security. Client / Session Identification HTTP does not maintain state. State Information can be passed using: HTTP Headers.
C HAPTER 13 Asymmetric Key Cryptography Slides adapted from "Foundations of Security: What Every Programmer Needs To Know" by Neil Daswani, Christoph Kern,
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
FORESEC Academy FORESEC Academy Security Essentials (II)
Computer Concepts 2014 Chapter 7 The Web and .
May 28, 2002Mårten Trolin1 Protocols for e-commerce Traditional credit cards SET SPA/UCAF 3D-Secure Temporary card numbers Direct Payments.
Web Security Programming I Building Security in from the Start Except where otherwise noted all portions of this work are Copyright (c) 2007 Google and.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
CHAPTER 12 COOKIES AND SESSIONS. INTRO HTTP is a stateless technology Each page rendered by a browser is unrelated to other pages – even if they are from.
Security.NET Chapter 1. How Do Attacks Occur? Stages of attack Examples of attacker actions 1. FootprintRuns a port scan on the firewall 2. PenetrationExploits.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Lecture 7 Interaction. Topics Implementing data flows An internet solution Transactions in MySQL 4-tier systems – business rule/presentation separation.
Chapter 9 Web Applications. Web Applications are public and available to the entire world. Easy access to the application means also easy access for malicious.
Chapter 10 Developing a Web-Based Online Shopping Application (I)
CS453: State in Web Applications (Part 1) State in General Sessions (esp. in PHP) Prof. Tom Horton.
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
COMP3121 E-Commerce Technologies Richard Henson University of Worcester November 2011.
Chapter 8 Cookies And Security JavaScript, Third Edition.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
PHP1-1 PHP Lecture 2 Xingquan (Hill) Zhu
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
Web Application Security ECE ECE Internetwork Security What is a Web Application? An application generally comprised of a collection of scripts.
Security Scanners Mark Shtern. Popular attack targets Web – Web platform – Web application Windows OS Mac OS Linux OS Smartphone.
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
School of Computing and Information Systems CS 371 Web Application Programming Security Avoiding and Preventing Attacks.
Chapter 6 Server-side Programming: Java Servlets
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
Ram Santhanam Application Level Attacks - Session Hijacking & Defences
October 3, 2008IMI Security Symposium Application Security through a Hacker’s Eyes James Walden Northern Kentucky University
Cookies and Sessions IDIA 618 Fall 2014 Bridget M. Blodgett.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
WWW: an Internet application Bill Chu. © Bei-Tseng Chu Aug 2000 WWW Web and HTTP WWW web is an interconnected information servers each server maintains.
Saving State on the WWW. The Issue  Connections on the WWW are stateless  Every time a link is followed is like the first time to the server — it has.
Cookies COEN 351 E-commerce Security. Client / Session Identification HTTP Headers Client IP Address HTTP User Login FAT URLs Cookies.
Sessions and Cookies State Management, Cookies, Sessions, Hidden Fields SoftUni Team Technical Trainers Software University
CIS 451: Cookies Dr. Ralph D. Westfall February, 2009.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
© Copyright 2009 SSLPost 01. © Copyright 2009 SSLPost 02 a recipient is sent an encrypted that contains data specific to that recipient the data.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
AJAX Use Cases for WSRP Subbu Allamaraju BEA Systems Inc WSRP F2F Meeting, May 2006.
Session Management Tyler Moore CS7403 University of Tulsa Slides adapted in part or whole from Dan Boneh, Stanford CS155 1.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
Fall 2006CS 395: Computer Security1 Key Management.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
COOKIES AND SESSIONS.
WEB SECURITY WEEK 1 Computer Security Group University of Texas at Dallas.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
Srinivas Balivada USC CSCE548 07/22/2016.  Cookies are generally set server-side using the ‘Set-Cookie’ HTTP header and sent to the client  In PHP to.
ITM 352 Cookies.
PHP / MySQL Introduction
Amit Kulkarni February 17, 2004
Lecture 2 - SQL Injection
Cross Site Request Forgery (CSRF)
Presentation transcript:

C HAPTER 7 Client-State Manipulation Slides adapted from "Foundations of Security: What Every Programmer Needs To Know" by Neil Daswani, Christoph Kern, and Anita Kesavan (ISBN ; Except as otherwise noted, the content of this presentation is licensed under the Creative Commons 3.0 License.

Agenda Web application – collection of programs used by server to reply to client (browser) requests  Often accept user input: don’t trust, validate! HTTP is stateless, servers don’t keep state  To conduct transactions, web apps have state  State info may be sent to client who echoes it back in future requests Example Exploit: “Hidden” parameters in HTML are not really hidden, can be manipulated

7.1. Pizza Delivery Web Site Example Web app for delivering pizza  Online order form: order.html – say user buys one $5.50  Confirmation form: generated by confirm_order script, asks user to verify purchase, price is sent as hidden form field  Fulfillment: submit_order script handles user’s order received as GET request from confirmation form ( pay & price variables embedded as parameters in URL)

7.1. Pizza Web Site Code Confirmation Form: Submit Order Script: Pay for Pizza The total cost is Are you sure you would like to order? if (pay = yes) { success = authorize_credit_card_charge(price); if (success) { settle_transaction(price); dispatch_delivery_person(); } else { // Could not authorize card tell_user_card_declined(); } } else { display_transaction_cancelled_page(); // no}

7.1. Buying Pizza Example Web Server Web Browser (Client) Credit Card Payment Gateway Order 1 Pizza Confirm $5.50 Submit Order $5.50 Attacker will modify Price Stored in Hidden Form Variable submit_order?price=5.50

Attack Scenario (1) Attacker navigates to order form…

Attack Scenario (2) …then to submit order form

Attack Scenario (3) And he can View | Source:

Attack Scenario (4) Changes price in source, reloads page! Browser sends request: GET /submit_order?price=0.01&pay=yes HTTP/1.1 Hidden form variables are essentially in clear

Attack Scenario (5) Web Server Web Browser (Client) Credit Card Payment Gateway Order 1 Pizza Confirm $5.50 Submit Order $0.01 Attacker modified Price!

Attack Scenario (6) Command-line tools to generate HTTP requests curl or Wget automates & speeds up attack: curl ?price=0.01&pay=yes Even against POST, can specify params as arguments to curl or wget command curl -dprice=0.01 -dpay=yes pizza.com/submit_order wget --post-data 'price=0.01&pay=yes'

Solution 1: Authoritative State Stays on Server Server sends session-id to client  Server has table mapping session-ids to prices  Randomly generated (hard to guess) 128-bit id sent in hidden form field instead of the price.  New Request <input type="hidden" name="session-id" value="3927a837e947df203784d309c8372b8e"> GET /submit_order?session-id=3927a837e947df203784d309c8372b8e &pay=yes HTTP/1.1

Solution 1 Changes submit_order script changes: if (pay = yes) { price = lookup(session-id); // in table if (price != NULL) { // same as before } else { // Cannot find session display_transaction_cancelled_page(); log_client_IP_and_info(); } } else { // same no case }

Session Management 128-bit session-id, n = # of session-ids  Limit chance of correct guess to n/  Time-out idle session-ids  Clear expired session-ids  Session-id: hash random # & IP address – harder to attack (also need to spoof IP) Con: server requires DB lookup for each request  Performance bottleneck – possible DoS from attackers sending random session-ids  Distribute DB, load balance requests

Solution 2: Signed State To Client Keep Server stateless, attach a signature to state and send to client  Can detect tampering through MACs  Sign whole transaction (based on all parameters)  Security based on secret key known only to server <input type="hidden" name="signature" value="a2a30984f302c843284e b33d2">

Solution 2 Analysis Changes in submit_order script:  Can detect tampered state vars from invalid signature Performance Hit  Compute MACs when processing HTTP requests  Stream state info to client -> extra bandwidth if (pay = yes) { // Aggregate transaction state parameters // Note: | is concatenation operator, # a delimiter. state = item-id | # | qty | # | address | # | credit_card_no | # | exp_date | # | price; //Compute message authentication code with server key K. signature_check = MAC(K, state); if (signature == signature_check) { // proceed normally } else { // Invalid signature: cancel & log } } else { // no pay – cancel}

7.2. POST Instead of GET GET: form params (e.g. session-id) leak in URL  Could anchor these links in lieu of hidden form fields  Alice sends Meg URL in , Meg follows it & continues transaction w/o Alice’s consent Referers can leak through outlinks:  This link  Sends request:  Session-id leaked to grocery-store-site ’s logs! GET / HTTP/1.1 Referer: session-id=3927a837e947df203784d309c8372b8e

7.2. Benefits of POST POST Request:  Session-id not visible in URL  Pasting into wouldn’t leak it  Slightly inconvenient for user, but more secure Referers can still leak w/o user interaction  Instead of link, image:  GET request for banner.gif still leaks session-id POST /submit_order HTTP/1.1 Content-Type: application/x-www-form-urlencoded Content-Length: 45 session-id%3D3927a837e947df203784d309c8372b8e

7.3. Cookies Cookie - piece of state maintained by client  Server gives cookie to client  Client returns cookie to server in HTTP requests  Ex: session-id in cookie in lieu of hidden form field  Secure dictates using SSL  Browser Replies: HTTP/ OK Set-Cookie: session-id=3927a837e947df203784d309c8372b8e; secure GET /submit_order?pay=yes HTTP/1.1 Cookie: session-id=3927a837e947df203784d309c8372b8e

7.3. Problems with Cookies Cookies are associated with browser  Sent back w/ each request, no hidden field to tack on If user doesn’t log out, attacker can use same browser to impersonate user Session-ids should have limited lifetime

7.4. JavaScript (1) Popular client-side scripting language Ex: Compute prices of an order: Order Pizza How many pizzas would you like to order? function computePrice() { f.price.value = 5.50 * f.qty.value; // compute new value f.Order.value = "Pay " + f.price.value // update price }

7.4. JavaScript (2) Evil user can just delete JavaScript code, substitute desired parameters & submit!  Could also just submit request & bypass JavaScript Warning: data validation or computations done by JavaScript cannot be trusted by server  Attacker may alter script in HTML code to modify computations  Must be redone on server to verify GET /submit_order?qty=1000&price=0&Order=Pay

Summary Web applications need to maintain state  HTTP stateless  Hidden form fields, cookies  Session-management, server with state… Don’t trust user input!  keep state on server (space-expensive)  Or sign transaction params (bandwidth-expensive)  Use cookies, be wary of cross-site attacks (c.f. ch.10)  No JavaScript for computations & validations