CS 155 Project 2. Overview & Part A

Similar documents
Application vulnerabilities and defences

Attacks Against Websites. Tom Chothia Computer Security, Lecture 11

Perslink Security. Perslink Security. Eleonora Petridou Pascal Cuylaerts. System And Network Engineering University of Amsterdam.

Web Security II. Slides from M. Hicks, University of Maryland

Assignment 6: Web Security

Web Application Security. Philippe Bogaerts

WEB SECURITY: XSS & CSRF

NET 311 INFORMATION SECURITY

CSCE 813 Internet Security Case Study II: XSS


Ruby on Rails Secure Coding Recommendations

Project 2: Web Security

CIS 4360 Secure Computer Systems XSS

WEB SECURITY WORKSHOP TEXSAW Presented by Solomon Boyd and Jiayang Wang

CS 161 Computer Security

Web basics: HTTP cookies

2/16/18. CYSE 411/AIT 681 Secure Software Engineering. Secure Coding. The Web. Topic #11. Web Security. Instructor: Dr. Kun Sun

How is state managed in HTTP sessions. Web basics: HTTP cookies. Hidden fields (2) The principle. Disadvantage of this approach

CSE361 Web Security. Attacks against the client-side of web applications. Nick Nikiforakis

PROBLEMS IN PRACTICE: THE WEB MICHAEL ROITZSCH

DEFENSIVE PROGRAMMING. Lecture for EDA 263 Magnus Almgren Department of Computer Science and Engineering Chalmers University of Technology

Web basics: HTTP cookies

CS 161 Computer Security

6.170 Tutorial 7 - Rails Security. Prerequisites. Goals of this tutorial. Resources

CS 161 Computer Security

Attacks Against Websites 3 The OWASP Top 10. Tom Chothia Computer Security, Lecture 14

RKN 2015 Application Layer Short Summary

2/16/18. Secure Coding. CYSE 411/AIT 681 Secure Software Engineering. Web Security Outline. The Web. The Web, Basically.

Exploiting and Defending: Common Web Application Vulnerabilities

Web Attacks Lab. 35 Points Group Lab Due Date: Lesson 16

Advanced Web Technology 10) XSS, CSRF and SQL Injection

Web Security Computer Security Peter Reiher December 9, 2014

Information Security CS 526 Topic 8

CS 142 Winter Session Management. Dan Boneh

Security. CSC309 TA: Sukwon Oh

Chrome Extension Security Architecture

Robust Defenses for Cross-Site Request Forgery

Security and Privacy. SWE 432, Fall 2016 Design and Implementation of Software for the Web

Web Attacks, con t. CS 161: Computer Security. Prof. Vern Paxson. TAs: Devdatta Akhawe, Mobin Javed & Matthias Vallentin

Web Security: XSS; Sessions

OWASP Top 10 Risks. Many thanks to Dave Wichers & OWASP

Web Application Security

PROBLEMS IN PRACTICE: THE WEB MICHAEL ROITZSCH

Combating Common Web App Authentication Threats

Web Security: Vulnerabilities & Attacks

Information Security CS 526 Topic 11

Lecture Notes on Safety and Information Flow on the Web: II

John Coggeshall Copyright 2006, Zend Technologies Inc.

Andrew Muller, Canberra Managing Director, Ionize, Canberra The challenges of Security Testing. Security Testing. Taming the Wild West

Solution of Exercise Sheet 5

Your Turn to Hack the OWASP Top 10!

Finding Vulnerabilities in Web Applications

Lecture Overview. IN5290 Ethical Hacking

Lecture 6: Web hacking 2, Cross Site Scripting (XSS), Cross Site Request Forgery (CSRF), Session related attacks

CS1520 Recitation: Security in Flask

IS 2150 / TEL 2810 Introduction to Security

Web Security. Web Programming.

CS 161 Computer Security

Lecture 17 Browser Security. Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017 Some slides from Bailey's ECE 422

Integrity attacks (from data to code): Malicious File upload, code execution, SQL Injection

Web Security. Thierry Sans

eb Security Software Studio

Robust Defenses for Cross-Site Request Forgery

Content Security Policy

Robust Defenses for Cross-Site Request Forgery Review

Web Security. Jace Baker, Nick Ramos, Hugo Espiritu, Andrew Le

Title: Multiple Remote Command Execution vulnerabilities on Avaya Intuity Audix LX (plus some client-side bugs)

CSCD 303 Essential Computer Security Fall 2017

GUI based and very easy to use, no security expertise required. Reporting in both HTML and RTF formats - Click here to view the sample report.

CS 161 Computer Security

Penetration Testing following OWASP. Boyan Yanchev Chief Technology Ofcer Peter Dimkov IS Consultant

PHP Security. Kevin Schroeder Zend Technologies. Copyright 2007, Zend Technologies Inc.

Provide you with a quick introduction to web application security Increase you awareness and knowledge of security in general Show you that any

Web Security: Authentication & UI-based attacks

Clojure Web Security. FrOSCon Joy Clark & Simon Kölsch

Web Security IV: Cross-Site Attacks

CSCD 303 Essential Computer Security Fall 2018

CHAPTER 8 CONCLUSION AND FUTURE ENHANCEMENTS

W e b A p p l i c a t i o n S e c u r i t y : T h e D e v i l i s i n t h e D e t a i l s

Client Side Injection on Web Applications

Web Security. Attacks on Servers 11/6/2017 1

Why bother? Causes of data breaches OWASP. Top ten attacks. Now what? Do it yourself Questions?

CNIT 129S: Securing Web Applications. Ch 12: Attacking Users: Cross-Site Scripting (XSS) Part 2

Is Browsing Safe? Web Browser Security. Subverting the Browser. Browser Security Model. XSS / Script Injection. 1. XSS / Script Injection

Don't Trust The Locals: Exploiting Persistent Client-Side Cross-Site Scripting in the Wild

Application Security Introduction. Tara Gu IBM Product Security Incident Response Team

INF3700 Informasjonsteknologi og samfunn. Application Security. Audun Jøsang University of Oslo Spring 2015

Web Security: Vulnerabilities & Attacks

OWASP Top 10 The Ten Most Critical Web Application Security Risks

CS Paul Krzyzanowski

Computer Security. 14. Web Security. Paul Krzyzanowski. Rutgers University. Spring 2018

EasyCrypt passes an independent security audit

Computer Security CS 426 Lecture 41

Web Application Threats and Remediation. Terry Labach, IST Security Team

CONTENTS IN DETAIL INTRODUCTION 1 THE FAQS OF LIFE THE SCRIPTS EVERY PHP PROGRAMMER WANTS (OR NEEDS) TO KNOW 1 2 CONFIGURING PHP 19

Cross-Site Request Forgery (CSRF) Attack Lab

This slide shows the OWASP Top 10 Web Application Security Risks of 2017, which is a list of the currently most dangerous web vulnerabilities in

Computer Forensics: Investigating Network Intrusions and Cyber Crime, 2nd Edition. Chapter 3 Investigating Web Attacks

CS 161 Computer Security

Security: Threats and Countermeasures. Stanley Tan Academic Program Manager Microsoft Singapore

Transcription:

CS 155 Project 2 Overview & Part A

Project 2 Web application security Composed of two parts Part A: Attack Part B: Defense Due date: Part A: May 5th (Thu) Part B: May 12th (Thu)

Project 2 Ruby-on-Rails http://guides.rubyonrails.org/index.html http://api.rubyonrails.org/ http://ruby-doc.org/ HTML & JavaScript http://www.w3schools.com/ StackOverflow is always helpful.

Web application security 1. Session Hijacking 2. Cross Site Request Forgery (CSRF) 3. Cross Site Scripting (XSS) 4. SQL Injection 5. Clickjacking

1. Session Hijacking How to store information while navigating? 1. Most common way is to store info in cookie. 2. Cookie is just key-value pair. 3. Many web apps store important data into cookie. 4. Store the session info (e.g. login id) in cookie. 5. Attackers can impersonate by stealing cookie.

1. Session Hijacking e.g.) document.cookie= "_bitbar_session=bah7cekid3nlc3npb25fawqgogzfvekijwrjogjjodkzm2m zmtm5ztfln2uyodzkotaymduzywvkbjsavekicnrva2vubjsarkkig0tiothu QkpTYk84ZjVyVnc2RDMzWkEGOwBGSSIRbG9nZ2VkX2luX2lkBjsARmkG-- 07fa496d50e4bbddca2046f6f0cd77dfdd9919e3"

2. CSRF Try to send malicious request with victim s valid credentials. Normally, attacker creates his own page, and victim visits here. Victim s browser will send request in attacker s page to target site using victim s credential.

3. XSS Attacker injects script into victim s browser. Attacker can inject his script in many ways 1. Attacker can redirect a victim to a certain URL with malicious script, and the script is echoed. (Reflected XSS) 2. Attacker can store malicious script in the server, and make the victim retrieve the script in victim s browser. (Stored XSS)

4. SQL Injection A lot of SQL queries are made in web applications. (e.g. login, search, store data, retrieve data) If query is not made carefully, an attacker can pass in strange input, and make malicious request to the server. Can retrieve undesired data, can modify data, can delete data, can create malicious data etc.

SELECT * FROM Students WHERE name=( <%=input %> ); => SELECT * FROM Students WHERE name=( Robert ); DROP TABLE Students;-- ); (In SQL, -- is inline comment, similar to // in C)

5. Clickjacking Involve victim s action to make an attack. Fool the victim to do something for attacker. Can be any type of attack, but mostly CSRF It seems stupid at first but...

Now move on to Project 2!

But first.ruby

Ruby-on-Rails? Syntax is similar to Python. MVC web development platform. Should not be that hard to understand Hopefully Quite great documentations. A lot of information in Google, StackOverflow etc.

How Ruby-on-Rails works HTML request => Find corresponding method in controller (specified in bitbar/config/routes.rb) => Execute the method in controller. * There are two types of variable in each method. One is normal local variable (which does not start with @ ), and the other is a variable passed into view to create HTML page. => Create HTML page with corresponding view file (.html.erb) * View file also has Ruby codes inside. Every line inside <% %> is executed as Ruby codes. Every line inside <%= %> will print out the return value of expression inside.

How Ruby-on-Rails works e.g.) localhost:3000/profile => bitbar/config/routes.rb

bitbar/app/controllers/user_controller.rb

bitbar/app/views/user/profile.html.erb

Database in Ruby-on-Rails Basically, one uses model to manage the database in Ruby-on-Rails. There is one model, User, in this project. User.find_by_id(1) => create SQL query to retrieve data. @user.id => how to access column id of a row. You can look at terminal output while running the server to see how query is made with model instructions.

Session, parameters Session is in hash object. Can access via session[key]. Session will be embedded in cookie. (as specified in bitbar/config/initializers/session_store.rb) reset_session will delete all data in session. Parameters in HTML request can be accessed via params [key]. Both for GET and POST.

Ask questions on Piazza about Ruby! Find information on the web about Ruby! Read recommended tutorial about Ruby in the handout!

Warmup Steal the cookie with reflected XSS Your solution is an URL starting with: http://localhost:3000/profile?username=... When a victim enters this URL, cookie should be sent to: http://localhost:3000/steal_cookie?cookie=... Look carefully how HTML looks like for profile page.

Attack A Write some codes to output a line of JavaScript. If you copy and paste this script into the JavaScript console, now you will impersonate as user1 You can assume attacker has a read-only access to everything in bitbar directory, except for bitbar/db. Need to know how cookie and session works in Ruby-on- Rails.

"_bitbar_session=bah7cekid3nlc3npb25fawqgogzfvekijwrjogjjodkzm2mzm TM5ZTFlN2UyODZkOTAyMDUzYWVkBjsAVEkiCnRva2VuBjsARkkiG0tIOThUQkpT Yk84ZjVyVnc2RDMzWkEGOwBGSSIRbG9nZ2VkX2luX2lkBjsARmkG-- 07fa496d50e4bbddca2046f6f0cd77dfdd9919e3" Session in hash object (e.g. {a:b, c:d}) => serialize (Marshal) => encode in Base64 (Base64) => BAh7CEkiD3Nlc3N (str1) => HMAC this string with secret key (Digest::HMAC) => 07fa496d50e4bbddc (str2) => _bitbar_session= + str1 + -- + str2 Marshal - http://ruby-doc.org/core-2.3.0/marshal.html Base64 - http://ruby-doc.org/stdlib-2.3.0/libdoc/base64/rdoc/base64.html Digest::HMAC - http://ruby-doc.org/stdlib-2.1.5/libdoc/digest/rdoc/digest/hmac.html

Attack A You will find Mechanize module helpful. (You should install it first. gem install mechanize. Already installed in VM) You can create other supporting files for this problem. But be sure your attack can work with single command./a.sh

Attack B Basic CSRF Create a page which will send request to transfer bitbars to attacker s account when the victim opens. Your page should redirect the victim to CS155 page as soon as the request is successfully made.

Attack B+ Advanced CSRF Should be clickjacking attack. Be sure you make a request to super_secure_transfer or super_secure_post_transfer You may create one more HTML page other than bp.html. You should not disable framebusting. Your attack should still work with provided basic framebusting.

Attack C SQL Injection Create an account with username of your answer, and then close the account. Should remove user3 from database at the same time. When you want to reset the database, run rake db:reset

Attack D Stored XSS Set profile of attacker with your answer When other user sees attacker s profile, his profile should be replaced with the same profile, and one bitbar should be transferred to the attacker. Same thing should happen when other users see infected user s profile.

Attack D Profile already has some basic sanitization ( bitbar/app/helpers/application_helper.rb ), but it s not enough. Profile page should look normal. Look carefully how HTML looks like for profile page.

Extra Credit: Attack E We will not give you a lot of hints on EC, but You will find String.fromCharCode helpful for this attack.

Questions?