Docsity

Web Application Security: Reported Web Vulnerabilities 'In the Wild', Study notes of Computer Networks

Partial preview of the text

Download Web Application Security: Reported Web Vulnerabilities 'In the Wild' and more Study notes Computer Networks in PDF only on Docsity!

CS 155

Spring 2010

Web Application Security

John Mitchell

Reported Web Vulnerabilities "In the Wild"^ Data from aggregator and validator of NVD-reported vulnerabilities

Three top web site vulnerabilitesThree

top web site vulnerabilites

SQL Injection^ ^ Browser sends malicious input to server^ ^ Bad input checking leads to malicious SQL query

Uses SQL to change meaning of

database command

CSRF – Cross-site request forgery^ ^ Bad web site sends request to good web site, usingcredentials of an innocent victim who “visits” site

Leverage user’s session at

victim sever

credentials of an innocent victim who

visits

site

XSS – Cross-site scripting^ ^ Bad web site sends innocent victim a script that

Inject malicious script into

victim sever

p

steals information from an honest web site

Inject malicious script into

trusted context

Command Injection

Code injection using

system()

Code

injection using

system()

Example: PHP server-side code for sending email$email = $_POST[“email”]$subject = $_POST[“subject”]system(“mail

$email –s

$subject < /tmp/joinmynetwork”)

system( mail Attacker can post

$email –s

$subject < /tmp/joinmynetwork )

http://yourdomain.com/[email protected] &subject=foo < /usr/passwd; lsOR http://yourdomain.com/[email protected]&subject=foo;echo “evil::0:0:root:/:/bin/sh">>/etc/passwd; ls

SQL Injection

Basic picture: SQL InjectionBasic

picture: SQL Injection

Victim Server

1

unintendedSQL

receive valuable data

2

3

Attacker

SQL query

receive valuable data 3

10

Victim SQL DB

CardSystems AttackCardSystems

Attack

CardSystems^ ^ credit card payment processing company^ ^ SQL injection attack in June 2005^ ^ put out of business^ put out of business The Attack^ ^ 263,000 credit card #s stolen from database^ ^ credit card #s stored unencrypted^ ^ 43 million credit card #s exposed^ 43 million credit card #s exposed

11

Main steps in this attackMain

steps in this attack

Use Google to find sites using a particular ASP stylevulnerable to SQL injection Use SQL injection on these sites to modify the page toinclude a link to a Chinese site

nihaorr1 com

include a link to a Chinese site

nihaorr1.com

Don't visit that site yourself! The site (nihaorr1 com) serves Javascript that exploitsThe site (nihaorr1.com) serves Javascript that exploitsvulnerabilities in IE, RealPlayer, QQ Instant MessengerSteps (1) and (2) are automated in a tool that can be configured toinject whatever you like into vulnerable sites

13

Example:

buggy login page

(ASP)

p^

ggy

g^

p g

(^

set ok = execute(

"SELECT * FROM Users

WHERE user=' "

&^

form(“user”)

AND^

p d ' " & form(“p d”) & “ '” ) AND^

pwd=' " & form(“pwd”) & “ '” );

if not ok.EOF

login success else

fail; I^ thi

l it bl?

14

Is this exploitable?

Bad inputBad

input

Suppose

user = “

'^ or 1=1 --

”^

(URL encoded)

Then scripts does:^ ok = execute( SELECTok^

= execute(

SELECT …

WHERE user=

or 1=

The^

“^ ”

causes rest of line to be ignored ^ The

”^ causes

rest of line to be ignored.

^ Now

ok.EOF

is always false and login succeeds.

The bad news:

easy login to many sites this way.

16

Even worseEven

worse

Suppose user =^ “

′^

; DROP TABLE Users

--^

Then script does:^ ok = execute( SELECT …WHERE user=

′^

′^ ; DROP TABLE Users

…^

Deletes user table

17

^ Similarly:

attacker can add users,

reset pwds,

etc.

Even

worse …

Even

worse …

Suppose user =^ ′^

;^ exec cmdshell

′net user badguy badpwd

′^ / ADD --

Then script does:^ ok^

= execute( SELECTok execute(

SELECT …

WHERE username=

′^

′^ ; exec …

If SQL server context runs as “sa”, attacker getsaccount on DB server

19

Getting private infoGetting

private info

20