17 - Application Vulnerabilities and Defenses
17 - Application Vulnerabilities and Defenses
defenses
Defining the problem of web
security
• Born out of advent of dynamic scripting
technologies like:
– Javascript
– ASP
– PHP
3
Two Sides of Web Security
• Web browser (front end)
– Can be attacked by any website it visits
– Attacks lead to malware installation (keyloggers,
botnets), document theft, loss of private data
• Web application (back end)
– Runs at website
• Banks, online merchants, blogs, Google Apps, etc.
– Written in Javascript, PHP, ASP, JSP, Ruby, …
– Many potential bugs: XSS, SQL injection, XSRF
– Attacks lead to stolen credit cards, defaced sites, etc.
4
Application Attacks
• Attacks that target applications
– Category continues to grow
– Web application attacks
– Client-side attacks
– Buffer overflow attacks
• Zero day attacks
– Exploit previously unknown vulnerabilities
– Victims have no time to prepare or defend
5
Web Application Attacks
• Web applications an essential element of
organizations today
• Approach to securing Web applications
– Hardening the Web server
– Protecting the network
6
Web Application Attacks
(cont’d.)
• Common Web application attacks
– Cross-site scripting
– SQL injection
– XML injection
– Command injection / directory traversal
7
Web Applications
• Big trend: software as a (Web-based) service
– Online banking, shopping, government, etc.
– Cloud computing
• Applications hosted on Web servers
– Written in a mixture of PHP, Java, Perl, Python,
C, ASP
• Security is rarely the main concern
– Poorly written scripts with inadequate input
validation
– Sensitive data stored in world-readable files
8
How Are Legitimate Web Sites
Compromised?
• SQL Injection Attacks
• Cross-site scripting (XSS) attacks
• Vulnerabilities in the Web server or forum hosting
software (e.g., shell attacks)
• Malicious Advertisements
– Many Web sites today display advertisements hosted
by third-party advertising sites
– Volume of ads published automatically makes
detection difficult
– Random appearances further compounds the
detection
• Search Engine Result Redirection
• Attacks on the backend virtual hosting companies
9
Botnets
• Bots: Autonomous programs performing tasks
• Plenty of “benign” bots
– e.g., weatherbug
• Botnets: group of bots
– Typically carries malicious connotation
– Large numbers of infected machines
– Machines “enlisted” with infection vectors like worms
• Available for simultaneous control by a master
• Size: up to 350,000 nodes
10
“Rallying” the Botnet
• Easy to combine worm, backdoor functionality
• Problem: how to learn about successfully
infected machines?
• Options
– Email
– Hard-coded email address
11
Botnet Control
Dynamic
DNS
Infected Botnet
Machine Controller
(IRC server)
• 1998-2000: Trojans
– BackOrifice, BackOrifice2k, SubSeven
14
Botnet Detection and Tracking
• Network Intrusion Detection Systems (e.g., Snort)
– Signature: alert tcp any any -> any any (msg:"Agobot/Phatbot
Infection Successful"; flow:established; content:"221
16
Using DNS Traffic to Find Controllers
• Different types of queries may reveal info
– Repetitive A queries may indicate bot/controller
– MX queries may indicate spam bot
– PTR queries may indicate a server
• Usually 3 level: hostname.subdomain.TLD (top-level
domain)
• Names and subdomains that just look rogue
– (e.g., irc.big-bot.de)
17
DNS Monitoring
• Command-and-control hijack
– Advantages: accurate estimation of bot
population
– Disadvantages: bot is rendered useless; can’t
monitor activity from command and control
• Complete TCP three-way handshakes
– Can distinguish distinct infections
– Can distinguish infected bots from port scans,
etc.
18
Traffic Monitoring
• Goal: Recover communication structure
– “Who’s talking to whom”
19
New Trend: Social Engineering
• Bots frequently spread through Instant Messenger(IM)
– A bot-infected computer is told to spread through IM
– It contacts all of the logged in buddies and sends them a
link to a malicious web site
– People get a link from a friend, click on it, and say “sure,
open it” when asked
20
Botnet Operation
• General • Redirection
– Assign a new random nickname to the bot – Redirect a TCP port to another host
– Cause the bot to display its status – Redirect GRE traffic that results to proxy
– Cause the bot to display system information PPTP VPN connections
– Cause the bot to quit IRC and terminate itself
–
–
Change the nickname of the bot
Completely remove the bot from the system
• DDoS Attacks
– Display the bot version or ID – Redirect a TCP port to another host
– Display the information about the bot – Redirect GRE traffic that results to proxy
– Make the bot execute a .EXE file PPTP VPN connections
21
Early Botnets: AgoBot (2003)
• Drops a copy of itself as svchost.exe or
syschk.exe
22
PhatBot (2004)
• Direct descendent of AgoBot
• More features
– Harvesting of email addresses via Web and local
machine
– Steal AOL logins/passwords
– Sniff network traffic for passwords
• Social-engineering schemes
– Spoofed emails direct users to counterfeit web sites
– Trick recipients into divulging financial, personal data
24
Which web sites are being phished?
25
Botnet Application: Click Fraud
• Pay-per-click advertising
– Publishers display links from advertisers
– Advertising networks act as middlemen
• Sometimes the same as publishers (e.g., Google)
• Motivation
– Competition between advertisers
– Revenue generation by bogus content provider
26
Botnet detection
• Botnet membership detection
– Existing techniques
• Require special privileges
• Disable the botnet operation
– Under various datasets (packet traces, various
numbers of vantage points, etc.)
• Phishing detection
27
Prevention
• Architectural considerations
– Properly-Segmented Network
– Firewalls Between Segments
– Input Validation
• Third-Party Tools
– Vulnerability Scanners
28
Prevention –
Architectural Considerations
• 3-Tier/Layer design approach – minimize
the attack surface
– UI/Interface
– Logic
– Data
29
Prevention –
Architectural Considerations
• Network Topology
30
Prevention –
Third-Party Tools
• Vulnerability Scanners
– Most will probe the web application for a set
of known security holes.
– Nikto
• Aware of “over 3300 potentially dangerous
files/CGIs, versions on over 625 servers, and
version specific problems on over 230 servers. “
(Nikto Website)
31
Conclusions
1. Defense is shifting from network to application
layer.
Firewalls, anti-virus, SSL input validation, WAF
2. Vulnerabilities should be identified.
1. Static analysis of source code.
2. Web proxies and scanners for testing.
3. Vulnerabilities should remediated.
1. Web application firewalls for immediate short-term
fixes.
2. Repairing source code for long term fixes.
32
Client side security
33
Three components to security
• Three perspectives
– User’s point of view
– Server’s point of view
– Both parties
• Three parts
– Client-side security
– Server-side security
– Document confidentiality
34
Client-side security
• Measures to protect the user’s privacy and
the integrity of his computer
• Example technological solutions
– Protection from computer viruses and other
malicious software
– Limit the amount of personal information that
browser’s can transmit without the user’s
consent
35
GETTING ONTO A USER’S COMPUTER
37
Document confidentiality
• Measures to protect private information
from being disclosed to third parties.
• Example risks:
• Solutions range
– Password to identify users
– Cryptography
38
Client-Side Attacks
• Web application attacks are server-side
attacks
• Client-side attacks target vulnerabilities in
client applications
– Interacting with a compromised server
– Client initiates connection with server, which
could result in an attack
39
Client-Side Attacks (cont’d.)
• Client-side attacks are performed on
Active Content
• Java applets, Active X controls, JavaScript, and
VBScript
40
Client-Side Attacks (cont’d.)
• Drive-by download
– Client computer compromised simply by viewing a Web
page
– Attackers inject content into vulnerable Web server
• Gain access to server’s operating system
– Attackers craft a zero pixel frame to avoid visual detection
– Embed an HTML document inside main document
– Client’s browser downloads malicious script
– Programs that interpret or execute instructions embedded
in downloaded objects
– Instructs computer to download malware
41
Client-Side Attacks (cont’d.)
• Code can be embedded into graphic images
causing harm to your computer
• Plug-ins are used to play audiovisual clips,
animated graphics
– Could contain ill-intentioned commands hidden
within the object
– http://home.netscape.com/plugins/
• E-mail attachments can contain destructive
macros within the document
42
Client-Side Attacks (cont’d.)
• Header manipulation
– HTTP header contains fields that characterize
data being transmitted
– Headers can originate from a Web browser
• Browsers do not normally allow this
• Attacker’s short program can allow modification
• Examples of header manipulation
– Referer
– Accept-language
43
Client-Side Attacks (cont’d.)
• Referer field indicates site that generated the
Web page
– Attacker can modify this field to hide fact it came
from another site
– Modified Web page hosted from attacker’s computer
• Accept-language
– Some Web applications pass contents of this field
directly to database
– Attacker could inject SQL command by modifying
this header
44
Client-Side Attacks (cont’d.)
• Cookies and Attachments
– Cookies store user-specific information on user’s local
computer
– Cookies remember user names, passwords, and other
commonly referenced information
• Web sites use cookies to identify repeat visitors
• Examples of information stored in a cookie
– Travel Web sites may store user’s travel itinerary
– Personal information provided when visiting a site
• Only the Web site that created a cookie can read it
45
Client-Side Attacks (cont’d.)
• First-party cookie
– Cookie created by Web site user is currently
visiting
• Third-party cookie
– Site advertisers place a cookie to record user
preferences
• Session cookie
– Stored in RAM and expires when browser is
closed
46
Client-Side Attacks (cont’d.)
• Persistent cookie
– Recorded on computer’s hard drive
– Does not expire when browser closes
• Secure cookie
– Used only when browser visits server over
secure connection
– Always encrypted
47
Client-Side Attacks (cont’d.)
• Flash cookie
– Uses more memory than traditional cookie
– Cannot be deleted through browser
configuration settings
– Flash cookie settings can be changed
• Cookies pose security and privacy risks
– May be stolen and used to impersonate user
– Used to tailor advertising
– Can be exploited by attackers
48
Client-Side Attacks (cont’d.)
• Session hijacking
– Attacker attempts to impersonate user by
stealing or guessing session token
• Malicious add-ons
– Browser extensions provide multimedia or
interactive Web content
– Active X add-ons have several security
concerns
49
Session hijacking
50
Client-Side Attacks (cont’d.)
• Buffer overflow attacks
– Process attempts to store data in RAM beyond
boundaries of fixed-length storage buffer
– Data overflows into adjacent memory locations
– May cause computer to stop functioning
– Attacker can change “return address”
• Redirects to memory address containing malware
code
51
Buffer overflow attack
52
How to Protect Yourself
(Client side)
• Update and Patch Software
– Get latest OS, Browser, Application patches
– Browser Plug-in updates often forgotten
• Endpoint Protection Software
– Anti-virus software for signature based detection and behavioral
monitoring
– Update Protection Software Subscription
• Could miss 70,000 new unique virus variants for one week
• Be Suspicious
– Avoid things that seem too good to be true
• Adopt Strong Password Policy
• Client/server communication using data (XML/JSON) rather than
presentation (HTML.)
53