Vulnerability Analysis Part 2 RK Shyamasundar IIT Bombay Outline - - PowerPoint PPT Presentation

vulnerability analysis part 2
SMART_READER_LITE
LIVE PREVIEW

Vulnerability Analysis Part 2 RK Shyamasundar IIT Bombay Outline - - PowerPoint PPT Presentation

Vulnerability Analysis Part 2 RK Shyamasundar IIT Bombay Outline Software Security Web Application Security Buffer Overflow Web content security: SSL Buffer Overflow Phishing attacks mitigation techniques


slide-1
SLIDE 1

Vulnerability Analysis – Part 2

RK Shyamasundar IIT Bombay

slide-2
SLIDE 2

Outline

  • Software Security

– Buffer Overflow – Buffer Overflow mitigation techniques

  • Web Application Security

– Web content security: SSL – Phishing attacks – Side-channel attacks – Finding vulnerabilities – OWASP Top 10 (top 3) – Mitigation techniques – Best practices

slide-3
SLIDE 3

Recap: Security Properties

Primary

  • Confidentiality
  • Authentication
  • Freshness
  • Availability
  • Non-repudiation
  • Integrity

Secondary

  • Scalability
  • Cost
  • Usability
  • Privacy
  • Trust anchor/hierarchy
  • State availability: on/off-line

A practitioner of Security Engineering should be juggling between above security properties and find an acceptable balance with well-documented risks/assumptions.

slide-4
SLIDE 4

HTTPS/SSL (Padlock & notion of Trust)

slide-5
SLIDE 5

HTTPS/SSL (Padlock & notion of Trust)

slide-6
SLIDE 6

Successful SSL = padlock

slide-7
SLIDE 7

Padlock = layman’s icon for session security*

slide-8
SLIDE 8

Getting into the details of a server certificate

slide-9
SLIDE 9

Leaf-CA

slide-10
SLIDE 10

Intermediate-CA

slide-11
SLIDE 11

Root-CA

slide-12
SLIDE 12

Certificate Details: Key’s Usage

slide-13
SLIDE 13

Certificate Details: Cert’s Usage

slide-14
SLIDE 14

Certificate Details: Cert Extension SAN

slide-15
SLIDE 15

Certificate Details: Cert Extension CRL, OCSP

slide-16
SLIDE 16
slide-17
SLIDE 17

SSL Protocol

slide-18
SLIDE 18

SSL Protocol

slide-19
SLIDE 19

SSL Protocol

slide-20
SLIDE 20

Broken padlock = ?

slide-21
SLIDE 21

Interesting Read… (2 days ago)

http://wrd.cm/2oEULr3

slide-22
SLIDE 22

DNS, SMTP, HTTP

slide-23
SLIDE 23

Security cannot be thought in isolation

slide-24
SLIDE 24

Attacks on SSL

  • CRIME attack [Qualys]
  • What is the problem?

– The root cause of the problem is information leakage that occurs when data is compressed prior to encryption. If someone can repeatedly inject and mix arbitrary content with some sensitive and relatively predictable data, and observe the resulting encrypted stream, then she will be able to extract the unknown data from it.

slide-25
SLIDE 25

Information Leakage

slide-26
SLIDE 26

Other reading…

  • Side channel leaks in Web applications

[S&P 2010]

  • Sidebuster [CCS 2010]
slide-27
SLIDE 27

Improper Configuration & Error Handling

slide-28
SLIDE 28
slide-29
SLIDE 29
slide-30
SLIDE 30
slide-31
SLIDE 31
slide-32
SLIDE 32
slide-33
SLIDE 33
slide-34
SLIDE 34
slide-35
SLIDE 35
slide-36
SLIDE 36

Data Leakage/Privacy/Credential Theft

  • http://www.mi.com/in/hdindex/choosePro/in

dex.html?pro=IN_REDMI3S&_1475044200

  • URL submission variables
  • https://account.xiaomi.com/pass/auth/sns/ho

me?userId=1617339665

slide-37
SLIDE 37

Information leakage

Type of webserver: incorrect configuration of webserver Attacker concentrates on a specific set of vulnerabilities!

slide-38
SLIDE 38

View Source: continue exploring

This webserver type is different from the previous webserver What does this tell me? (there is either: directory mapping or NFS, or webserver proxy feature in place)

slide-39
SLIDE 39

Continue directory traversal

slide-40
SLIDE 40

Two webservers offering same content!

slide-41
SLIDE 41

Automate the process

  • Use open-source/professional tools
  • Limitation: known-vulnerabilities
  • 0-days: not covered
slide-42
SLIDE 42

How should a bank protect its data if everything is SSLized?

slide-43
SLIDE 43

SSL Proxy References

  • 1. https://blog.heckel.xyz/2013/08/04/use-

sslsplit-to-transparently-sniff-tls-ssl- connections/

  • 2. https://blog.heckel.xyz/2013/07/01/how-to-

use-mitmproxy-to-read-and-modify-https- traffic-of-your-phone/

  • 3. https://blog.heckel.xyz/2013/08/04/use-

sslsplit-to-transparently-sniff-tls-ssl- connections/

slide-44
SLIDE 44

Nessus Vulnerability Scanner: Dashboard

slide-45
SLIDE 45

Nessus Vulnerability Scanner: Event Notification

slide-46
SLIDE 46

Payloads!

slide-47
SLIDE 47
slide-48
SLIDE 48
slide-49
SLIDE 49
slide-50
SLIDE 50
slide-51
SLIDE 51

Code injection attack

  • Code Injection is the general term for attack types

which consist of injecting code that is then interpreted/executed by the application.

  • This type of attack exploits poor handling of

untrusted data. These types of attacks are usually made possible due to a lack of proper input/output data validation, for example:

– allowed characters (standard regular expressions classes or custom) – data format – amount of expected data

slide-52
SLIDE 52

Code injection attack

  • These types of vulnerabilities can range from

very hard to find, to easy to find

  • If found, are usually moderately hard to

exploit, depending of scenario

  • If successfully exploited, impact could cover

loss of confidentiality, loss of integrity, loss of availability, and/or loss of accountability

slide-53
SLIDE 53
slide-54
SLIDE 54

Input validation is necessary!

slide-55
SLIDE 55

Preventive Techniques

  • Despite best efforts of application developers

to detect and rectify bugs/vulnerabilities it may not be guaranteed that application will be remain secure in future.

  • One may take help of application firewalls to

reduce exposure of the application to unauthorized users

– modSecurity (Apache) – AppSensor (OWASP)

slide-56
SLIDE 56

Growth of Threat: Growth in the tools available (2004!)

5,000 10,000 15,000 20,000 25,000 1 9 8 1 9 8 1 1 9 8 2 1 9 8 3 1 9 8 4 1 9 8 5 1 9 8 6 1 9 8 7 1 9 8 8 1 9 8 9 1 9 9 1 9 9 1 1 9 9 2 1 9 9 3 1 9 9 4 1 9 9 5 1 9 9 6 1 9 9 7 1 9 9 8 1 9 9 9 2 2 1 2 2 2 3 2 4

Year

Hacker Tools

Source: PestPatrol.com

Categories:

  • Binder
  • Carding
  • Cracking Tool
  • Flooder
  • Key Generator
  • Mail Bomber
  • Mailer
  • Misc Tool
  • Nuker
  • Packer
  • Password Cracker
  • Password Cracking Word List
  • Phreaking Tool
  • Port Scanner
  • Probe Tool
  • Sniffer
  • Spoofer
  • Trojan
  • Trojan Creation Tool
  • Virus Creation Tool
  • Virus Source
  • Virus Tutorial
  • War Dialer
slide-57
SLIDE 57
slide-58
SLIDE 58

Requirements and use cases Design Test plans Code Test results Field feedback

Security requirements Risk analysis Risk-based security tests Static analysis (tools) Penetration testing Design Review Iterative approach Code Review

Application Security tollgates in SDLC

slide-59
SLIDE 59

References

  • https://www.metasploit.com/
  • http://valgrind.org/
  • https://www.coverity.com/
  • http://www.arachni-scanner.com/
  • http://www.openvas.org/
  • http://www.tenable.com/
  • https://www.rapid7.com/products/nexpose/
  • https://en.wikipedia.org/wiki/Application_security
  • https://portswigger.net/burp/
  • https://sourceforge.net/projects/paros/
  • http://www.binaryanalysis.org/en/home
  • http://bitblaze.cs.berkeley.edu
  • https://www.veracode.com/products/static-analysis-sast/binary-code-analysis
  • http://angr.io/
  • https://cyberpedia.in/manual-sql-injection-by-the-help-of-firebug/
  • https://www.owasp.org/index.php/OWASP_AppSensor_Project
  • https://www.modsecurity.org/
slide-60
SLIDE 60

For the curious ones!

  • Availability of services vs Denial of Services

– Akamai & “Krebsonsecurity.com” https://krebsonsecurity.com/2016/09/the- democratization-of-censorship/

  • https://projectshield.withgoogle.com/public/
slide-61
SLIDE 61

Additional reading…

slide-62
SLIDE 62

Outline

  • Software Security

– Buffer Overflow – Buffer Overflow mitigation techniques

  • Web Application Security

– Web content security: SSL – Phishing attacks – Side-channel attacks – Finding vulnerabilities – OWASP Top 10 (top 3) – Mitigation techniques – Best practices

slide-63
SLIDE 63

OWASP top 10

Open Web Application Security Project

Don’t stop at 10

slide-64
SLIDE 64
slide-65
SLIDE 65
slide-66
SLIDE 66
slide-67
SLIDE 67

SQL Injection – Illustrated

Firewall Hardened OS Web Server App Server Firewall Databases Legacy Systems Web Services Directories Human Resrcs Billing Custom Code APPLICATION ATTACK Network Layer Application Layer Accounts Finance Administration Transactions Communication Knowledge Mgmt E-Commerce

  • Bus. Functions

HTTP request

SQL query

DB Table 

HTTP response 

 "SELECT * FROM accounts WHERE acct=‘’ OR 1=1-- ’"

  • 1. Application presents a form to

the attacker

  • 2. Attacker sends an attack in the

form data

  • 3. Application forwards attack to

the database in a SQL query

Account Summary Acct:5424-6066-2134-4334 Acct:4128-7574-3921-0192 Acct:5424-9383-2039-4029 Acct:4128-0004-1234-0293

  • 4. Database runs query containing

attack and sends encrypted results back to application

  • 5. Application decrypts data as

normal and sends results to the user

Account: SKU: Account: SKU:

slide-68
SLIDE 68

Avoiding SQL Injection Flaws

  • Avoid the interpreter entirely, or
  • Use an interface that supports bind variables (e.g., prepared statements,
  • r 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

Recommendations

  • For more details, read the

https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet

References

slide-69
SLIDE 69

HTTP is a stateless protocol

slide-70
SLIDE 70

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

slide-71
SLIDE 71

How not to create a SESSION ID

h5kek4z9ha1rtrf gj75l3k7hb15rtr l8l65k45hc1rw7i p05jrj53hd1i039 5urltda1he1bn46 j5le97h9hf2yq3h po953ld7hg2awi9 t6zhj2n5hh27bn0 iu345r53hi2aw34

  • 0z43411hj2njkl

9por42o9hk3dfrz …

slide-72
SLIDE 72

How not to create a SESSION ID

h5kek4z9ha1rtrf gj75l3k7hb15rtr l8l65k45hc1rw7i p05jrj53hd1i039 5urltda1he1bn46 j5le97h9hf2yq3h po953ld7hg2awi9 t6zhj2n5hh27bn0 iu345r53hi2aw34

  • 0z43411hj2njkl

9por42o9hk3dfrz …

  • 9,7,5,3,1,9,7,5,3,1,9…
  • h,h,h,h,h,h,h,h,h,h,h,

  • a,b,c,d,e,f,g,h,i,j,k,…
  • 1,1,1,1,1,2,2,2,2,2,3,…
slide-73
SLIDE 73

Broken Authentication Illustrated

Custom Code Accounts Finance Administration Transactions Communication Knowledge Mgmt E-Commerce

  • Bus. Functions

1 User sends credentials 2 Site uses URL rewriting (i.e., put session in URL) 3 User clicks on a link to http://www.hacker.com in a forum www.boi.com?JSESSIONID=9FA1DB9EA... 4 Hacker checks referrer logs on www.hacker.com and finds user’s JSESSIONID 5 Hacker uses JSESSIONID and takes over victim’s account

slide-74
SLIDE 74

Avoiding Broken Authentication and Session Management

  • Authentication should be simple, centralized, and standardized
  • Use the standard session id provided by your container
  • Be sure SSL protects both credentials and session id at all times

Verify your architecture

  • Forget automated analysis approaches
  • Check your SSL certificate
  • Examine all the authentication-related functions
  • Verify that logoff actually destroys the session
  • Use OWASP’s WebScarab to test the implementation

Verify the implementation

  • https://www.owasp.org/index.php/Authentication_Cheat_Sheet

Follow the guidance from

slide-75
SLIDE 75

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

slide-76
SLIDE 76

Cross-Site Scripting Illustrated

Application with stored XSS vulnerability 3 2 Attacker sets the trap – update my profile

Attacker enters a malicious script into a web page that stores the data

  • n the server

1 Victim views page – sees attacker profile Script silently sends attacker Victim’s session cookie

Script runs inside victim’s browser with full access to the DOM and cookies

Custom Code Accounts Finance Administration Transactions Communication Knowledge Mgmt E-Commerce

  • Bus. Functions
slide-77
SLIDE 77

(AntiSamy)

Avoiding XSS Flaws

  • Recommendations

– Eliminate Flaw

  • Don’t include user supplied input in the output page

– Defend Against the Flaw

  • Use Content Security Policy (CSP)
  • Primary Recommendation: Output encode all user supplied input (Use

OWASP’s ESAPI or Java Encoders to output encode) https://www.owasp.org/index.php/ESAPI https://www.owasp.org/index.php/OWASP_Java_Encoder_Project

  • 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: https://www.owasp.org/index.php/AntiSamy

  • References

– For how to output encode properly, read the

https://www.owasp.org/index.php/XSS_(Cross Site Scripting) Prevention Cheat Sheet

slide-78
SLIDE 78

Interesting Reads…

  • An XSS on Facebook via PNGs & Wonky

Content Types [January 2016, link]

  • A $5,000 Google Maps XSS (by fiddling with

Protobuf) [9th March, link]

slide-79
SLIDE 79

Cross Site Request Forgery (CSRF)

  • An attack where the victim’s browser is tricked into issuing a command to a

vulnerable web application

  • Vulnerability is caused by browsers automatically including user authentication

data (session ID, IP address, Windows domain credentials, …) with each request Cross Site Request Forgery

  • What if a hacker could steer your mouse and get you to click on links in your
  • nline banking application?
  • What could they make you do?

Imagine…

  • Initiate transactions (transfer funds, logout user, close account)
  • Access sensitive data
  • Change account details

Typical Impact

slide-80
SLIDE 80

CSRF Vulnerability Pattern

  • The Problem

– Web browsers automatically include most credentials with each request – Even for requests caused by a form, script, or image on another site

  • All sites relying solely on automatic

credentials are vulnerable!

– (almost all sites are this way)

  • Automatically Provided Credentials

– Session cookie – Basic authentication header – IP address – Client side SSL certificates – Windows domain authentication

slide-81
SLIDE 81

CSRF Illustrated

3 2 Attacker sets the trap on some website on the internet (or simply via an e-mail) 1 While logged into vulnerable site, victim views attacker site Vulnerable site sees legitimate request from victim and performs the action requested <img> tag loaded by browser – sends GET request (including credentials) to vulnerable site

Custom Code Accounts Finance Administration Transactions Communication Knowledge Mgmt E-Commerce

  • Bus. Functions

Hidden <img> tag contains attack against vulnerable site Application with CSRF vulnerability

slide-82
SLIDE 82

Avoiding CSRF Flaws

  • Add a secret, not automatically submitted, token to ALL sensitive requests

– This makes it impossible for the attacker to spoof the request

  • (unless there’s an XSS hole in your application)

– Tokens should be cryptographically strong or random

  • Options

– Store a single token in the session and add it to all forms and links

  • Hidden Field: <input name="token" value="687965fdfaew87agrde"

type="hidden"/>

  • Single use URL: /accounts/687965fdfaew87agrde
  • Form Token: /accounts?auth=687965fdfaew87agrde …

– Beware exposing the token in a referer header

  • Hidden fields are recommended

– Can have a unique token for each function

  • Use a hash of function name, session id, and a secret

– Can require secondary authentication for sensitive functions (e.g., eTrade)

  • Don’t allow attackers to store attacks on your site

– Properly encode all input on the way out – This renders all links/requests inert in most interpreters See the: www.owasp.org/index.php/CSRF_Prevention_Cheat_Sheet for more details

slide-83
SLIDE 83

How do you address these problems?

  • Develop Secure Code

– Follow the best practices in OWASP’s Guide to Building Secure Web Applications

  • https://www.owasp.org/index.php/Guide
  • And the cheat sheets: https://www.owasp.org/index.php/Cheat_Sheets

– Use OWASP’s Application Security Verification Standard as a guide to what an application needs to be secure

  • https://www.owasp.org/index.php/ASVS

– Use standard security components that are a fit for your organization

  • Use OWASP’s ESAPI as a basis for your standard components
  • https://www.owasp.org/index.php/ESAPI
  • Review Your Applications

– Have an expert team review your applications – Review your applications yourselves following OWASP Guidelines

  • OWASP Code Review Guide:

https://www.owasp.org/index.php/Code_Review_Guide

  • OWASP Testing Guide:

https://www.owasp.org/index.php/Testing_Guide

slide-84
SLIDE 84

References: Tools

  • Kali Linux
  • OpenVAS (+metasploit)
  • ZAP
  • Charles Proxy
  • Apache modSecurity