Вы находитесь на странице: 1из 36

PR ing .

Tes

BE TIC T Ap
AC NE
ST ES ps
t

:
VOLUME 6 • ISSUE 4 • APRIL 2009 • $8.95 • www.stpcollaborative.com

Speak in Tongues:
The CERT C Spec

S ni f f O u t S e c u r i t y
F l a ws W i t ho u t A
F au s t i a n B a r g a i n

Don't Get Burned With


Two Impossible Choices

Turn the Hackers'


Tool Into Your App's
Security page 12
VOLUME 6 • ISSUE 4 • APRIL 2009

Contents A Publication

12
COV ER STORY
Making a Career of Evil—Using A
Hacker's Tool to Secure Your Apps
Fuzz testing turns the tables on those that would do harm. Learn about
this negative testing technique that takes penetration to a whole new level.
By Ari Takanen

Speak Security
16 Lingua Franca
Make CERT C your native tongue and
build secure applications from the start.
Developed by Carnegie Mellon Univer-
sity, the specification translates or
dinary C-language code into safe and
reliable. By Paul Humphries

Sniff Out Security


22 Flaws Without
Breaking the Skin
Depar t ments
4 • Editorial
The results are in. Here's what testers told
us about how you use the Web.
Like a pack of wild dogs, hackers are
always poking around. Build a cage 6 • Contributors
Get to know this month’s experts and the
around your app with dynamic taint pro- best practices they preach.
pogation. By Brian Chess and Jacob West
7 • Out of the Box
New products for testers.

9 • ST&Pedia
Industry lingo that gets you up to speed.
Bad Choice vs.
29 Worse Choice
10 • The Conference Report
Here's what you missed at February's Future
Test conference in NYC.
Delay release or deploy with bugs? When 33 • Best Practices
your only two options are bad and worse, Such fragile creatures, those .NET applica-
there's sometimes another way to go. tions. By Joel Shore
By Matt Love 34 • Future Test
The difference between traditional and mile-
stone consulting. By Phil Simon

Software Test & Performance (ISSN- #1548-3460) is published monthly by Redwood Collaborative Media, 105 Maxess Avenue, Suite 207, Melville, NY, 11747. Periodicals postage paid at Huntington, NY and additional mailing offices. Software Test & Performance is
a registered trademark of Redwood Collaborative Media. All contents copyrighted © 2009 Redwood Collaborative Media. All rights reserved. The price of a one year subscription is US $49.95, $69.95 in Canada, $99.95 elsewhere. POSTMASTER: Send changes of address
to Software Test & Performance, 105 Maxess Road, Suite 207, Melville, NY 11747. Software Test & Performance Subscribers Services may be reached at stpmag@halldata.com or by calling 1-847-763-1958.

APRIL 2009 www.stpcollaborative.com • 3


Ed Notes
VOLUME 6 • ISSUE 4 • APRIL 2009

Testers’ Web 2.0 Editor


Edward J. Correia
ecorreia@stpcollaborative.com

Usage Snapshot Contributing Editors


Joel Shore
Matt Heusser
Chris McMahon

We recently launched an online aimed at “friending” other people, Art Director


survey to ask about your profes- sharing photos and words and join- LuAnn T. Palazzo
sional education needs and goals. ing and interacting via common lpalazzo@stpcollaborative.com
To those of you who took a few interest groups. Sure, Facebook has
minutes to complete the survey, groups for testers. I belong to sev- Publisher
thank you. If you haven’t com- eral, including the Software Testing Andrew Muns
pleted it yet, we invite you to do so Club, Software Testing Services and amuns@stpcollaborative.com
now. A link is below. Software Testing and Quality
In addition to questions about Assurance/Control, which is by far Associate Publisher
the topics, tools, and technologies the largest with more than 2,000 David Karp
you most want to learn about, we members. Still, there were only a dkarp@stpcollaborative.com
Edward J. Correia
asked about some of the Web serv- couple hundred one-off posts,
ices you use and the social networking Web sites mainly from job seekers. Director of Events
you visit most. One third of you visit QAforums and/or Donna Esposito
Not surprisingly, more than half of you (55 Stickyminds. Of the two, QAforums is by far the desposito@stpcollaborative.com
percent) regularly visit LinkedIn, the business busier, with tens of thousands of posts and views
and social networking site. LinkedIn counts per subject compared with just a relative hand- Director of Operations
among its 36 million members ful in SQE’s forum. A few of you Kristin Muns
“executives from all Fortune 500 indicated that other Web sites were


kmuns@stpcollaborative.com
companies,” according to its part of your routine; ITToolbox
About page. When I first started (12 percent), Open Source Reprints
receiving invitations to join Testing (11 percent), DZone (5 Lisa Abelson
social networks years ago, I resis- percent) and Daniweb (2 per- abelson@stpcollaborative.com
ted, even though most were Most testers cent). But 41 percent replied that (516) 379-7097
from people I knew and trusted. none of those listed were “online
My thinking was that I had use LinkedIn forums you visited most.” Subscriptions/Customer Service
enough on my plate just to main- Of this latter group, the stand- stpmag@halldata.com
tain my own contact database regularly; about out was opensourcetesting.org, a 847-763-1958
(now 4,500 strong). Why should Web site devoted to software test-
I help maintain someone else’s a third visit ing tools. It was created and is run Circulation and List Services
professional contact list? But Ted by Mark Aberdour in his spare Lisa Fiske
Bahr, my boss at the time, urged Facebook, time. Aberdour is CEO of Kineo lfiske@stpcollaborative.com
me to give it a try. Open Source, a solution and serv-
What I realized after joining QAforums or ice provider based in the U.K.
Cover Illustration by Misha
was that these networks provide The not-for-profit Web site does
a great way to stay in touch with Stickyminds. offer a discussion forum, but it’s
contacts long since forgotten. (I lightly trafficked; the site’s main


also learned that one should not thrust is as a repository. As such,
simply invite everyone in one’s it does the job well; it’s informa-
database, as many have forgotten tive, well organized, and extreme-
me). The main takeaway is that ly well stocked.
my 548 direct connections link With the dearth of busy
me to more than five million other people, any forums out there, clearly software test and QA
President Chairman
of whom I can communicate with through a professionals need more places to interact. Andrew Muns Ron Muns
number of channels. Which ones do you use and what would you like
105 Maxess Road, Suite 207
Back to our recent survey: Nearly two in five to see done differently? If you haven’t taken our Melville, NY 11747
(38 percent) of you use Facebook, which in my one-page survey yet, please take two minutes +1-631-393-6051
fax +1-631-393-6057
experience is used for personal contact far more now and visit tinyurl.com/cmtkqt. We look for-
ward to hearing from you. ý
www.stpcollaborative.com
than for business. Its interface appears to be

4 • Software Test & Performance APRIL 2009


Contributors

You’ve heard of fuzzy math. If you turn to page 12, you’ll learn about fuzzy testing, a practice with
roots in the world of hackers. ARI TAKANEN, chief technical officer at Codenomicon, tackles the sub-
ject of our lead feature, explaining fuzz testing’s usage scenarios beyond that of penetration testing and
security auditing. Ari is a noted speaker and author on software testing and security. He conducted exten-
sive research on fuzz testing with the Oulu University Secure Programming Group, and also was involved
in the pioneering work done by the PROTOS project (1998 to 2001).

PA U L HUMPHREYS is a software engineer with LDRA Ltd., and responsible for ongoing enhancement
of LDRAs’ static code analyzer. LDRA provides solutions and services for safety-critical systems in aero-
space, defense and other industries. A veteran of software development for nearly two decades, Paul has
been with companies such as British Aerospace and GEC Marconi. He holds a masters degree in Computing
for Commerce and Industry. Beginning on page 16, Paul explains best practices for producing reliable
and secure software systems using CERT C, a secure language developed by Carnegie Mellon's Software
Engineering Institute.

As the chief scientist at Fortify Software, BRIAN CHESS is focused on develop-


ing practical solutions for securing software systems. Brian also is co-founder
of the company, which makes software security analysis tools. He holds a Ph.D.
in computer engineering from the University of California at Santa Cruz, where
he studied the application of static analysis for finding security-relevant source
code defects. His article is co-authored by JACOB WEST, who manages Fortify’s
Security Research Group. Turn to page 22 to learn how dynamic taint propa-
gation can be used to find input validation bugs with less effort and technical
savvy than typical security testing.

One key problem with security code audits is that they tend to cause more problems than they solve.
Beginning on page 29, M ATT LOVE, a software development manager at test tools maker Parasoft, helps
you solve the “one size fits all” problem of having to decide between delaying the project or going to
market as-is. Matt has been a Java developer since 1997. He holds a bachelor’s degree in computer engi-
neering from the University of California at San Diego.

TO CONTACT AN AUTHOR, please send e-mail to feedback@stpcollaborative.com.

Index to Advertisers
Advertiser URL Page Number

Hewlett-Packard www.hp.com/go/alm 36

Klocwork www.klocwork.com 28

Software Test & Performance www.stpcollaborative.com 5

Test & QA Newsletter www.stpmag.com/tqa 35

Wildbit www.beanstalkapp.com 2

6 • Software Test & Performance APRIL 2009


Out of the Box

Performance Center 9.5 Ready for ‘Web 2.0’


Hewlett-Packard in late February LoadRunner now supports Adobe’s cation.” Testers simply run the applica-
released Performance Center 9.5, Action Message Framework (AMF) and tion and Protocol Advisor presents a list
including an enterprise-grade version the RTMP format for streaming media. of all the protocols being used. “Testers
of LoadRunner platform with support “Because [developers] want [to build] can [that] there’s some Ajax, some Flex,
for more protocols and simplified per- interactive Flex apps with backend data, HTTP…They get a better picture of the
formance tracking over time. they are reaching out to backend sys- app to make sure the scripting covers all
these technologies. It’s a complex pic-
ture from a performance testing per-
spective, and validating that is a large
challenge. Now our customers can do
that testing from a single tool.”
Of particular interest to agile shops
might be new reporting capabilities that
permit quick spotting of application per-
formance trends. “For Agile, I can now say
I ran a tests on Monday, Tuesday and
Wednesday and I can quickly build a
graph to show how the apps is improving
or degrading in performance over
[those] days of the week.” You can do the
same thing in Excel now, of course, but
Iyer points out that “we provide it online,
in real time and provide for several differ-
ent metrics,” including transactions per
second, and response time of a particular
component, such a login transaction. “We
actually provide the output in tabular
form as well as in a graphical display.”

SaaSy Services
“There’s a drive toward refreshing HP has modified its support and consul-
Among Performance Center 9.5's latest fea-
existing apps to make them more inter- tures is Trending, which automates the job of ana-
tancy policies to better suit short term
active and engaging,” said Subbu Iyer, lyzing performance data from one release to the projects, now offering 1- and 3-month
senior director of products for HP next, presenting stats graphically in a browser. engagements in addition to the previous
Software and Solutions, of the move to minimum of one year. “If you need
so-called Web 2.0 standards. “That intro- tems in a high-performance way.” resources, want to leverage our skills for
duces a slew of performance issues. For For situations in which the tester testing oracle apps, let’s say, or your work-
Ajax, there are several frameworks,” he might not know which protocols are in load got higher but they don’t want to
said, for example, and referred to the use, Performance Center 9.5 introduces hire, we have the ability to do the testing
asynchronous nature of the technique. Protocol Advisor. “Developers often miss for you for a short term.” Performance
“Ajax-related architecture [also] intro- out on telling testers all the protocols or Center 9.5 and the short-term services
duces performance issues.” technology that’s embedded in the appli- became available on Feb. 24.

ment and quality analysis.


TeamInspector Gives Apps According to the company, Team
Inspector “helps minimizes the risk of

A ‘Stamp of Approval’ release failure by continuously monitor-


ing the code and core assets of any soft-
ware system, across a multi-project portfo-
Maybe it’s not like Hanes’ Inspector 12, its stamp of approval for “application lio” and presents dashboard-style all code-
but Borland’s TeamInspector applies a readiness.” The company in late related metrics of a release. In its current
series of metrics for code analysis, test February unveiled the new tool, which is version, the product includes inspectors
coverage, standards compliance and part of Borland Management Solutions for Ant, Nant, Checkstyle, Emma, JUnit
build trends before it gives applications suite for application tracking, measure- and NUnit. Pricing was not disclosed.

APRIL 2009 www.stpcollaborative.com • 7


SOASTA Keeps ’Em Down Regression Test In A
Browser Sandbox
On the BrowserFarm When testing requires closer proximity to
a browser than provided by some far-flung
cloud, there’s a way you can keep it vir-
tual and still have it running on your desk-
top. Xenocode on Feb. 23 unveiled
Browser Sandbox, a free tool that permits
any number of different browsers or
browser versions to be executed on a sin-
gle Windows machine at the same time.
Regression testing never had it so good.
Regular readers might recall coverage
on these pages of Virtual Application
Studio, Xenocode’s US$40-per-seat tool
that turns any application into a self-con-
tained executable, able to be e-mailed or
transported on a USB drive to run on any
modern Windows PC without so much as
touching the registry. Browser Sandbox
lets you do the same thing with browsers,
and download and launch them right
from the Web.
Browser Sandbox is available now at
Whether you're using multiple cloud-service providers or just one, BrowserFarm adds real-browser
loads to their virtual ones.
www.xenocode.com/browsers, where
you’re also find “sandboxed” versions of
Cloud testing company SOASTA on of Linux- and Windows-based browsers IE 6, 7 and 8, FireFox 2 and 3, Chrome,
March 11 introduced BrowserFarm, which running various application technolo- Opera and Safari.
combines the virtual load generated by its gies, combined with hundreds of thou-
CloudTest On-Demand service with that of sand of virtual instances. This gives
real browsers. According to the company, testers “the flexibility to measure end-
Real-Time Klocwork
the feature enables more realistic valida- user experience regardless of a user’s Klocwork, which makes automation tools
tion of the “last mile client-side experience location or browser choice,” he said. for source code analysis, has joined with
of Web systems.” Introductory pricing The BrowserFarm release comes on real-time operating system developer
through June 11 is set at US$500 for a 500- the heels of the Feb. 18 launch of ENEA Embedded Technology to create a
browser performance test. CloudTest Global Platform, a cloud-based version of Klocwork Insight intended to
The advantage of using real browsers load and performance testing and analy- simplify the validation of software for avi-
for testing, according to SOASTA CEO sis tool that works atop cloud platforms ation and other safety-critical systems.
Tom Lounibos, is that it allows testers “to from 3Tera, Amazon, Enomaly and Insight is Klocwork’s flagship source
understand what could lead to aban- Rackspace and streams performance data code analysis tool for C/C++, C# and Java
doned shopping carts, poor user experi- to user dashboards in real time. Pricing that works from within many integrated
ence or frozen transactions…” The sys- for the service starts at $1,000 per test- development environments, permitting
tem can simulate geographically dis- hour, including all underlying platform “developers to check in bug-free code,”
bursed loads from thousands of instances costs, tools and results analysis. according to the company. If you’re
responsible for command and control sys-
are in the process of a merger or acquisi- tems such as those in avionics, you’ll also
Don’t Lose Sleep tion, product introduction, demand for need to conform to the FAA’s DO-178B
Over Software Assets IP indemnity or are about to commer-
specification, which defines coding stan-
dards for fail-safe systems. Thanks to the
A service launched in early March by cialize a research project. It serves to
partnership, users of the tool, combined
software governance solutions company identify licensing and copyright attrib-
with ENEA’s DO-178B expertise, will allow
Protecode might help testers sleep bet- utes of open source and other software
organizations to “achieve credit for numer-
ter at night. assets of an enterprise, and reports rele-
ous objectives of DO-178B certification.”
The Software IP Audit is a service that vant obligations, similarities between two
the company says can be particularly code sets and other attributed of binaries Send product announcements to
news@stpcollaborative.com
helpful to companies that for example or source code. Pricing was not disclosed.

8 • Software Test & Performance APRIL 2009


ST&Pedia
Translating the jargon of testing into plain English

stages of a project and the designers can

Q&A: Paul Melson plan to address each of the identified


threats before work begins.
Peter Torr at Microsoft wrote a blog
post about 'Guerilla Threat Modeling'
Paul Melson is information But I think the one that that is probably the single best short
security officer at Priority would maybe surprise a few piece on threat modeling.
Health, an insurance com- folks is that password How, exactly, can we 'insert security
pany in Grand Rapids, MI. guessers/crackers are still throughout the life cycle'? What does that
he has been in IT for 13 widely used. And they're still even mean?
years, focusing exclusively widely used because they First, I think it means making security a
on security for the last seven. still work. concern that is addressed at every step of
During his career Paul has Matt Heusser and What are some common design/build/maintain process.
also consulted on matters of Chris McMahon vulnerabilities? As far as how to bake this in to the
incident response and compli- Default or weak passwords, process, I wish I had an easy answer. In its
ance for government, financial, higher SQL injection, cross site scripting. And of simplest form, someone comes to the dis-
education and manufacturing industries. course the first two are heavily used by the cussion asking, "What are our security
ST&Pedia: What's the difference botnet/malware distributors to compro- risks and how do we address them?"
between penetration and vulnerability mise a Web site and use it to attack Web Some good ideas that are practical
testing? browsers. There's still a lot of work for include requiring security testing of sys-
Paul Melson: Vulnerability testing is a developers, especially Web application tems before they can be put into produc-
subset of penetration testing, in which developers, to do around input handling. tion, using standards for commodity
the tester attempts to identify the pres- How we do we decide how much time functions like authentication and log-
ence of vulnerabilities–typically publicly and effort to invest in security? ging, and using some tried and true secu-
known vulnerabilities–in a system. Risk assessment, vulnerability scoring, rity concepts like "least privilege" and
Penetration takes this to the next level in threat modeling whatever you do and "defense in depth" at the design phase.
several ways. The main difference is that whatever you call it, at the end of the day As much as security industry pundits have
penetration testers attempt to exploit vul- you have to have a system to prioritize trashed it, defense in depth–building,
nerabilities that they find and attempt to where you focus security resources. documenting, and using mitigating con-
escalate privileges as far as they can go. Can you tell us a little more about that trols at strategic points throughout a sys-
This serves to simulate a targeted attack threat modeling thing? tem–still works very well.
by an intelligent hacker and provide the Threat modeling is the current ideal way When are we finally going to have this
client with a realistic understanding of to prioritize security spend. I should first 'security' testing thing locked down into a
the risk each vulnerability poses. Many explain what the progression is, because checklist and standardized?
penetration testers will also attempt to in the real world you can't always opt to There is already some excellent work out
identify and exploit previously unknown do threat modeling. there in the area of codifying and stan-
[industry lingo: "zero day” or “0-day"] vul- Risk assessment prioritizes security dardizing Web security testing. OWASP
nerabilities. spend based on the value of the assets has developed an excellent set of guides
What tools do you use? you are trying to protect. This is the old on secure development, code review, and
Different testers use different tools, and school, but sometimes it's all you have to security testing. I also believe that we
there is some controversy about the use go on. won't be “done” any time soon. Fifteen
of automated scanners among pen Vulnerability scoring prioritizes secu- years ago nobody was doing code review
testers. I believe based on my experience rity spend against known vulnerabili- and looking at buffer overflows. Ten
both as a consultant and a client that the ties/deficiencies by quantifying how like- years ago nobody was looking at input
use of network and Web scanning tools is ly a vulnerable or deficient system is to be checking and SQL injection. Security
prevalent even among pen testers. But attacked, the relative difficulty of a suc- testing will continue to evolve and
there are those pen testers that vehe- cessful attack, and the consequence of a progress for the foreseeable future. And
mently deny that they use scanners. And successful attack. Or, put more simply, a now that there's real money to be made
to their point, a skilled tester will always system's Vulnerability Score (or Risk on both the defensive and offensive sides
do better than a scanner. Score) is the product of its Likelihood, of Web security, you can rest assured that
In many cases, a pen tester will write a Exploitability, and Impact. new classes of vulnerabilities are right
custom tool to work on a tricky or new Threat modeling takes this goal to an around the corner. ý
vulnerability and these tools get re used additional level by analyzing a system, its Matt Heusser and Chris McMahon are career soft-
in later tests as well. Exploit frameworks environment, the transactional processes ware developers, testers and bloggers.They’re col-
and fuzzers are also frequently used in that it runs, and [develops] a detailed list leagues at Socialtext, where they perform testing
finding and exploiting zero day vulnera- of all of the potential threats against that and quality assurance for the company’s Web-
bilities. system. Ideally this happens in the design based collaboration software.

APRIL 2009 www.stpcollaborative.com • 9


Conference Report

Industry's Best
Gather in NYC For
Web-Test Confab
By Edward J. Correia

More than 100 people were gathered at


the Roosevelt Hotel in New York City in
February for FutureTest, a single-track
conference on Web testing for high-level
test managers and executives. The his-
toric mid-town location was an ideal
backdrop for this intimate management
summit, and a successful first event
organized by this magazine’s new man-
agement, Redwood Collaborative Media.
Redwood president and CEO Andy
Muns and his father, chairman Ron
Muns were on hand to and kick off the
conference, introduce the company and
state some of its goals. “In the coming
months, we’ll be introducing more edu-
cational content, news and information
and more great networking opportuni-
ties,” said the chairman. He reiterated
Redwood’s intention to focus intently on
the software testing community. “Our
goal is to give you the tools you need to
help you achieve results faster and more
easily. And we thank you for being part
Above, test-industry veteran and author Judy
of this transformation.” McKay; clockwise from top left, the introduc-
Also on hand to give presentations tion of “The Cyber Tester,” from Cigital’s Paco
were more than a dozen industry nota- Hope; Redwood chairman Ron Muns; Hope and
bles, including test-team management BrowserMob’s Patrick Lightbody, Jinesh Varia
expert Judy McKay, Scrum guru Robert of Amazon Web Services; and Edward Correia
Sabourin and Selenium core developer smiling for for the camera with Rob Sabourin.
Patrick Lightbody. Other experts in
their field were sent by Amazon, Bank that many Websites contain serious UI
of America, Cigital, eBay, Hewlett- mistakes. Pointless choices, unhelpful rity-focused talks was Ryan Townsend,
Packard, IBM, Resource Interactive, descriptions and conflicting, outdated lead security engineer of Time, Inc. In
Time and uTest. and useless content are just a few exam- addition to discussing methods for
Opening the program was Jeff ples. Some were downright hilarious, embedding security into the QA
Johnson, an expert on human-computer such as an airline booking app that lists process. Townsend discussed privacy
interface and author of the successful airports alphabetically (regardless of issues, cookie stealing, phishing, deface-
GUI Bloopers book series. He posited city) and a dialog box requesting that ment and ways to protect e-commerce
that much of the Web is not yet of com- the user “Please choose your gender,” as functions. He also touched on “Web
mercial quality, and illustrated—with if that were possible by clicking. hacking 2.0,” and pointed out that new
real examples taken from the Internet— Presenting one of a number of secu- rich interfaces based on Flash and Ajax

10 • Software Test & Performance APRIL 2009



“Our goal is to give
you the tools you
need to help you
achieve results faster
and more easily.”
Photographs by Joel Shore

– Ron Muns, Redwood Chairman

open new doors to hackers. would change the face of testing.



Flash,” by Kristopher Schultz of Re-
In this information-rich presenta- Central to the technology’s usefulness to source Interactive. That’s the company
tion, Townsend detailed the importance testers, he asserted, is its flexibility and that does Web-site development for
of vendor/partner due diligence when efficiency to configure servers when Hewlett-Packard, Sher win Williams
incorporating third-party elements into needed to strip them down when done. and Victoria’s Secret, among others.
a Website. He also covered SLAs and Such efficiencies will become ever more He described practices for the design
ultimately the importance of risk-based important to business. “As Web per- and testing of complex rich-internet
testing. “At Time we like the test/QA formance becomes more crucial for our applications from the creation of stat-
department to be involved with all stages use, it’s critical to test the performance ic-design and motion comps, behind-
of application implementation,” he said, of your Website,” he said. Varia followed the-scenes technical design, graphic
including the planning, analysis, design, with a demonstration of testing “in the production and coding, to the skin-
implementation and maintenance, cloud,” and the creation of virtual test ning and tweaking stages. Text-based
because remediation costs increase over labs. He was joined by Selenium core documentation used in the process
time, he said. Is presentation also includ- developer Patrick Lightbody, who includes a UI guide, wireframes, use
ed a warning against relying too heavily demonstrated Browser Mob, a cloud- cases and the software requirements
on automated testing. based Web-application testing tool and specification. He also covered a
Jinesh Varia, a technology evangelist Lightbody’s latest venture. process for validating the targeted
at Amazon Web Services, was next with a Perhaps one of the most polished Flash player and how to test across
demonstration of how cloud computing presentations was “Testing RIAs in a browsers and on “weak” machines. ý

APRIL 2009 www.stpcollaborative.com • 11


By Ari Takanen

uzzing is a relative newcomer to the test and automation


F scene. It’s a negative software testing method that feeds
a program, device or system with malformed or otherwise unexpected input data
with the intention of finding critical crash-level defects. I’ve found it useful for iden-
tifying critical security problems in communication software.
The tests are targeted at remote interfaces. That means that fuzzing is able to
cover the most exposed and critical attack surfaces in a system relatively well, and can
identify many common errors and potential vulnerabilities quickly and cost-effec-
tively. Only a year ago, it was mostly an unknown hacking technique that few quality
assurance specialists knew about. Today, QA engineers and security auditors alike are
turning the hacker tool against its creators. Fuzzing has become a mainstream test-
ing technique used by major companies building software and devices for critical
communication infrastructure.

Negative Requirements
To understand the principles behind fuzzing, it’s helpful to look at how it fits into the
entire software lifecycle. Since the software development process starts from require-
ments gathering, let’s first look at how the requirements for security and fuzzing can
be mapped together. A software requirement specification often consists of two dif-
ferent types of requirements. First there’s a set of positive requirements that define
how software should function. Then there’s the negative requirements that define
what software should not do. The actual resulting software is a cross-section of both.
Acquired features and conformance flaws map against the positive requirements.
Fatal features and unwanted features map into the negative requirements. The unde-
fined grey area between the posi-
tive and negative requirements
leave room for the innovative fea-
tures that never made it to the
requirements specifications or to
the design specifications but were
implemented as later decisions
during the development. These are
often difficult to test, and might
not make it to the test plans at all.
The main focus of fuzzing is not to
validate correct behavior of the
software but to explore the nega-
tive requirements.

Two Types of Fuzzers


Two automation techniques are
commonly used with fuzzing. The
major difference between the two
lies in where the “model” of the
interface is acquired. The easiest
method of building a fuzzer starts
by reusing a test case from feature
testing or performance testing—
be it a test script or a captured mes-
sage sequence—and then aug-
menting that piece of data with mutations or anomalies.
Photograph by Appleby Texas

In its simplest form, mutation fuzzing can be accomplished with bit flipping, data
insertion or other random data modifications. The idea is to try unexpected inputs.
The other fuzzing method involves building a model from communication protocol
specifications and state-diagrams.
Ari Takanen is chief technical officer at Codenomicon, which makes tools for testing software security.

www.stpcollaborative.com • 13
FUZZ TESTING

FIG. 1: FUZZING PROCESS MODEL covery of security related problems such


as overflows and boundary value condi-
tions, in order to more intelligently test
the infinite input space that is required
to try out in robustness testing.

Fuzz Buzz
The purpose of fuzzing is to find securi-
ty-critical flaws. The timing of such tests
will have heavy impact on the total cost
of the software. Therefore the most com-
mon view in analyzing fuzzing benefits is
to look at costs related to identification
and repair or security-related bugs.
Software security has a special additional
attribute to it, as most of the costs are
actually borne by the end user in the
form of maintenance, patch deployment
and damages from incidents.
Security compromises or denial of
service attacks impact the users of the
software, not the developers. This is why
the cost metrics often include the repair
costs for the developers as well as the
costs from damages to end-users. These
are often the very same metrics that you
Mutation-based fuzzers break down is the traditional approach of validating might have developed for analyzing the
the structures used in the message and verifying functionality. Perfor- needs for static analysis tools. The cost
exchanges and tag those building blocks mance testing looks at the efficiency of per bug will vary depending on which
with meta-data that helps the mutation the built system. Both exercise the sys- phase of the software lifecycle your test-
process. Similarly, in full model-based tem using valid inputs. ing efforts take place in (the earlier the
fuzzers, each data element needs to be Introduced by PROTOS protocol- better). This type of analysis is not easy
identified, but that process also can be security researchers in 1999, robustness for static analysis tools due to the rate of
automated. The information needed is testing on the other hand, looks at the false positives that do not have any signif-
often already given in the specifications system under invalid inputs, and focuses icance for security. A metric collected
that are used to generate the models on system stability, security and reliabili- early in the process might not give any
(Figure 1). ty. By comparing these three testing cat- indication of the real cost savings.
Besides information on the data egories, we can note that most feature It’s different for fuzzing. While a stat-
structures, the added meta-data also can tests map one-to-one against use-cases ic analysis tool often delivers a poor suc-
include details such as the boundary in the software specifications. Perfor- cess rate based on analyzing the real
limits for the data elements. In model- mance testing however, uses just one security impact of the found flaws, with
based fuzzing, the test generation is use-case but loops that in either a fast fuzz testing there are no false positives.
often systematic, and involves no ran- loop or in multiple parallel executions. All found issues are real and will provide
domness at all. Although many muta- In robustness testing, you build thou- a solid metric for product security
tion and block-based fuzzers often claim sands or sometimes millions of misuse- improvements.
to be model-based, a true model-based cases for each use-case. Fuzzing is one
fuzzer is based on a dynamic model that form of robustness testing, focusing on Fuzz-Test Automation
is “executed” either at runtime or off- the communication interfaces and dis- Fuzzing maps nicely to various test
line. In PROTOS research papers, this
approach of running a model during
the test generation or test execution was
called Mini-Simulation. The resulting
executable model is basically a full
implementation of one of the end-
W ASN’T FUZZY, WAS HE?
The term ‘fuzzing’ or ‘fuzz testing’ emerged around 1990, but in its original meaning
fuzzing was just another name for random testing, with very little use in QA beyond some
limited ad-hoc testing. Still, the transition to integrating the approach into software
points in the communication. development was evident even back then. From 1998 to 2001 the PROTOS project (at
University of Oulu) conducted research that had a focus on new model-based test
Fuzzing Among Other Techniques automation techniques as well as other next-generation fuzzing techniques. The purpose
Looking at different types of black-box was to enable the software industry itself to find security-critical problems in a wide
testing, we can identify three main cate-
range of communication products, and not to just depend on vulnerability disclosures
gories of testing techniques. These are
from third parties.
feature testing, performance testing
and robustness testing. Feature testing

14 • Software Test & Performance APRIL 2009


FUZZ TESTING

W
automation techniques. While differ-
ent levels of test automation are used HERE'S THE FUZZ?
in all testing organizations, fuzzing
can be added just about anywhere in While fuzzing was originally intended as a tool mainly for penetration testers and secu-
the domain. In fact, test automation rity auditors, today its usage is more widespread and diverse. Soon after the exposure
experts are often the first people that caused by PROTOS, fuzzing quickly became adopted by network equipment manufactur-
familiarize themselves with fuzzing ers for their quality assurance processes. From that, fuzzing technologies evolved into
and other related test generation tech- quality metrics for monitoring the product lifecycle and product maturity.
niques. Test automation often focuses
only on the repeatability of tests. But Perhaps because of the rapid quality improvements in network products, fuzzing soon
automation has led to significant also became a recommended purchase criterion for enterprises and pushed by vendors
improvements in test design and effi- who were already conducting fuzzing and thought that it would give them a competitive
ciency. edge. As a result, service providers and large enterprises started to require fuzzing and
The more advanced your tools, the similar testing techniques from all their vendors, further increasing the usage of fuzzing.
less work that will be required to inte- Today fuzzing is used in three phases at the software lifecycle:
grate fuzzing in your testing cycles. Not • QA Usage of Fuzzing in Software Development
all fuzzing tools are model-based, but • Regression testing and product comparisons using Fuzzing at test laboratories
fuzzing techniques are always automated • Penetration testing use in IT operations
with almost zero human involvement.
Tests are automatically generated and
As the usage scenarios range from one end to another, so does the profile of the actual
executed, and reports are also typically
users of the tools. Different people look for different aspects in fuzzers. Some users pre-
generated automatically. Most of the
fer random fuzzers, whereas others look for intelligent fuzzing. Other environments
work can be focused on analyzing and fix-
require appliance-based testing solutions, and still other test environments dictate soft-
ing the found issues.
ware-based generators. Fortunately, all of these are readily available today.
Fuzzy Tools
Comparing fuzzing tools is difficult, and compared by running them against a Fuzzing as a security-testing technique
there is no accepted method. The easiest software intentionally planted with seems to have a future. And if you don’t
way might be to enumerate he interface security vulnerabilities. Based on that plan on using it yourself, someone else—
requirements. One toolkit might sup- sample, fuzzer efficiency ranged from quite possibly a hacker—surely will. So
port about 20 or so protocol interfaces 0 percent to 80 percent. Random test- it’s best to fight fire with fire and beat
where another will cover more than 100 ing provided inefficient test results, them at their own game.
protocols. and model-based tests peaked at high- Fuzzing tools are easily accessible as
Testing a Web application requires a er efficiency. The tool with the most free open source tools as well in com-
different set of fuzzers than testing a test cases rarely was the most efficient mercial products. Fuzzing is an efficient
voice over IP (VoIP) method of finding
application. Some FIG. 2: REQUIREMENTS OF FUZZING remotely exploitable
fuzzing frameworks holes in critical sys-
are adept at testing tems, and the return
simple text-based of time and effort
protocols but pro- placed in negative
vide no help for test- testing is immediate.
ing complex struc- Finding just a single
tures such as ASN.1 flaw prior to release
or XML. Other fuzz can save enormous
tests come in costs and time
prepackaged suites resources for internal
with common pro- crisis management,
tocols such as not to mention the
SSL/TLS, HTTP, compromise to a
and UPnP. Still oth- deployed system and
ers might require damage to reputa-
you to build the tests yourself. one. Looking at the number of test tion. No bug can stay hidden if correct
The test direction and physical cases will often lead to selection of a tools are used correctly.
interfaces also can impact the usability tool that has the least intelligence in Still, there is always room for
of some tools, and some test only serv- the test generation. Pleasantly surpris- advancement, and fuzzing research and
er-side implementations in a client- ing, all planted bugs were found by at development are ongoing. ý
server infrastructure, for example. In a least one fuzzer. So in critical environ- REFERENCES
study conducted by Charlie Miller, ments, it might be good to employ a This article was based on Fuzzing for Software Security
which appears in Fuzzing for Software few solutions, rather than entrusting Testing and Quality Assurance (Artech House, 2008)
• Web site: http://www.fuzz-test.com
Security and Quality Assurance all your efforts in a single fuzzing tool • PROTOS project:
(Artech House, 2008), fuzzers were or technology. http://www.ee.oulu.fi/research /ouspg/protos/

APRIL 2009 www.stpcollaborative.com • 15


By Paul Humphries

oncerns over security have become part of the ever-increasing


C demands placed on software developers and testers. Fortunately,
there are programming standards that can duced by the software, it might still be
help identify some of the most common soft- exploitable by an attacker and result in a sig-
ware defects that can deprive software systems nificant breach of security.
of integrity. What follows is a look at some of these
Defects, bugs or mistakes in a software arti- defects and how they affect business appli-
fact represent a deviation from what is cations. Also covered are the common types
required for correct behavior. For the pur- of verification and validation (V&V) tech-
poses of this article, a software vulnerability is niques and how they can help achieve
defined as a defect that affects security when defect-free software at the outset of devel-
it is present in an application or information opment.
system.
Although the defect may be minor and Paul Humphries is software engineer with LDRA,
which makes test tools for safety-critical systems.
not affect the performance or results pro-

16 • Software Test & Performance APRIL 2009


The CERT C Standard: Lessons
In Etiquette and Protocol For Building
Secure Applications From the Start
Examples will be provided for each step dard and how it addresses security problems.
Illustration by S. Gursozla

of the V&V with real life methods to help


you fully understand the problems and how Exploitable Software Defects
to best implement the solutions. There’s Problems such as denial of service or comput-
also a focus on regulatory conformance and er resource depletion can often be traced to
programming standards, with particular ref- software malfunction or failure due to pro-
erence to the CERT C secure coding stan- gram errors. Such errors are a result of poor

APRIL 2009 www.stpcollaborative.com • 17


CERT C SPEC

TABLE 1: DEFECT TYPES “sins” originally expounded by B.


Meyer for requirements capture.
Example Defect Type Example Coding Problem Identified Error At the top level there are inappro-
Missing construct Omission of a statement, e.g.: Detected as a dataflow anom-
priate representations, missing con-
(Silence) aly – highlighting either redun-
dant variables or a potential
structs, unnecessary constructs, incor-
{
int x, y; bug. rect constructs, organization, and inad-
/* no value assigned to x */ equate constructs. Incorrect con-
y = x; structs, in particular, may be decom-
} posed to a number of levels to consid-
er the type of defects introduced by the
Unnecessary construct Control flow with unreachable or May be detected by checking
misuse of constructs such as aggrega-
(Noise) infeasible code, e.g.: each condition of the control
flow graph – highlighting either tion, modularisation, and branching
unsigned int x; redundant logic or a potential statements.
bug.
if( x < 0 ) {…} /* infeasible */ Identifying Defects, Removing
Errors, and Avoiding Failures
Incorrect constructs Array (aggregation) initialization Unpopulated array items can V&V techniques help identify if, when,
has insufficient items. be left with garbage which can
and how the development process
lead to program failure.
{ drifted from what was intended or
int iarr[3] = required by the user.
{ 1, 2 }; /* insufficient Validation focuses on producing
initialisers */ the right software system while verifi-
} cation ensures that the software is
built the right way. V&V should be evi-
dent at each stage of development and
analysis, design or coding defects, which capabilities. However, the very flexibili- conducted with reference to the out-
in turn are exploited by hackers on net- ty that appeals to developers also opens puts from previous stages. Verification
worked or Internet-facing systems.To the door for various defect types, some is at the hub of a quality process, eval-
guard against security vulnerabilities, of which are extremely difficult to rec- uating whether or not a product, serv-
software development projects need to ognize without careful analysis and ice, or system complies with a regula-
incorporate security testing and verifica- appropriate guidelines. tion, specification, or conditions
tion into all phases of a project plan. Table 1 provides one possible list of imposed at the start of a development
Historically, software validation has defect types, which when represented phase.
been weighted toward system and as a set of programming standards, may There are numerous V&V tech-
acceptance testing and performed in be checked to uncover software errors. niques that may be applied at one or
the latter stages of development. As These defect types are taken from the more phases of development, notably:
such, it consumes significant first tier of a generic tree structure of formal methods, static analysis, dynam-
resources. In this tradition, code veri- defects based on a list of the seven ic analysis, modified condition/deci-
fication has been performed manually,
usually adhering to an in-house coding
style guide. Not only is manual inspec-
tion slow and inefficient, it it’s also not
sufficiently consistent or rigorous to
uncover the variety of defects that can
B OOK 'EM, DANO
The U.S. Department of Homeland Security (DHS) has sponsored projects to identify the
source of software vulnerabilities to help understand the significance of computer security.
Notably, the National Vulnerability Database in 2004 found that 64 percent of the identified
result in errors and serious faults in
vulnerabilities are due to programming errors that could have been prevented by adhering to
large, complex software applications.
automated security checking.
Safety-critical systems such as those
developed for aerospace and automo-
The CERT Coordination Centre (CERT C Center) at Carnegie Mellon’s
tive industries incorporate an increas-
ing amount of computer-aided naviga- Software Engineering Institute (SEI) has gathered evidence on the caus-
tion and management systems, and are es of security breaches. This research has led to the formation of CERT
therefore prime candidates for careful C, a new breed of software development guidelines driven by organiza-
verification. But general-use applica- tions and institutions keen to protect their systems from attack. With
tions also deserve scrutiny, as the cost this new compliance standard available, organizations are now
of failure mounts along with their demanding that developers not only produce reliable and safe soft-
importance to the bottom line. ware, but also ensure their software systems are impenetrable.

Defect Types Detecting defects at the point of injection, rather than later in the development process, also
High-level languages such as C and C++ greatly reduces the cost of remediation and ensures that software quality is not degraded
are commonly used for diverse and far- with excessive maintenance.
reaching types of applications, due to
their inherent flexibility and powerful

18 • Software Test & Performance APRIL 2009


CERT C SPEC

sion coverage and unit testing. FIG. 1: CERT C CALLING


Redundancy, in the form of diversi-
ty, can also be practiced by the use of
two independent techniques, one
being static analysis and another,
dynamic analysis. Both can bring con-
siderable benefits.
Formal methods for tracking
requirements are based on a mathe-
matical approach to specification,
development and verification of soft-
ware and hardware systems. Formal
methods can vary from using com-
monly accepted notation to the full
formality of theorem proving. A
degree of formal specification reaps
benefits at later stages in the process
for any software application.
As in all project management, a
cost-benefit analysis must be used to
determine where, when, and how to
apply formal methods to achieve proj-
ect goals within budget. Successful use
of formal methods invariably relies on
a sharp focus: choosing the right tech-
niques and tools, and applying them
in the right way to just the right parts
of the system. ing the program. A variety of different about the structure of software and
Formal methods allow defects in analyses may be performed, but per- provides various textual and graphical
requirements and designs to be detect- haps one of the most significant is representations of the code. A static
ed earlier in development, greatly dataflow analysis. call graph, as shown in Figure 2, is one
reducing the incidence of mistakes in Dataflow Analysis is a process in example. This is used to convey struc-
interpreting and implementing cor- which the control-flow graph is anno- ture in terms of procedure calls. An
rect requirements and designs. There tated with operations on variables. upside-down tree of nodes (proce-
is much to gain by ensuring dures) linked by edges (calls
requirements are captured in to procedures) has a root, or
full, are well understood, and
are specified completely and
unambiguously.
A popular formalism adopt-
• main procedure, that fans out
to increasing lower-level
called procedures, until at the
lowest level it reaches the leaf
ed by many developers is that A file-open should nodes.
of use case specification. Use The main purpose of static
cases are employed to describe not follow a previous analysis, however, is to obtain
a system’s behaviour as it software metrics and highlight
responds to a request that orig- open of the same file without possible coding errors. If we
inates from outside of that sys- consider the “write to file”
tem. The use case technique an intervening close. example above, and the soft-
captures a system’s behavioural ware fulfilling the action of


requirements by detailing sce- opening the file, it is possible
nario-driven threads through to apply static checks to the
the functional requirements. code to uncover common
So, for example, if a user defects.
(the actor) requests to write to Using the same example, a
a file, possible scenario preconditions This form of analysis is able to reveal file open should not follow a previous
may be: data anomalies such as the use of open of the same file without an inter-
a. the file does not exist uninitialized variables, or variables vening file close, as this can lead to
b. the file does exist that have been assigned a value but dangerous race conditions resulting in
Considerations for the interaction are never referenced. abnormal program termination or
include user privileges, filtering the Within the overall process of static data integrity violations.
input and available file space. analysis, there is an initial (main) part Dynamic Analysis involves executing
Static Analysis involves the analysis of analysis that facilitates all further a program with test data and monitor-
of a program without actually execut- analysis. Specifically, it extracts details ing the process. Many aspects of test

APRIL 2009 www.stpcollaborative.com • 19


CERT C SPEC

T
‘false’, with the other conditions held
HE COST OF DEFECTS constant, produces a change in the
result of the whole decision. A mini-
Motivating the move to defect tracking by general-market software companies is the mum of (n+1) data items is needed to
cost of defects. Recall Barry Boehm’s groundbreaking work in software economics, in achieve full MC/DC.
which he quantified the relative expense to fix a bug at different times in the develop- This extra coverage means that pos-
ment lifecycle. Although his work was based on the waterfall model, and not the now sible errors will be hit and there is a
commonly used iterative development model, the underlying principle remains the greater confidence level in the code
same: that it’s a lot less expensive to correct defects during development, than to cor- when conditions are tested.
rect them after deployment. Unit Testing checks that the outputs
of a unit of code are appropriate to
The figure shows that costs should ideally track as close to the preferred trend analy- the requirements of the unit and that
sis (solid red) line as possible, as opposed to letting this slide over to the less desirable it responds in a known way under all
but often typical (dashed purple) line. In the latter scenario, developers defer all soft- input states. The sensitivity to any gen-
ware application checking to the quality and assurance phase of development which eral fault is enhanced because the out-
results in a much greater cost (black solid line). puts are examined close to the point
of generation, rather than in a com-
plete system where they can be masked
by other activities.

Regulatory Conformance And


Programming Standards
Conformance with standards stipulat-
ed by governing bodies, such as the
Federal Aviation Administration
(FAA), generally requires the applica-
tion of a number of different V&V
techniques. For instance, MC/DC cov-
erage is essential in the U.S. for certi-
fying software in avionics using the
DO-178B guidelines.
However, guidelines from organiza-
tions such as the Motor Industr y
Software Reliability Association
Boehm found that if automated software checking is applied at the implementation (MISRA) in the U.K. and CERT in the
stage, the cost is 1.6 hours per bug. However, if automated checking is delayed to after U.S. focus on eliminating defects
the software is in service, the cost is 14 hours per bug. By checking code as soon as it introduced at the coding phase using
exists and making it an integral part of a developer’s day-to-day work, software check- precisely defined programming stan-
ing reduces costs by raising the quality level of code. Similarly, if the quality of software dards.
entering testing is higher, there are fewer test failures, fewer defects, the time for test- The code checker provided by most
ing is reduced, and costs are saved.
tool vendors will normally be integrat-
ed into a static analyzer, and involves
lexical and syntactic analysis of the
source code for a single file or poten-
execution can then be subjected to dant, unreachable or infeasible. tially a complete system. Lexical analy-
subsequent analysis. With control-flow Coverage metrics may be obtained for sis is the process of converting a
tracing, the analysis determines the statements, branches or decisions, and sequence of characters into tokens or
precise path taken as control flows jumps to or within procedures. Desk- lexemes, which can then be parsed in
through the program during execu- checking code, by manually stepping context with the syntax of the pro-
tion using techniques such as array through each combination of data gramming language.
bound checking and storage alloca- inputs, rapidly becomes unmanage- Programming standards, which may
tion and deallocation. Such informa- able as the number of possible paths be either rules or advisory guidelines,
tion may be presented in a variety of increases. An automated process, are applied to the code, and any viola-
formats. Most often, however, dynamic using tools that support dynamic tions of those standards are reported.
analysis simply determines the coverage analysis, is therefore essential when Often the violations carry a severity,
of various program elements. attempting to achieve full coverage. and may be classified or filtered to
Clearly, it is desirable to establish Modified condition/decision coverage provide focus upon certain types of
that all executable code has been exer- (known as MC/DC) is a technique defects in the software.
cised by the test data. If not all code whereby a logical decision (expres-
has been covered at least once by some sion) having n conditions is executed CERT C Center and The
input data, then further datasets are with data such that altering the value Common Weakness Enumeration
required or code exists that is redun- of each condition from ‘true’ to CERT was created by the Defense

20 • Software Test & Performance APRIL 2009


CERT C SPEC

C
Advanced Resource Projects Agency trary code on a system. Dynamic mem-
(DARPA) in November 1988 to deal ory management is generally treated 'MON WORM
with Internet security problems follow- with caution due to the effect a mis-
ing the Morris Worm strike. (See take by a developer may have on the
C’mon Worm) results obtained from a program. Although intended purely as an aca-
Again with reference to the write to From a security viewpoint, resource demic exercise to gauge the size of the
file example, the CERT C Secure depletion and denial of service are the Internet, the effect of the Morris
Coding Standard provides a number underlying rationale for careful check- Worm had repercussions throughout
of guidelines aimed at removing ing of memory management code. the worldwide Internet community,
potential insecurities related to file infecting thousands of machines. Many
char* ptr = (char*)malloc (SIZE);...
input/output. if (abrt) { organizations with systems attached to
Essentially, file handling defects free(ptr); the Internet suffered damaging denial
may allow an attacker to misuse an }
of service attacks. Consequently, soft-
...
application through unchecked or ware vulnerabilities came under the
free(ptr);
unfiltered user input, i.e. the program
microscope of the U.S. government.
assumes that all user input is safe. The Bottom Line is Security
Programs that do not check user input To achieve a secure and reliable soft-
The CERT C Center is located at
can allow unintended direct execution ware system, there are a number of
Carnegie Mellon University’s Software
of commands or SQL well defined steps and
Engineering Institute (SEI). The cen-
statements (known as corresponding V&V tech-
ter was primarily established to deal
buffer overflows, SQL niques that should be
injection or other non-
validated inputs).
One example of this is
where the user is
• applied. The initial focus
in any project should be
on capturing and specify-
ing complete, unambigu-
with Internet security problems in
response to the poor perception of
security and reliability of the Internet.
For a number of years prior to tackling
required to provide a file
The automated ous requirements. programming guidelines and other
name, for the purpose of However, developers security-related activities, the CERT C
storing further input, verification of should also apply diverse Center studied and compiled cases of
which is then created. V&V techniques at all software vulnerabilities. The Secure
However if pathname is design and stages of software devel- Coding Initiative, launched in 2005,
entered together with an opment. In particular, used the database of catalogued vul-
unchecked file name, implemention the automated verifica- nerabilities, built up over a period of
this may lead to a system tion of design and imple- 12-15 years to develop secure coding
file being overwritten. artifacts leads mentation artifacts, practices in C and C++.
The guidelines in namely code, leads to
CERT C are spread across to greater greater confidence in the SEI is also working very closely with
thirteen distinct chapters quality of software. Static sponsors, such as the U.S. Department
and begin by covering confidence in analysis, through the of Homeland Security (DHS) and
language independent enforcement of appropri-
other defense agencies, to correlate
preprocessor directives, software quality. ate programming stan-
vulnerabilities with coding errors. DHS
followed by C language dards, provides a reliable
also sponsor MITRE’s Common


specifics: declarations means of removing the
Weakness Enumeration (CWE), which
and initialization through majority of defects prior
classifies software weaknesses that
to error handling and to testing.
lead to vulnerabilities. The CWE now
miscellaneous items. Common coding mis-
Of course, this takes are typically the contains references to CERT C, and
approach to the C lan- source of security vulner- vice-versa, with the intention that
guage is not uncommon, but it is the abilities in today’s software systems. weaknesses may be eliminated by fol-
emphasis upon security issues that sets CERT C can help tackle security-relat- lowing the secure coding standard.
CERT C apart from other coding stan- ed issues for C-language program-
dards. ming. Many real world attacks on soft- The philosophy that underpins the
The CERT C rule MEM31-C states ware systems have been identified as work of the CERT C Center and CWE
that developers should "[f]ree dynam- the result of exploited vulnerabilities is that the majority of vulnerabilities
ically allocated memory exactly once.” which are traceable to preventable can be traced back to a relatively
This rule can be regarded as high- defects. Indeed, relevant CERT C small number of common defects. If
lighting redundant code, which may guidelines are now referenced by these defects can be eradicated using
be confusing to the reader or make MITRE’s Common Weakness Enum- suitable automated V&V techniques
the code more difficult to understand eration CWE) database for newly dis- then as a consequence a much higher
and maintain. covered and disclosed vulnerabilities, level of software security can be
However, double-free vulnerabili- so that developers can explicitly see attained.
ties are viewed by CERT as something the association. Visit cwe.mitre.org to
that may be exploited to execute arbi- find out more. ý

APRIL 2009 www.stpmag.com • 21


Sniff Out Vulnerabilities
Without Attacking
By Brian Chess and Jacob West

strong evidence that a bug exists.


oftware bugs can lead to security failures. Bugs related to
S input validation and representation are of particular intere s t
because they lead to today’s most com- teams and quality assurance organiza-
Fault injection has a major disad-
vantage too. A test that includes inten-
tionally bad input often disrupts the
monly reported security vulnerabili- tions. typical behavior of the program. Even
ties: SQL injection, cross-site scripting, The accuracy of our analysis if no bug exists, the program will like-
and remote file inclusion. These vul- depends on rules that govern the areas ly enter an error state or simply fail to
nerabilities share the same fundamen- of the program we instrument. Users progress toward its intended outcome.
tal pattern: The absence of adequate can customize the rules to describe If the program accepts an input for-
input validation allows an attacker to important details about the program mat with a large number of interde-
supply malicious input to a program under test, such as the nature of pro- pendencies or implements a state
and cause the program to misbehave. prietary input validation mechanisms, machine with deeply nested states,
Unfortunately, crafting malicious to avoid false positives and false nega- fault injection can require a tremen-
inputs to reveal security vulnerabilities tives. For even greater accuracy, we dous number of test cases in order
is a skill that few quality assurance guide users to craft attacks against achieve good test coverage. The prob-
engineers posses. Addressing this need reported vulnerabilities and verify that lem is multiplied by the fact that dif-
is dynamic taint propagation, a tech- the attacks succeed at runtime and ferent types of bad input are required
nique that allows QA engineers to find increase confidence in the bugs we to test for different kinds of vulnera-
vulnerabilities by reusing existing report. bilities.
functional tests. Consider a Web application that
The approach described here intro- Motivation implements an online shopping cart
duces taint propagation logic as a pro- The most widely used approach to find- and checkout system with three phases
gram is loaded at runtime without ing injection vulnerabilities is to exer- (see Figure 1). The process begins
changing the program’s source code cise the target program in the same when an item is added to the cart
or binary on disk. This platform-level manner an attacker would. This is to using addItemtoCart(). Next, the pro-
integration allows us to introduce provide unexpected input and look gram accepts the customer’s informa-
security testing with very little process for feedback that indicates the pro- tion and validates it in
Photograph from Dreamstime.com

change and provides a logical collabo- gram has gone wrong. This technique enterCustomerInfo(). After the pro-
ration point for enterprise security is a form of fault injection, a common gram receives valid customer informa-
approach taken by security testers and tion, the program processes cus-
Brian Chess is chief scientist and co-founder
security testing tools. The advantage of tomer’s credit card in processCCard()
of security tool maker Fortify Software;
Jacob West manages the company’s Security
the approach is that when the pro- and completes the transaction.
Research Group. gram misbehaves because it has However, if the customer information
received unusual input, the tester has fails to pass basic validation checks,

22 • Software Test & Performance APRIL 2009


Dynamic Taint
Propagation
Can Shepherd
QA People Into
Security Testing
TAINT SECURITY

code, the program constructs and exe-


TABLE 1: SQL INJECTION BITES
cutes a dynamic SQL quer y that
SQL Injection: A SQL injection issue where external taint reached a database sink. includes a value read from an HTTP
URL: http://localhost/splc/listMyItems.do request parameter. If an attacker sup-
Source: Web Input Sink: Database plies a value such as “‘ OR 1 = 1” for
the parameter name, then the
File: org.apache.coyote.to File: com.order.splc.ItemSer WHERE clause of the quer y will
mcat5.CoyoteReques vice:201 match every row in the users table,
tFacade:295 String[]
giving the attacker access to the entire
Method: org.apache.coyote.to Method: ResultSet user database.
mcat5. java.sql.Statement.
CoyoteRequest. executeQuery(String) LISTING 1
getParameterValues List getUser(HttpServletRequest request) {
(String) ...
String user = request.getParameter("user");
Method Arguments: bean.quantity Method Arguments: ... try {
String sql = "SELECT * FROM users WHERE
Stack Trace: ... Stack Tracer: ... id='" + user + "'";
stmt.executeQuery(sql);
HTTP Request: ... HTTP Request: ... }
...
}

such as a check to ensure that the In order to identify sources (meth- Listing 2 shows the code from Listing
postal code for the billing address is ods that introduce untrusted data) and 1 modified to include representative
valid, control will not proceed and sinks (methods that untrusted data dynamic taint propagation logic around
processCCard() will never be exer- should never reach) for tainted values, program points that introduce, propa-
cised. Without focused test data, fault we instrument the program to set the gate, or potentially misuse taint. The
injection techniques will not spend as taint-storage values added to the String code added at runtime to permit taint
much time exercising processCCard(), class in cases where values are read propagation is shown in boxes. When a
and so it is more likely to miss bugs in from outside the program and could String is created or updated with untrust-
the program logic found there. be influenced by an attacker. We also ed input, a call to setTaintMarker() is
In many cases this means that fault instrument a variety of security-rele- inserted. When taint is propagated from
injection requires much more time vant methods whose arguments should one string to another, a similar call is
and effort than functional testing to not be controlled by an attacker to used to transfer the taint status to the
achieve the same level of test coverage. check that their sensitive string argu- new string. Finally, before a call to a secu-
Our experience is that many organiza- ments are not tainted. If a security-rel- rity-relevant operation, such as
tions either omit security testing evant method is invoked with a tainted executeQuery(), a call to checkTaint() is
entirely or give it only a fraction of the string, a warning is raised. inserted to check if the argument to the
resources devoted to functional test- To better understand how taint sensitive operation can be controlled by
ing. The result is that many input vali- propagation can be used to identify a an attacker.
dation problems are overlooked. vulnerability, consider the code in
Dynamic taint propagation works by Listing 1, which demonstrates a classic LISTING 2
List getUser(HttpServletRequest request) {
monitoring the target program as it SQL injection vulnerability. In the ...
runs and associating a taint marker
with user-controlled input. The taint FIG. 1: DIDN'T BREAK THE SKIN
marker propagates through the pro-
gram with the input data. If a taint
marker reaches a sensitive function processCCard ( )
before it encounters appropriate input
validation, a vulnerability is reported.

Implementation for Java enterCustomerInfo ( )


We focus our efforts on tracking taint
through string variables because dan-
gerous input in Java programs often
arrives as a string. In the Java Runtime X addItemToCart ( ) X
Environment (JRE), we modify the
java.lang.String class to include addi-
tional values that store the taint status
of each string object. We also modify
classes used to alter and combine
strings, such as StringBuffer and
StringBuilder, to allow us to propa-
gate taint between string values.

24 • Software Test & Performance APRIL 2009


TAINT SECURITY

String¬ user = request.getParameter1("user"); that contains a value read from an interfaces or parent classes in an
TaintUtil.setTaintMarker(user, 1);
try {
HTTP request parameter would inheritance hierarchy, in some cases
String sql = "SELECT * FROM users WHERE receive a higher priority than the same we are able to instrument code even
id='" + user + "'"; vulnerability caused by a value read though we have not explicitly written a
TaintUtil.setTaintMarker(sql, from a local properties file. When an rule with it in mind.
user.getTaintMarker());
TaintUtil.checkTaint(sql); error is reported, it includes details
stmt.executeQuery1(sql); about not only the type of vulnerabili- Sources of Inaccuracy
} ty, but also the specific source and sink Here we discuss ways to combat both
...
involved and the line numbers where false positives and false negatives and
}
they are located in the original pro- maximize the accuracy of results pro-
To make dynamic taint propagation gram source code. duced by dynamic taint propagation.
effortless for testers, we modify the Table 1 shows an overview of a vul- In programs where security was
bytecode for the core Java Runtime
Environment (JRE) classes, the pro- TABLE 2: A DIFFERENT BREED
gram’s bytecode and the bytecode of
SQL Injection: A SQL injection issue where external taint reached a database sink.
URL: http://localhost/splc/listMyItems.do Verified: 3
any external libraries the program
employs. We perform the instrumen-
tation at runtime by replacing the Source: Web Input Sink: Database
application server’s class loader with
File: org.apache.coyote.to File: com.order.splc.Item
one designed to rewrite classes target- mcat5.CoyoteReques Service:201
ed for instrumentation as they are tFacade:295 String[]
loaded. Performing instrumentation
Method: org.apache.coyote.to Method: ResultSet
at load-time avoids changes to the pro-
mcat5. java.sql.Statement.
gram’s source code or binary on disk CoyoteRequest. executeQuery(String)
and makes it easy to analyze multiple getParameterValues
programs loaded in the same applica- (String)
tion server. This means the program’s Method Arguments: bean.quantity Method Arguments: select id, account, sku,
build and deployment processes do quantity, price, ccno,
not have to change in order to use Return Value: ' OR 1=1-- description from item
dynamic taint propagation. Rewriting where account = 'gary'
Stack Trace: ... and quantity = '' OR
a class at runtime roughly doubles the 1=1--'
amount of time required for loading HTTP Request: ...
the class, so programs are noticeably Stack Tracer: ...
slower to start. But once a class has
HTTP Request: ...
been loaded, the additional code
required for dynamic taint propaga-
tion adds little overhead to the pro- nerability report for a SQL injection addressed during development, many
gram’s execution time. issue detected with runtime taint false positives are caused by unrecog-
Beyond tracking taint as a binar y propagation. Notice the vulnerability nized input validation because we can-
property of a string, it is often desir- report contains the URL, as well as not automatically determine whether
able to differentiate multiple sources code-level details about the source and an input validation mechanism is suffi-
of taint and track them independently. sink involved in the vulnerability. cient to mitigate a vulnerability. Doing
To address this demand, our taint so would require that we keep track of
tracking mechanism supports taint Writing Rules which specific characters and sub-
flags, which associate information The choice of which classes and meth- strings can make their way through
about sources that introduce taint with ods to instrument has a clear impact the validation logic and relate this
tainted values that they impact. Armed on the effectiveness of our dynamic information to the types of attacks pos-
with detailed information about the taint propagation approach. Instru- sible on each sink. Listing 3 shows the
source of a tainted value when it caus- ment too broadly, and the analysis will SQL injection from Listing 1 mitigated
es a vulnerability to be reported, we produce false positives (also called with whitelist validation that ensures
can report vulnerabilities more accu- false alarms). Instrument too narrow- the untrusted input contains only
rately and include more useful infor- ly, and the analysis will suffer false neg- upper and lower case characters from
mation with the vulnerabilities we atives (miss real vulnerabilities). We the English alphabet. Without knowl-
report. derived the set of classes and methods edge of the constraints Input
When taint reaches a security-sensi- to instrument from the rule set we use Util.alphaOnly() places on the input,
tive sink, we must decide what, if any, for SCA, our static analysis tool. SCA we will report a false positive on the
vulnerability to report. Our taint prop- performs taint propagation on source subsequent call to executeQuery().
agation implementation is capable of code without running it, so converting LISTING 3
fine-grained decisions about the type the rule set for use with dynamic taint List getUser(HttpServletRequest request) {
and priority of error to report depend- propagation was a fast way to create ...
String user = request.getParameter("user");
ing on which source and sink are rules for thousands of packages and if (!InputUtil.alphaOnly(user)) { // ensure user
involved. For example, a SQL query methods. Because rules can refer to matches a-zA-Z

APRIL 2009 www.stpcollaborative.com • 25


TAINT SECURITY

log.error("Invalid username specified");


cannot occur is to verify vulnerabilities string reach the vulnerable sink, we
return null;
} reported with real attack data. Users are able to report the issue as verified.
try { can create attacks that build on con- The potential sources for false neg-
String sql = "SELECT * FROM users WHERE text-specific advice reported with each atives are even more diverse than for
id='" + user + "'";
stmt.executeQuery(sql);
vulnerability to verify their feasibility. false positives. The taint propagation
} When the user mounts an attack, our implementation might be missing
... implementation checks whether the rules; taint is not tracked through
} attack makes its way to the sink identi- native code or when strings are
Our approach relies on the user to fied with taint propagation. If the decomposed into individual charac-
convey knowledge of input validation attack makes it through to the sink, ters; and cleanse rules might mistak-
mechanisms to the tool using cleanse then it’s likely that the reported vul- enly remove taint from a value that has
rules, which specify how to adjust the nerability is a real bug. This technique received insufficient validation.
taint status of values that undergo vali- for verifying bugs is much easier than Careful rule writing and an under-
dation. Cleanse rules can stipu- standing of security mecha-
late that a value is no longer nisms can help mitigate many
tainted after validation, or they
can selectively adjust the set of
taint flags associated with the
value based on nature of the

Dynamic taint propagation should
of these challenges, but even if
taint propagation is working
properly, poor functional test
coverage allow bugs to go
validation logic. In Table 1, the unnoticed. The risk of false
user could specify that negatives suggests that dynam-
InputUtil.alphaOnly() pre- not be the sole means for assuring ic taint propagation should
vents meta-character attacks not be the sole means for
such as SQL injection and elim- that a program is free from assuring that a program is free
inate the false positive SQL from injection vulnerabilities.
injection vulnerability that injection vulnerabilities.
would otherwise be reported. Integrating with Quality
Listing 3 also demonstrates Assurance
another scenario that often
leads to false positives: A con-
trol flow path that is exercised
by a functional test that cannot
• Dynamic taint propagation
can be deployed with varying
degrees of involvement from a
central security team. The
occur when attack data are present. In mounting arbitrary attacks against the degree to which a security team par-
this case, validation logic is built into program, because it provides users ticipates depends on many organiza-
the control flow structure of the pro- with contextual help constructing the tion-specific factors, but in general
gram so that when an attack is identi- attack and allows them to easily verify boils down to the ability of the securi-
fied, a benign log entry is recorded whether the attack was successful. It is ty team and quality assurance team to
and the transaction is aborted. Since particularly useful for situations in conduct each of the phases of the
normal test data are not likely to con- which an attacker could mount a so- security testing process shown in
tain attacks, the transaction will com- called “blind” injection attack, where- Figure 2. Save functional testing,
plete as expected. However, from an in it is not obvious from the program which is already conducted by the
uninformed taint propagation per- output that the attack has succeeded. quality assurance team, any of these
spective, the value used in the SQL Table 2 shows an error report for steps can be performed by a central
query is untrusted and therefore a vul- the same SQL injection vulnerability security team, a quality assurance
nerability will be reported. shown in Table 1, but this time the test team, or some combination of the
The best way to weed-out false posi- data also included the attack string “‘ two. The division of efforts depends
tives caused by control flow paths that OR 1=1.” When we witness the attack on the level of security knowledge and
familiarity with the program under
FIG. 2: WELL-HEALED SECURITY test, both of which play an integral
role in the ability of a given group to
complete each phase effectively.
To ensure that the proper rules are
being applied during instrumenta-
tion, the team must understand both
the kinds of sensitive operations the
program performs, as well as the
nature of the security ramifications of
those operations. During verification,
the ability to construct an effective
attack string or to pinpoint real vul-
nerabilities at the source-code level
must be combined with an under-

26 • Software Test & Performance APRIL 2009


TAINT SECURITY

standing of how the program operates


to exercise the potentially vulnerable
constructs and decipher sometimes
cryptic program logic. When it comes
to reporting bugs, strong remediation
advice must include the appropriate
security countermeasures and main-
tain the necessary program function-
ality.
Depending on the level of involve-
ment the central security team has in
development, they may or may not
possess the necessary understanding
of the program under test to function
autonomously. Likewise, only quality
assurance teams with above-average
security knowledge will be capable of
identifying, verifying, and driving the
remediation of security vulnerabili-
ties. Based on experience integrating
vulnerability identification into the
development phase, we anticipate
most deployments of dynamic taint
propagation to begin with heavy
involvement from the central security
team because security knowledge will
initially be the gating factor.
Gradually, as the quality assurance
teams builds a foundation of security
knowledge, the process can mature to
a point where they conduct most activ-
ities with only targeted support from
the security team.

Related Work and Tools


Taint propagation has long been rec-
ognized as a valuable security mecha-
nism, and it has been employed in
numerous forms. The most widely
used taint propagation system belongs
to the Perl programming language.
Perl taints user input to ensure that
user-supplied commands are not exe-
cuted in scripts that run with root priv-
ileges. Although Perl uses taint in an
effort to prevent successful attacks
whereas our purpose is to find bugs,
our implementations are similar to
Perl in that we taint whole objects
rather than individual characters. Also
like Perl, we remove taint when a
string passes through functions that
are typically used for input validation.
Google’s Vivek Haldar and others
describe a taint propagation system for
Java that is much like our own but
involves adding instrumentation to the Taint tracking can also be used to update the potential size of an input
program before it is run. They describe find buffer overflow vulnerabilities in buffer if the program performs
the utility of taint flags, but have not programs written in C. System archi- bounds checking. They have applied
implemented them. Like Perl, their tects Eric Larson and Todd Austin their technique to find multiple buffer
stated goal is to prevent successful instrument C programs to track the overflow vulnerabilities in OpenSSH.
attacks rather than to find bugs. potential size of user input. They Purdue associate professor of com-

APRIL 2009 www.stpmag.com • 27


TAINT SECURITY

puter science Dongyan Xu and others the PHP interpreter by Core Security tool can explore many more possible
track which bytes in a C program come Technologies (grasp.coresecurity.com) execution paths than would be practical
from user input by reserving a portion that includes taint tracking with char- to exercise during program testing. The
of the program’s address space for acter-level precision. disadvantage of static taint propagation
taint tracking. Every memory location All of the tools mentioned thus far is that less information is available
in the program has an associated entry perform taint propagation at runtime. about the true state of the program, so
in the taint map. As user input information about possible exe-
propagates through the pro- cution paths is necessarily less


gram, instrumentation added precise.
to the program updates the
taint map. The implementa- Broader QA Role
tion uses static analysis to elim- Dynamic taint propagation does
inate instrumentation in por-
tions of the code that will
The disadvantage of static taint not rely on fault injection and
does not disrupt the normal
never carry taint. The advan- behavior of the application. For
tage of this low-level and high-
propogation is that less information is this reason, it does not require
ly precise approach is that it any effort beyond standard
can be applied not only to pro-
available about program state. functional testing. By harness-
grams written in C, but also to ing the energy already devoted
programs written in interpret-
ed languages such as PHP
when the interpreter is written
in C.
• to functional testing, dynamic
taint propagation often finds
more input validation bugs than
other security testing approach-
PHP has been the target of es. And because the technique
numerous taint propagation projects, They all associate some shadow state integrates well with existing QA prac-
undoubtedly because PHP has a poor with user input and update that state tices, it seems an effective way for QA
reputation for security and is widely according to the instructions the pro- organizations to contribute to the secu-
used in applications that accept user gram executes. However, taint propaga- rity process. ý
input over a network. PHP does not tion does not have to wait until runtime.
yet have a built-in
klocworkPrint_final.pdf 1 taint propagation
03/03/09 2:52 PM A taint propagation analysis can also be REFERENCES
mechanism, but there’s a version of performed statically. A static analysis 1. http://cwe.mitre.org/documents/vuln-trends

SERIOUS
SOURCECODE
ANALYSIS
Helping software developers create more secure code.

When developing mission-critical software, developers must


quickly and accurately identify, assess and fix critical security
vulnerabilities right at their desktop before they impact anyone
else.

Klocwork’s leading static source code analysis tools provide


powerful, collaborative analysis of C/C++/C# and Java code
before code check-in, when detected issues are easiest and
less costly to fix.

Take the first step towards more secure code – get a free trial of
Klocwork Insight today at www.klocwork.com/freetrialsignup.

www.klocwork.com Learn more: Next-Generation Source Code Analysis white paper


www.klocwork.com/NextGenPaper

28 • Software Test & Performance APRIL 2009


Photograph by Andy Dean
Stuck With Two
Impossible Choices
By Matt Love

ne key problem with security code audits is that they tend to


When It O cause more problems than they solve. “One size fits all” audit
scans tend to overwhelm developers, ultimately leaving the team with a long list of known
Comes To problems, but little actual improvement. In fact, when an audit tool is used near the end
of an application development cycle and it produces a significant number of potential
issues, a project manager is put in the uncomfortable position of having to decide whether

Security to delay the project and to remediate the code, or send it out into the market as-is.
Trying to inject security into an application through testing is a fool's errand. The num-
ber of paths through an application is nearly infinite, and you can’t guarantee that all those

Auditing, paths are free of vulnerabilities. It's simply not feasible to identify and test each and every
path for vulnerabilities. Moreover, errors would be difficult to fix considering that the
effort, cost, and time required to fix each bug increases exponentially as the development

One Size process progresses. Most importantly, the bug-finding approach to security fails to address
the root cause of the problem. Security, like quality, must be built into the application.
Building security into an application involves designing and implementing the applica-
tion according to a policy for reducing the risk of security attacks, then verifying that the
Does Not policy is implemented and operating correctly. In other words, security requirements
should be defined, implemented, and verified just like other requirements.
For example, establishing a policy to apply user input validation immediately after the
Fit All Matt Love is a software development manager at Parasoft.

APRIL 2009 www.stpcollaborative.com • 29


ROCK-HARD SECURITY

FIG. 1: ONE CODE BRANCH, MULTIPLE INPUTS requirements for the specific applica-
tion under development. Obviously,
this would require considerable inter-
Input action with the internal team members
most familiar with the application.
The security policy should describe
Input Input what types of resources require privi-
leged access, what kind of actions should
be logged, what kind of inputs should be
Switch validated, and other security concerns
If specific to the application. To be sure key
requirements are not overlooked, I rec-
SQL ommend listing all the important assets
Statement that a given application interacts with,
then prioritizing them based on the
importance of protecting each asset.
SQL X Path
Statement Query Applying the Security Policy
SQL Having an effective security policy
Statement defined on paper will not translate to a
secure application unless the security
policy is followed during development.
Static analysis can be used to automati-
input values are received guarantees many regulations, such as Sarbanes- cally verify whether most security policy
that all inputs are cleaned before they Oxley, that require organizations to requirements are actually implemented
are passed down through the infinite demonstrate they have taken "due dili- in the code and identify code that
paths of the code and allowed to wreak gence" in safeguarding application requires rework. Verifying the remaining
havoc (see Figure 1). If this requirement security and information privacy. Yet, security policy requirements might
is defined in the security policy then ver- although the term is mentioned fre- require unit testing, component testing,
ified to be implemented in the code, the quently, it is not often defined. peer code review or other techniques.
team does not need to spend countless A security policy is a specification Using static analysis to automatically
resources finding every bug and testing document that defines how code needs verify the code’s compliance to applica-
every possible user input. tion-specific security policy
One of the best strategies for requirements (for instance, for
building security into the appli-
cation is to define how code
needs to be written to protect it
from attacks, then use static
• authentication, authorization,
logging, and input validation)
requires expressing
requirements as custom static
those

analysis to verify that the policy is An effective security policy on paper analysis rules, then configuring
implemented in the code. This the tool to check those custom
article provides an overview of will not translate to a secure rules. Often, developing such
how this can be accomplished. custom rules is simply a matter of
application unless it's followed. tailoring the static analysis tool’s
Establishing A available security policy rule tem-
Security Policy


plates to suit your own policy. For
Writing code without heed for instance, custom SOA security
security then later trying to iden- policy rules can be created from
tify and remove all of the appli- templates such as:
cation’s security vulnerabilities is • Do not import WSDLs
not only resource-intensive, it’s also to be written to protect it from attacks. outside a certain domain
largely ineffective. To have any chance of Security policies typically include cus- • Do not import schemas outside a
exposing all of the security vulnerabili- tom security requirements, privacy certain domain
ties that may be nested throughout the requirements, security coding best prac- Custom Java security policy rules
application, you would need to identify tices, security application design rules, can be created from templates such as:
every single path through the applica- and security testing benchmarks. • Ensure all sensitive method invo-
tion, and then rigorously test each and What do you do if your team does cations are logged
every one. A policy-based approach not already have well-defined security • Allow only certain providers to be
helps alleviate that problem. policy? If the organization has desig- specified for the ''Security.add
Security policies are espoused by nated security experts, they should be Provider()'' method
security experts, such as Open Web writing these requirements. If not, • Keep all access control methods
Application Security Project (OWASP), security consultants could be brought centralized to enforce consistency
and are mandated for compliance with in to help develop appropriate Static analysis can also be used to

30 • Software Test & Performance APRIL 2009


ROCK-HARD SECURITY

check whether code complies with } catch (ISOValidationException e) { a panacea for detecting security vul-
ISOStandardLogger.log(e);
industry-standard security best practices }
nerabilities. It is certainly valuable for
developed for the applicable language quickly exposing vulnerabilities in
and technologies. Many available static XML is no safe haven either. For SOA large code bases without requiring you
analysis tools can check compliance to applications, applying industry-standard to ever write a test case or even run the
such standards “out of the box,” and static analysis rules can expose common application (see Figure 2). However,
with no special configuration. security vulnerabilities that manifest there are some notable shortcomings:
If you are developing in Java, you themselves in XML. For example, static • A complex application has a vir-
would want to perform static analysis analysis could be used to parse the docu- tually infinite number of paths,
to check industry-standard Java securi- ment type definitions (DTDs) that define but data flow analysis can traverse
ty rules such as: XML files and check for recursive entity only a finite number of paths
• Validate an 'HttpServlet Request' declarations that, when parsed, can using a finite set of data. As a
object when extracting data from it quickly explode exponentially to a large result, it finds only a finite num-
• Use JAAS in a single, centralized number of XML elements. If such “XML ber of vulnerabilities.
authentication mechanism bombs” are left undetected, they can con- • It identifies symptoms (where the
• Do not cause deadlocks by calling sume the XML parser and constitute a vulnerability manifests itself)
a synchronized method from a denial of service attack. For instance, stat- rather than root causes (the code
synchronized method ic analysis could be used to identify the that creates the vulnerability).
• Use only strong cr yptographic following DTD that, when processed, Rules-based static analysis exposes
algorithms explodes to a series of 2100 “Bang!” ele- root causes rather than symptoms, and
• Session tokens should expire ments and will cause a denial of service: can reliably target ever y single
• Do not pass mutable objects to instance of that root cause. If you use
<?xml version=”1.0” ?>
'DataOutputStream' in the <!DOCTYPE foobar [
flow analysis, it will probably find you
'writeObject()' method <!ENTITY x0 “Bang!”> a few instances of SQL injection vul-
• Do not set custom security man- <!ENTITY x1 “&x0;&x0;”> nerabilities, but it cannot find them
<!ENTITY x2 “&x1;&x1;”>
agers outside of 'main' method all. However, if you enforce an input
...
For SOA, you would want to check <!ENTITY x99 “&x98;&x98;”> validation rule through rules-based
industry-standard rules such as: <!ENTITY x100 “&x99;&x99;”> static analysis—finding and fixing
• Avoid unbounded schema se- ]> every instance where inputs are not
quence types properly validated—you can guaran-
• Avoid xsd:any, xsd:anyType and Go with the Flow? tee that SQL injection vulnerabilities
xsd:anySimpleType Data flow analysis is often hailed as will not occur.
• Avoid xsd:list types
• Avoid complex types with mixed
content
• Restrict xsd simple types
• Use SSL (HTTPS) in WSDL serv-
ice ports
• Avoid large messages
• Use nonce and timestamp values
in UsernameToken headers
To illustrate how following such
industry-standard rules can prevent secu-
rity vulnerabilities, consider the rule
“Validate an 'HttpServletRequest' object
when extracting data from it.” Following
this rule is important because Http
ServletRequest objects contain user-mod-
ifiable data that, if left unvalidated and
passed to sensitive methods, could allow
serious security attacks such as SQL injec-
tion and cross-site scripting. Because it
allows unvalidated user data to be passed
on to sensitive methods, static analysis
would report a violation of this rule for
the following code:
String name = req.getParameter(“name”);

To comply with this rule, the code would need to be


modified as follows:
try {
String name =
ISOValidator.validate(req.getParameter(“name”));

APRIL 2009
ROCK-HARD SECURITY

I recommend using rule-based static FIG. 2: SECURE WORKFLOW


analysis to prevent vulnerabilities and
then employing flow analysis to verify
that you implemented the appropriate
preventative measures and that these Isolate Implement
measures are being applied properly. Vulnerabilities Policy
No problems should be identified at
this point. Issues found at this phase
usually indicate process problems that
should be addressed immediately. If
Vulnerabilities Security Test
flow analysis does find a problem, iden- Found? NO Succeeded
tify its root cause, then enable or create
a rule that flags the root cause. By inte-
grating this rule into your regular
enforcement process, you expose other
instances of the same problem and can Test for Regression Fix
prevent it from re-entering the code Security Test Vulnerabilities
base in the future.

Policy Implementation Workflow


As new vulnerabilities are found, isolate START HERE

them and find the root cause for the


issue. Once the root cause is identified,
a policy is implemented around it. A fix
for the vulnerability is determined, and actions and checking if any tested sce- ations are centralized (as required by
then your static analysis tool is config- narios result in security breaches. When the recommended security policy).
ured to check whether code is written penetration testing is performed in this 2. Requirements are missing: For
according to the new rule. This check- manner, it can provide reasonable assur- example, consider a Web application
ing is then added to your regularly- ance of the application's security after it that requires users to register. The reg-
scheduled static analysis tests so that has verified just a few paths through istration form takes in a variety of
moving forward, you know that the vul- each security-related function. fields, one of which is the -mail
nerability remains fixed. The policy is If the security policy was enforced address. If the e-mail field is known to
take any input, the application is miss-
ing a requirement to verify that a valid
e-mail address is input into the field.
Moreover, to ensure that code
remains secure as the application
evolves, all security-related tests (includ-
ing penetration tests, static analysis tests,
and other requirements tests) should be
added to a regression test suite, and this
test suite should be run on a regularly-
schedule basis (preferably nightly). Tests
are then performed consistently, with-
out disrupting the existing development
process. If no problems are identified,
no team intervention is required. If tests
find that code modifications reintro-
duce previously-corrected security vul-
nerabilities or introduce new ones, the
then applied across the application and using static analysis, the penetration team is alerted immediately. This auto-
organization— ensuring that every testing should reveal two things: mated testing ensures that applications
instance of that vulnerability is fixed. 1. Problems are related to security remain secure over time and also pro-
policy requirements that cannot be vides documented proof that the appli-
Penetration Testing enforced through static analysis (for cation security policy has been enforced.
Once you’re confident that the security instance, requirements involving Perl): Don’t get stuck with Sophie’s
policy is implemented in the code, a If problems are identified, either the Choice. To avoid the dilemma of hav-
smoke test can help you verify that the security policy must be refined or the ing to choose between delaying a proj-
security mechanisms operate correctly. code is not functioning correctly and ect to fix errors and deploying a prod-
This is done through penetration test- needs to be corrected. In the latter case, uct with known vulnerabilities, incorpo-
ing, which involves manually or auto- locating the source of the problem will rate security from the start—at the
matically trying to mimic an attacker's be simplified if the code's security oper- requirements phase. ý

32 • Software Test & Performance APRIL 2009


Best Practices

Without Protection, .NET


Apps are Easily Cracked
When it comes to working guage within .NET. This code. Also, there was a problem with
with .NET, protection is provides further defense the way the load test sent requests,
the key. Protection of the against an advanced such that concurrent calls were throt-
actual application from threat, especially if you tled earlier than expected. “Once
decompiling will keep are worried about piracy these issues were addressed, the
your intellectual property or the algorithms in the performance time of a single request
from being stolen. And software.” Most at risk, he was improved and the concurrent
development of far-reach- says, are developers creat- calls throttle was no longer lower
ing test cases should pro- ing financial, e-voting, than expected.” The moral, says
tect against performance and even casino software Bustamante, is that a problem may not
woes resulting from poorly that must deal with gov- be what you think it is, “so it is impor-
Joel Shore
written code. ernmental regulatory or tant to look a little deeper with appro-
Though .NET offers an efficient compliance standards. priate tools and a little common
framework for developing and deploy- Protecting code may require chang- sense.”
ing Windows applications, when ing not the overall architecture, but When exercising each tier, Busta-
deployed they provide hackers with rather the way algorithms and DLLs mante says sometimes the best test
easy access to the source code and the are packaged and put into executa- clients are those built by hand. “You
embedded intellectual property. At bles, or how they are distributed on a can also build simple load tests this
V.i. Labs, the mission is to determine server. Says DeMarines, “Once you way, but using a load testing tool such
the “crack risk level” when those apps start thinking about what’s sensitive in as that built in to Visual Studio Team
are run. your software, you will start to imple- System is usually better because with
“We’ve seen a lot of organizations ment a bit differently.” custom load tests it is sometimes diffi-
quickly migrate to .NET and what On the testing side, if test cases are cult to be sure if problems were intro-
becomes apparent when we review not complete and fail to test every duced in the load testing code or if it
their code is that by going to .NET aspect of an API, then the entire API is is indeed the application.” As for pro-
they exposed their innovation or intel- potentially flawed when you start filing, she says ANTS profiler for .NET
lectual property to be easily reverse building services and clients on top of is a must-have “to see where your code
engineered, or are subjected to piracy that logic, says Michele Leroux is spending the most time.”
issues because they had licensing rou- Bustamante, chief architect at IDesign Although with a simple load test
tines that could be easily discovered or and a Microsoft MVP for Connected and ANTS it’s relatively easy to discov-
disabled,” says product vice president Systems. er any performance issues the applica-
Victor DeMarines. “Of all the develop- Working with a customer deploy- tion will have in a production environ-
ment platforms we see, .NET apps are ing a system built with Windows ment, she cautions this doesn’t neces-
by far the easiest to crack.” Communication Foundation (WCF) sarily scale for extremely large loads,
Microsoft in the past has bundled ser vices, response times for each but says “the issues you see with simple
third-party obfuscation tools that can request were critical. After some load tests of up to 30 users uncovers 90
be used on portions of an application hand-written load testing, significant percent of problems without spending
deemed most sensitive. It provides issues with performance were discov- money on expensive third-party load
only a first line of defense against the ered, “not to mention that [the] num- testing companies.” Those companies,
occasional curious user or IT person ber of concurrent calls when testing Bustamante says, often can’t do much
looking at the code with a Reflection on a laptop was dropping very short more than you could have uncovered
tool, DeMarines says. For serious hack- once 30 users were added to the load with your own tests. ý
ers it’s not a deterrent. test,” she says. Though the IT depart-
Obfuscation, he says, is not nearly ment believed WCF to be the issue, Joel Shore is a 20-year industry veteran and
enough. “You may want to put in tamp- the IDesign team pushed for further has authored numerous books on personal com-
puting. He owns and operates Reference Guide,
er-detection code, or anti-debugging testing.
a technical product reviewing and documenta-
code, or implement third-party prod- Using Redgate’s ANTS profiler, the tion consultancy in Southborough, Mass.
ucts to encrypt the intermediate lan- team discovered bottlenecks in the

APRIL 2009 www.stpcollaborative.com • 33


Future
Future Test
Test

Traditional vs.
employees. If an organization wants to
minimize the number of external con-
sultants on an implementation, it must
ensure that the end-users on its imple-
mentation team. It must ensure that the

Milestone end-users on its implementation team are


significantly devoted to, and have suffi-
cient expertise in that system. A project’s
timeframe, complexity and scope are also
critical factors. All else being equal, con-
Organizations might recog- sultant’s arrival is known sultants called in to solve a discrete task
nize the need for consult- well in advance, end-users with no particular due date may not need
ants but remain unsure can focus on their day jobs to show up for months at a time.
about how to use them. In a during the week knowing Assuming an organization’s documenta-
traditional consulting ar- that they will devote certain tion is sufficient, a consulting firm may
rangement, a firm might days to the new system, coin- be able to perform the work required
deploy a team of individuals ciding with the arrival of the using the milestone approach. Con-
full-time at a client site for consultant. In theory, this versely, consider a client with a bevy of
forty hours a week, typically can be more efficient. complex issues, poor internal documen-
four days at ten hours per But the milestone meth- tation, and a “drop-dead” date of two
day per consultant. Under od should be used judicious- months to resolve an issue. It’s very
Phil Simon
milestone consulting, a ly; it is rife with potential dis- unlikely that the client will be able to use
client engages the firm to check in with advantages. For example, there may be consultants in a limited capacity. Minimal
them on a regular basis, ensuring that the no one keeping an eye on the implemen- consultant input and resources does not
project is meeting its goals. Then there’s tation on a daily basis, allowing goals and mean zero. On just about every new sys-
the hybrid consultant—offering equal dates to fall by the wayside. Issues may not tem implementation or upgrade, organi-
parts project manager, techie, and appli- be broached in time to address them zations must use external application
cation expert—with on-site visits every without impacting a go-live date. Also, the experts, technical resources adept at
two weeks or so. implementation’s flow may suffer. installing the application and seasoned
Consultancies typically prefer the tra- Projects that constantly start and stop project managers who have dealt with
ditional consulting arrangement, prima- often lose momentum. Projects with many of the issues likely to face the client.
rily because it maximizes billable time more interruptions have a greater Many organizations lack the expert-
and revenue. Second, consultants on the chance of failure and milestone-based ise that consultancies provide. As such,
ground can better steer clients in the approaches tend to have this limitation. organizations benefit from having
right direction throughout the project, Given the cost of consultants, many knowledgeable, on-site consultants
manage issues and ensure an overall clients might question the need to have a who ensure that the project stays on
smoother implementation. On the down- team of three or more highly paid hourly course, issues are reported and
side, traditional consulting tends to be resources on staff for forty hours per resolved and that individual objectives
the most expensive option for clients. week. As a general rule, the quality and are met. Before hiring external con-
Also, many organizations face end-user number of required external resources sultants, senior management should
availability issues. Client end-users are varies indirectly with the quality and consider budget, the state of its inter-
often overworked and too busy to spend number of available and experienced nal documentation, end-user availabil-
time with consultants. Remember, end- internal end-users. In other words, an ity and the timeframe, scope, and com-
users on implementation teams have day organization with extensive internal plexity of the issue or project. A com-
jobs while consultants are there to imple- resources and expertise needs fewer plex but poorly-documented issue that
ment the new system exclusively. external consultants. Organizations can- needs to be resolved yesterday cannot
Consultants on site are billing not expect to successfully implement be accomplished under a milestone
regardless of whether r not their skills major systems exclusively with either con- approach. At the other extreme, a sim-
are being used efficiently or not. In the sultants or end-users. Almost always, a ple but less urgent issue probably
rare event that a project is ahead of combination of each is required. doesn’t require a full-time team of
schedule, rare is the consulting compa- Another consideration is end-user consultants to solve it.
ny that attempts to move dates up or availability. Regular employees still have Most real-world scenarios fall some-
suggests that its consultants do not to do their day jobs in order for the where in between. ý
need to be on site for several weeks. organization to conduct business. For
Among the most obvious of benefits example, a payroll manager cannot set Philip Simon is an independent consultant
of the milestone consulting approach is up, test, and document a new payroll sys- serving manufacturing, health care and retail
minimal cost. To the extent that the con- tem at the expense of paying current industries.

34 • Software Test & Performance APRIL 2009


Don’t
Miss
Out

On Another Issue of The


Test & QA Rep ort
eN ew slet ter!
Each FREE biweekly issue includes original articles that
interview top thought leaders in software testing and
quality trends, best practices and Test/QA methodologies.
Get must-read articles that appear
only in this eNewsletter!

Subscribe today at w w w.stpmag.com/tqa


To advertise in the Test & QA Report
eNewsletter, please call +631-393-6054
dkarp@stpcollaborative.com

Вам также может понравиться