Copyright © 2006 - The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.

Slides:



Advertisements
Similar presentations
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Advertisements

Spring Roo and the Cloud Shekhar Gulati.
Requirements Engineering Processes – 2
Explosive Security Testing Tools with XPath Path X.
IS 6116 Introduction – 10 Jan Lecturer Details Aonghus Sugrue Website: aonghussugrue.wordpress.com
Harbinger Systems Pvt. Ltd. System Test Automation in Agile Environments using Open Source Technologies Asheesh Choksi Associate Test Architect Harbinger.
1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 2 Getting Started.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Chapter 1 The Study of Body Function Image PowerPoint
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
Myra Shields Training Manager Introduction to OvidSP.
Nick Feamster CS 6262 Spring 2009
SecuBat: An Automated Web Vulnerability Detection Framework
UNITED NATIONS Shipment Details Report – January 2006.
By Rick Clements Software Testing 101 By Rick Clements
HL7 Project Management Tool Overview for HL7 Project Facilitators
18 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Introduction to Web Services.
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
Introduction to HTML, XHTML, and CSS
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
1 Click here to End Presentation Software: Installation and Updates Internet Download CD release NACIS Updates.
Excel Functions. Part 1. Introduction 2 An Excel function is a formula or a procedure that is performed in the Visual Basic environment, outside the.
1 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Brown Bag – Behaviour Driven Development with Specflow Brown Bag – Behaviour Driven Development.
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
© Telcordia Technologies 2004 – All Rights Reserved AETG Web Service Tutorial AETG is a service mark of Telcordia Technologies. Telcordia Technologies.
Configuration management
Software testing.
Acceptance Testing vs. Unit Testing: A Developers Perspective Owen Rogers Rob Styles
Unit Testing Australian Development Centre Brisbane, Australia.
Campaign Overview Mailers Mailing Lists
Introducing WebDewey 2.0. Introducing WebDewey 2.0.
+ Introduction to JUnit IT323 – Software Engineering II By: Mashael Al-Duwais 1.
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
© 2008 Security Compass inc. 1 Firefox Plug-ins for Application Penetration Testing Exploit-Me.
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
© 2012 National Heart Foundation of Australia. Slide 2.
Copyright © 2013 by John Wiley & Sons. All rights reserved. HOW TO CREATE LINKED LISTS FROM SCRATCH CHAPTER Slides by Rick Giles 16 Only Linked List Part.
Lilian Blot VARIABLE SCOPE EXCEPTIONS FINAL WORD Final Lecture Spring 2014 TPOP 1.
Services Course Windows Live SkyDrive Participant Guide.
Chapter 10 Software Testing
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
Implementation Architecture
Presented by Douglas Greer Creating and Maintaining Business Objects Universes.
How creating a course on the e-lastic platform 1.
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
Analyzing Genes and Genomes
Chapter 9 Interactive Multimedia Authoring with Flash Introduction to Programming 1.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Chapter 12 Working with Forms Principles of Web Design, 4 th Edition.
Essential Cell Biology
Intracellular Compartments and Transport
PSSA Preparation.
Essential Cell Biology
SESSION ID: Continuous Monitoring with the 20 Critical Security Controls SPO1-W02 Wolfgang Kandek CTO.
RefWorks: The Basics October 12, What is RefWorks? A personal bibliographic software manager –Manages citations –Creates bibliogaphies Accessible.
Presentation 10 SOAP on the Microsoft Platform (.NET)
1 Unit Testing with JUnit CS 3331 Fall 2009 Kent Beck and Eric Gamma. Test Infected: Programmers Love Writing Tests, Java Report, 3(7):37-50, Available.
Profile. 1.Open an Internet web browser and type into the web browser address bar. 2.You will see a web page similar to the one on.
South Dakota Library Network MetaLib User Interface South Dakota Library Network 1200 University, Unit 9672 Spearfish, SD © South Dakota.
TIDE Presentation Florida Standards Assessments 1 FSA Regional Trainings Updated 02/09/15.
What’s new in WebSpace Changes and improvements with Xythos 7.2 Effective June 24,

Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
Unit, Regression, and Behavioral Testing Based On: Unit Testing with JUnit and CUnit by Beth Kirby Dec 13, 2002 Jules.
Presentation transcript:

Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License. The OWASP Foundation OWASP AppSec Europe May Security Testing through Automated Software Tests Stephen de Vries, Principal Consultant, Corsaire

OWASP AppSec Europe  Sub bullet Typical Iterative development life cycle  Correcting issues is costly  The people who understand the code best, don’t perform the security tests  No buy-in from developers into the security process

OWASP AppSec Europe Typical Iterative development life cycle

OWASP AppSec Europe Typical Iterative development life cycle Integrating Security Tests in the process: A shorter security testing phase More robust applications because testing is deep Developer involvement in security

OWASP AppSec Europe Outline  A taxonomy and description of testing types  An introduction to JUnit and examples of its use  Testing compliance to a security standard  Testing security in Unit Tests  Testing security in Integration Tests  Testing security in Acceptance Tests  Conclusion  Q & A

OWASP AppSec Europe Use cases and Abuse cases  Use cases  Expected behaviour  Normal input  Functional requirements  Abuse cases  Unexpected behaviour  By Malicious agents  Derived from risk assessment  Developers should think evil which leads to…  Defensive programming

OWASP AppSec Europe Taxonomy of Automated Software Tests  Unit Tests  Integration Tests  Acceptance Tests

OWASP AppSec Europe Taxonomy of Automated Software Tests  Unit Tests  Operate at the method and class level  High test coverage  Test in isolation - stubs and mocks  Executed the most frequently  Written by developers

OWASP AppSec Europe Taxonomy of Automated Software Tests  Integration Tests  Integration between classes and modules  Integration between tiers  In-container tests or Mock objects  Executed often, but not as often as unit tests  Written by developers

OWASP AppSec Europe Taxonomy of Automated Software Tests  Acceptance Tests  Performed on the external API  Low test coverage  Executed the least frequently  Performed by QA testers

OWASP AppSec Europe Introducing JUnit “Never in the field of software development was so much owed by so many to so few lines of code.” - Martin Fowler

OWASP AppSec Europe Introducing JUnit Example: A single method from a shopping cart class public void addItem(Item item, boolean inStock) { CartItem cartItem = (CartItem) itemMap.get(item.getItemId()); if (cartItem == null) { cartItem = new CartItem(); cartItem.setItem(item); cartItem.setQuantity(0); cartItem.setInStock(inStock); itemMap.put(item.getItemId(), cartItem); itemList.getSource().add(cartItem); } cartItem.incrementQuantity(); }

OWASP AppSec Europe Introducing JUnit  Test that:  a new cart has 0 items in it  adding a single item results in that item being present in the cart  adding a single item results in the cart having a total of 1 items in it  adding two items results in both items being present in the cart  adding two items results in the cart having a total of 2 items in it  Test whether adding a null item results in an exception and nothing being set in the cart

OWASP AppSec Europe public class CartTest extends TestCase { public CartTest(String testName) { super(testName); } protected void setUp() throws Exception { //Code here will be executed before every testXXX method } protected void tearDown() throws Exception { //Code here will be executed after every testXXX method } public void testNewCartHasZeroItems() { // Test code goes here } public void testAddSingleItem() { // Test code goes here } public void testAddTwoItems() { // Test code goes here } public void testAddNullItem() { // Test code goes here } Introducing JUnit

OWASP AppSec Europe Introducing JUnit public void testAddTwoItems() { Cart instance = new Cart(); boolean isInStock = true; //First add an item Item item = new Item(); item.setItemId("item01"); instance.addItem(item, isInStock); //Test adding a second item Item item2 = new Item(); item2.setItemId("item02"); instance.addItem(item2, isInStock); //Check whether item01 is in the cart boolean result = instance.containsItemId("item01"); assertTrue("First item is in cart", result); //Check whether item02 is in the cart result = instance.containsItemId("item02"); assertTrue("Second item is in cart", result); //Check that there are 2 items in the cart assertEquals("2 items in cart", instance.getNumberOfItems(), 2); } USE CASE TEst

OWASP AppSec Europe Introducing JUnit public void testAddNullItem() { Cart instance = new Cart(); boolean isInStock = true; try { instance.addItem(null, isInStock); fail("Adding a null item did not throw an exception"); } catch (RuntimeException expected) { assertTrue("null Item caught",true); assertEquals("Null not in cart", instance.getNumberOfItems(), 0); } ABUSE CASE TEST

OWASP AppSec Europe Introducing JUnit  Using JUnit  Supported in all Java IDE’s  Ant and Maven support  Part of the code-debug cycle

OWASP AppSec Europe Introducing JUnit  Other Unit testing frameworks  Java – JUnit, ( TestNG ( JTiger (  Microsoft.NET – NUnit ( ( ASPUnit ( CSUnit ( and MS Visual Studio Team Edition and many more.  PHP – PHPUnit ( SimpleTest (  Coldfusion – CFUnit ( cfcUnit (  Perl – PerlUnit ( Test::More (included with Perl)  Python – PyUnit ( doctest (included in standard library)  Ruby – Test::Unit (included in the standard library)  C – CUnit ( check (  C++ – CPPUnit ( cxxtest (

OWASP AppSec Europe Web Application Security Standards  What is a Web Application Security Standard?  Derived from an organisation’s Security Policy  Similar to an Operating System Build Standard  Defines how the application should behave from a security point of view  Should include functional and non-functional security aspects

OWASP AppSec Europe Web Application Security Standards Example:

OWASP AppSec Europe Web Application Security Standard

OWASP AppSec Europe Testing Security in Unit Tests Test Valid Input public void testValidPhoneNumbers() { //Test valid input String number = "232321"; acc.setPhone(number); validator.validate(acc, errors); assertFalse(number+" caused a validation error.", errors.hasFieldErrors("phone")); number = " "; acc.setPhone(number); validator.validate(acc, errors); assertFalse(number+" caused a validation error.", errors.hasFieldErrors("phone")); number = "(44) 32321"; acc.setPhone(number); validator.validate(acc, errors); assertFalse(number+" caused a validation error.", errors.hasFieldErrors("phone")); //etc… }

OWASP AppSec Europe Testing Security in Unit Tests  Test Invalid Input: public void testIllegalCharactersInPhoneNumber() { String number = "+(23)';[] "; acc.setPhone(number); validator.validate(acc, errors); assertTrue(number+" did not cause a validation error.", errors.hasFieldErrors("phone")); } public void testAlphabeticInPhoneNumber() { String number = "12a12121"; acc.setPhone(number); validator.validate(acc, errors); assertTrue(number+" did not cause a validation error.", errors.hasFieldErrors("phone")); }

OWASP AppSec Europe Testing Security in Unit Tests  Advantages of testing at this layer  Tests are run very frequently - issues are identified quickly  Most granular form of test - high test coverage  Disadvantages  Not many security vulnerabilities can be tested at this layer

OWASP AppSec Europe Testing Security in Integration Tests  In-container testing  Realistic and complete  Requires specific tools  Overhead in starting container  Mock Objects  Server API is faked  Generic solution  No container overhead

OWASP AppSec Europe Testing Security in Integration Tests  In-container testing with Apache Cactus  Popular tool for testing J2EE applications  Can test EJB and Web tiers  Plugin’s for Jetty, Eclipse, Ant and Maven

OWASP AppSec Europe Testing Security in Integration Tests  Lifecycle of a single cactus test 1.beginXXX() - setup the client side 2.setUp() - common server side code 3.testXXX() - server side test 4.tearDown() - common server side code 5.endXXX() - client side tests

OWASP AppSec Europe Testing Security in Integration Tests public class TestAccessControl extends ServletTestCase { public void beginUnprivilegedUserAccessControl(WebRequest theRequest) { theRequest.setAuthentication(new BasicAuthentication("user", "password")); } public void testUnprivilegedUserAccessControl() throws IOException, javax.servlet.ServletException { AdminServlet admin = new AdminServlet(); admin.doGet(request, response); } public void endUnprivilegedUserAccessControl(WebResponse theResponse) throws IOException { assertTrue("Normal users must not be able to access /admin", theResponse.getStatusCode() == 401) }

OWASP AppSec Europe Testing Security in Integration Tests  Advantages of testing at this layer  Can test in the application server  Many security vulnerabilities can be tested, e.g.: Injection, Authentication flaws and Authorisation flaws.  Disadvantages  Not executed as often as unit tests  Overhead of starting an application server  Some vulnerabilities may not be easily testable, e.g.: XSS, URL filtering performed by a web server or application firewall.

OWASP AppSec Europe Security Testing in Acceptance Tests  Tests the external API  Language agnostic  2 types of tools: 1.Include their own HTTP client and HTML parser, e.g.: HTTPUnit, jWebUnit, HtmlUnit, Canoo Webtest 2.Drive a browser instance, e.g.: Selenium, WATIR, Watij

OWASP AppSec Europe Security Testing in Acceptance Tests  Example: Testing HTML injection with jWebUnit public class XSSinSearchFieldTest extends WebTestCase { public void setUp() throws Exception { getTestContext().setBaseUrl(" } public void testHtmlInjection() throws Exception { beginAt("/index.html"); assertLinkPresentWithText("Enter the Store"); clickLinkWithText("Enter the Store"); assertFormPresent("searchForm"); setFormElement("query", " Injection "); submit(); assertLinkNotPresent("injection"); } public XSSinSearchFieldTest(String name) { super(name); }

OWASP AppSec Europe Security Testing in Acceptance Tests

OWASP AppSec Europe Security Testing in Acceptance Tests  Example: Testing SQL injection with WATIR class SQL_Injection_Test < Test::Unit::TestCase include Watir def test_SQL_Blind_Injection_in_Login() $ie.goto(' $ie.link(:url, /signonForm.do/).click $ie.text_field(:name, 'username').set('corsaire1\' OR 1=1--') $ie.form(:action, "/ispatula/shop/signon.do").submit assert($ie.contains_text('Signon failed')); end # Snip setup code end

OWASP AppSec Europe Security Testing in Acceptance Tests  Example: Testing XSS with WATIR def test_XSS_In_Search $ie.goto(' $ie.text_field(:name, 'query').set(' window.open(" ') $ie.form(:action, /Search.do/).submit assert_raises(Watir::Exception::NoMatchingWindowFoundException, "Search field is susceptible to XSS") { ie2 = Watir::IE.attach(:url, " } end

OWASP AppSec Europe Security Testing in Acceptance Tests  Advantages of testing at this layer  Full testing of external API  Security consultants can use tools to script vulnerabilities  Documents vulnerabilities  Easy retesting  Disadvantages  Low test coverage  Developers aren’t involved in testing

OWASP AppSec Europe Conclusions  Existing testing tools and techniques can be used for security testing in the development lifecycle  Developer training in security is a good investment!  Security issues are identified early  Code is subject to deep testing  Compliance with a Web App Security Standard can be demonstrated