Web Apps Security For Dummies
Web Apps Security For Dummies
scanning needn't
Compliments of
be scary!
Discover:
Why web security
matters
n
o
i
t
a
c
i
l
p
p
Web A
Security
ition
Qualys Limited Ed
ain English
Explanations in pl
formation
Get in, get out in
vigational aids
Icons and other na
Top ten lists
A dash
etips.dummies.com
An electronic version of
this book is available
at www.qualys.com/
wasfordummies
ISBN: 978-1-119-99487-9
Not for resale.
Mike Shema
Scan your
website for
vulnerabilities
QualysGuard Awards
QualysGuard is overwhelmingly recognized as the leader in its
space. QualysGuard has won awards ranging from Best Vulnerability
Management Solution, Best Security Product, Best Security Company,
Best Network Protection Service, and much more!
Web Application
Security
FOR
DUMmIES
by Mike Shema
Publishers Acknowledgements
Were proud of this book; please send us your comments through our Dummies online
registration form located at www.dummies.com/register/.
Some of the people who helped bring this book to market include the following:
Acquisitions, Editorial and Media
Development
Corporate & Custom Publishing:
Scott Smith
Project Editor: Rachael Chilvers
Executive Project Editor: Daniel Mersey
Composition Services
Project Coordinator: Kristie Rees
Layout and Graphics:
Samantha K. Cherolis
Introduction
Foolish Assumptions
In writing this book, we assume that you:
Work in a mid- to large-sized organization and know that
you have to secure web applications, but you arent sure
whats required or what you need to do.
Are familiar with information technology and managing
its operations.
Want to discover the easiest, most effective and direct
way to improve web application security.
Part I
Head to www.verizonbusiness.
com/resources/reports/
rp_2010-data-breachreport_en_xg.pdf for more
information.
Defense is in disarray. Quite often,
theres no clear organizational
accountability for web application
security, based on the Ponemon
Institutes April 2010 study, State of
Web Application Security. According
to respondents: 70 per cent say their
organizations devote insufficient
resources for web application security; 34 per cent of urgent vulnerabilities remain unfixed; 38 per cent
say fixing one vulnerability takes
more than 20 hours of developer
time; and 55 per cent say developers
are too busy to fix security flaws.
Visit www.imperva.com/docs/
AR_Ponemon_2010_State_
of_Web_Application_
Security.pdf for the full story.
Improving Security in
Web Applications
Web application vulnerabilities are often outside the traditional
expertise of network managers, even if their main job is
network security. The built-in obscurity of web application
vulnerabilities helps them evade traditional network defenses
unless an organization takes deliberate countermeasures.
Unfortunately, theres no silver bullet for detection! As with
network security, the best strategy is a multi-layer approach.
Detection and remediation may require source code analysis.
Detecting some web application vulnerabilities may require
on-site penetration testing.
The good news is that most prevalent web application
vulnerabilities can be easily detected with an automated
scanner. As youll see later in this book, scanning web
applications acts to supplement and compliment manual
testing by performing likely attacks on target applications.
Scanning web applications has even become a strategic
requirement in some regulations. For example, the Payment
Card Industry Data Security Standard (PCI DSS) version 2.0
now requires all merchants accepting payment cards to pass
quarterly scans for vulnerabilities in web applications.
10
Part II
Establishing a
Web Application
Security Program
In This Part
Designating someone to lead web application security
Using the software development lifecycle to address risks
Adding applications to enterprise vulnerability management
Using tools to automate the web application security program
12
13
14
Secure development
The Secure Development phase is all about building security into web applications right from their inception. This is
what commercial software companies do because customers
expect what they license to be secure. This isnt an automatic
process, however, so as your organization strives to be smart
with its efforts to secure applications on its websites, it needs
to provision for several elements. These include:
Secure SDLC. The software development life cycle is
where your organization establishes best practices for
secure coding, testing, and proving that software is safe.
Static Analysis. This entails line-by-line analysis of code
for errors or improper implementations of open source
modules. So-called white box tools (testing code structure) can help automate this process.
Dynamic Analysis. Tools of the black box variety (functionality testing) attack and try to break running applications. They dont analyze source code.
Secure deployment
Web applications are deployed when deemed functional
within specifications, and when theyre secure. Upon deployment, ensuring their security requires two new elements:
15
Secure operation
The operational phase includes detection and reaction to
actual vulnerabilities and potential exploits. Ideally, the security team leads this process with participation by programmers and other application experts as required. New elements
for the operational phase include:
Web Application Firewall (WAF). This tool can help
provide visibility into web application traffic. It also can
block known attacks.
Activity Monitoring. An organization needs perpetual
visibility on the operations and security of the web
applications, databases powering their operation, and
systems that host operations and provide connectivity.
Automated tools can provide this visibility and instantly
alert the security team when policy is violated.
In addition, you need to continue Vulnerability Scanning and
Penetration Testing. Success is only as good as results from
the latest security scan.
16
17
18
An auditors perspective
As someone whos responsible for
network and application security,
youre frequently urged to think like
a hacker in order to create defenses
that provide strong protection. If
youre responsible for helping your
company comply with various regulations for security, its likewise helpful to think like an auditor. Heres
the auditors perspective on web
application security:
I am a Certified Public
Accountant at a national CPA
firm where I perform SarbanesOxley, Service Organization
Controls Report (SOC, formerly
called SAS70), Payment Card
Industry Data Security Standard,
and other types of IT audits.
Clients come in different shapes,
sizes, and states from a policy
controls perspective. The easiest audits for me are when its
clear that the client has a continuous and consistent compliance program. I have some
really great clients who generate monthly reports to show that
they use tools to monitor their
web applications, networks,
and systems for compliance,
and they make those reports
available to me. The reports
are hard evidence that a client
has the required policies and
procedures and that they actually follow them. From an auditors perspective, its clear that
19
20
Part III
22
23
24
25
26
27
28
Manual testing by an expert will always be the most comprehensive and accurate way to determine a sites security, but
even the most accomplished security testers incorporate
tools into their work.
29
30
31
32
Cross-site scripting
A web application has two fundamental elements: the software that runs on your sites servers, and the HTML that
displays in a visitors browser. The browser is required for
visitors to see and interact with your site. The browser does
this by executing the mixture of HTML and JavaScript it
receives from a website in much the same way a binary program is launched on the desktop.
Attackers take advantage of the browsers execution environment with exploits like cross-site scripting (XSS). Web applications often customize their content for each visitor. For
example, many sites greet a user whos just logged in with a
brief message somewhere in the page:
<div id=first_name><b>Welcome, Mike!<b></
div>
Notice that the name, Mike, is mixed in directly with the
pages HTML. The site has put this content together on the fly
by inserting the users first name. If this mixture of HTML and
data isnt handled carefully, an attacker can directly influence
the browsers actions. For example, what if the first name happened to contain the <script> tags used to execute JavaScript?
<div id=first_name><b>Welcome,
Mike<script>evil_function()</script>!<b></
div>
In the preceding example, the insides of evil_function( ) are
left to your imagination, but real-world attacks have included
everything from adding followers on social networking sites,
to launching phishing attacks, to downloading malware.
Cross-site scripting attacks dont have to cross sites or necessarily use JavaScript to be effective, but the term cross-site
scripting has been commonly used in a generic sense for
more than a decade. A scanner looks for this type of problem
by injecting HTML and JavaScript payloads into links, forms,
and even cookies, and then watches the web application for
signs of subversion to its regular HTML content.
33
SQL injection
Cross-site scripting occurs in the browser through security
failures in a websites server-side code and HTML content. A
different set of vulnerabilities called SQL injection result from
problems in the sites server-side code.
Databases are the central players here, for they store the
information that sites need to display customized content,
and store the comments, orders, and profiles of its visitors.
An attack using SQL injection piggybacks malicious database
statements onto values otherwise used by the site to make
legitimate queries. For example, a website may use an id
parameter to track products in its catalog:
http://web.site/products.page?id=19
Just like an attacker, a scanner looks for SQL injection problems by adding special characters to the id value. One of the
usual characters is a single quote because it serves as a delimiter for values, usually strings or sequences of characters,
within SQL statements. Your site is in serious trouble if an
attacker can change the syntax of a SQL statement, perhaps
by changing a record lookup to grab data from another table.
Other avenues of attack leverage SQL injection to execute
commands on the databases server.
The first step towards determining if a web application is
vulnerable to SQL injection is watching for specific error messages when link parameters and form fields have special characters or garbage data thrown into them. In the worst case, a
website will serve the same verbose error message only seen
by a developer. Ideally, the web application should return no
detailed information when reacting to attempts at SQL injection. Remember, information is power, so providing less of it
to an attacker helps keep your site more secure.
Information disclosure
Not all vulnerabilities lead immediately to compromise, but
you cant be complacent about the danger of a breach. Some
vulnerabilities, such as information disclosure problems, can
34
35
36
37
38
Part IV
Introducing
QualysGuard WAS
In This Part
Understanding what QualysGuard WAS can do for you
Automating the website crawl for a thorough, efficient scan
Testing web applications for an accurate ID of vulnerabilities
Scaling the solution scan websites of any complexity
40
41
42
43
Authenticated scanning
Some web applications require authenticated access to
the majority of their functionality. With QualysGuard WAS,
authenticated scanning can be configured for two different
situations: server-based authentication (HTTP Basic, Digest,
NTLM, or SSL client certificates) and HTML forms (think of
login pages for email or banking sites). Server- and form-based
authentication may be combined.
Configuring scans to use HTML form-based authentication
is simple merely supply a valid username and password.
Throughout the crawl, QualysGuard WAS watches for login
forms. When encountered, it applies some logic to complete
the appropriate fields required for processing form. All this
is done automatically behind the scenes, including detailed
profiling to ensure the scanner stays logged in once it finds
the login page.
Scanning your web applications may trigger exceptions
requiring more advanced configuration. Some web applications use complex login forms that prevent WAS from completing a proper profile. In these situations, you may need to
create a customized authentication record. The customized
authentication record uses the name/value pairs of each input
field within a form.
Make sure the credentials supplied to QualysGuard WAS are
valid! The reason a scan fails to authenticate to a website may
be as simple as a typo in the username or password.
44
45
46
47
The test phase typically uses 90 per cent or more of the time
required to complete a full scan. As mentioned above, you can
reduce the scan time by including fewer Qualys IDs. For example, you could run one scan that just looks for XSS-related
QIDs. Running fewer tests significantly improves scan times.
However, network latency and poor server responsiveness
also contribute to longer scans. Unfortunately, theres nothing
WAS can do to reduce the effect of those on a scan.
48
49
50
51
52
Part V
54
55
56
57
58
r! TM
UK editions
BUSINESS
Body Language For Dummies
978-0-470-51291-3
British Sign Language
For Dummies
978-0-470-69477-0
Business NLP For Dummies
978-0-470-69757-3
978-0-470-51806-9
978-0-470-77930-9
978-0-470-71382-2
FINANCE
978-0-470-99280-7
978-0-470-77930-9
978-0-470-69515-9
HOBBIES
978-0-470-75857-1
Available wherever books are sold. For more information or to order direct go to
www.wiley.com or call +44 (0) 1243 843291
08079_p1
978-0-470-69960-7
ur horizons and ac
Helping you expand yo
COMPUTER BASICS
Access 2007 For Dummies
978-0-470-04612-8
Adobe Creative Suite 3 Design
Premium All-in-One Desk Reference
For Dummies
978-0-470-11724-8
AutoCAD 2009 For Dummies
978-0-470-22977-4
978-0-470-27759-1
978-0-470-13728-4
978-0-471-75421-3
DIGITAL LIFESTYLE
978-0-470-25074-7
978-0-470-39062-7
978-0-470-42342-4
978-0-470-39700-8
978-0-470-32725-8
978-0-470-34502-3
Available wherever books are sold. For more information or to order direct go to
www.wiley.com or call +44 (0) 1243 843291
06439_p4
QualysGuard Awards
QualysGuard is overwhelmingly recognized as the leader in its
space. QualysGuard has won awards ranging from Best Vulnerability
Management Solution, Best Security Product, Best Security Company,
Best Network Protection Service, and much more!
Web application
scanning needn't
Compliments of
be scary!
Discover:
Why web security
matters
n
o
i
t
a
c
i
l
p
p
Web A
Security
ition
Qualys Limited Ed
ain English
Explanations in pl
formation
Get in, get out in
vigational aids
Icons and other na
Top ten lists
A dash
etips.dummies.com
An electronic version of
this book is available
at www.qualys.com/
wasfordummies
ISBN: 978-1-119-99487-9
Not for resale.
Mike Shema
Scan your
website for
vulnerabilities