Continuous Security Testing with Devops - OWASP EU 2014

22
Continuous Security Testing In a DevOps World

description

Integrating security into devops approach using BDD-Security in a CI environment.

Transcript of Continuous Security Testing with Devops - OWASP EU 2014

Page 1: Continuous Security Testing  with Devops - OWASP EU 2014

Continuous Security Testing

In a DevOps World

Page 2: Continuous Security Testing  with Devops - OWASP EU 2014

About Me

• Stephen de Vries

– CTO ContinuumSecurity– 60% Security consultant 40% Developer– Author: BDD-Security project

Page 3: Continuous Security Testing  with Devops - OWASP EU 2014
Page 4: Continuous Security Testing  with Devops - OWASP EU 2014

About Me

DevOps is a means

Continuous Delivery / Continuous Deployment is the end

• Don’t wait for a release before deploy• Deploy individual features• Get business value to production as fast as possible

Page 5: Continuous Security Testing  with Devops - OWASP EU 2014

Continuous Delivery

Agile

Plan/Code/Build/Test

Continuous Integration

Int. Test QA Testing

Continuous Deployment

Deploy

DevOps

Page 6: Continuous Security Testing  with Devops - OWASP EU 2014

DevOps is a tool to operate a continuous delivery pipeline

Page 7: Continuous Security Testing  with Devops - OWASP EU 2014

The DevOps challenge to security

• Our project requirements are visible to dev and ops• Our build, test and deploy process is entirely automated• Developers can deploy to prod directly• We deploy to prod multiple times per day

• Amazon: deploy every 11.6 seconds• Etsy: deploys 25+ times/day• Gov.uk: deploys 30 times/day

How can we do this securely?

Page 8: Continuous Security Testing  with Devops - OWASP EU 2014
Page 9: Continuous Security Testing  with Devops - OWASP EU 2014

• Dead documents

• Reliance on manual processes

• Tools don’t fit the deployment pipeline

• Tool results don’t translate to business requirements

Traditional Security approach

Page 10: Continuous Security Testing  with Devops - OWASP EU 2014

What can security learn from DevOps?

• Security Testing is quality testing

• Continuous monitoring (See OWASP AppSensor)

• Automated all the things

Page 11: Continuous Security Testing  with Devops - OWASP EU 2014

Security Testing > Security Scanning

• Scanners don’t test functional security• Tests have an expected outcome• Comprehensive tests ARE the requirements• Tests are code: stored by SCM

Page 12: Continuous Security Testing  with Devops - OWASP EU 2014

@Testpublic void change_session_ID_after_login() { driver.get("http://localhost:9110/ropeytasks/user/login"); Cookie preLoginSessionId = getSessionId("JESSSIONID"); login("bob", "password"); Cookie afterLoginSessionId = getSessionId("JESSSIONID"); assertThat(afterLoginSessionId.getValue(),

not(preLoginSessionId.getValue()));}

public void login(String u, String p) { driver.findElement(By.id("username")).clear(); driver.findElement(By.id("username")).sendKeys(u); driver.findElement(By.id("password")).clear(); driver.findElement(By.id("password")).sendKeys(p); driver.findElement(By.name("_action_login")).click();}

• Navigation logic is embedded in the test• Selenium does not expose HTTP• Excludes non-developers

First attempt:

Page 13: Continuous Security Testing  with Devops - OWASP EU 2014

BDD-Security Testing Frameworkhttps://github.com/continuumsecurity/bdd-security

• Tests written in JBehave• Automated Functional Security Testing• Non-functional security testing• Wraps security tools in tests:

• OWASP ZAP• Nessus• Port scanner (built in)

Page 14: Continuous Security Testing  with Devops - OWASP EU 2014

BDD-Security example

Page 15: Continuous Security Testing  with Devops - OWASP EU 2014

• Must be able to automate manual security testing• Selenium + OWASP ZAP API

• Tests must be understandable by all stakeholders• Behaviour Driven Development (BDD) with JBehave

• Must fit into dev workflow and continuous integration pipelines• Runs in IDE, cmd line• Runs in Jenkins• Test results in JUnit wrapper +HTML in Jenkins

• The logic of the security tests should be independent from navigation code

• Provide a baseline of ready-to-use security tests

BDD-Security Testing Framework

Page 16: Continuous Security Testing  with Devops - OWASP EU 2014

Demo

• Ropey Tasks• Initial configuration• BDD wrappers around scanning tools• BDD tests of functional app security• Automated access control tests

Page 17: Continuous Security Testing  with Devops - OWASP EU 2014

Integration with Jenkins

Page 18: Continuous Security Testing  with Devops - OWASP EU 2014

Limitations

• Email: Not implemented yet• Needed for self-reg• Account Lockout

• Access control not Anti-CSRF aware

• Test Maintenance• Use error checking wherever possible• When extending try to find generic solution

• E.g.: ISomeBehaviour

Page 19: Continuous Security Testing  with Devops - OWASP EU 2014

Traditional Security approach

Page 20: Continuous Security Testing  with Devops - OWASP EU 2014

• Self verifying requirements• Automated testing• Testing inserted into CD pipeline

Page 21: Continuous Security Testing  with Devops - OWASP EU 2014

Resources:

• https://github.com/continuumsecurity

• OWASP ZAP Pure Java client API• Resty-Burp RESTful API into Burp Suite• Nessus Java Client• SSLTest Java SSL analyser

• Related projects:

• Gauntlt BDD wrapper for sec tools: https://github.com/gauntlt/gauntlt (Ruby)

• Mittn Burp Integration: https://github.com/F-Secure/mittn (Python)

Page 22: Continuous Security Testing  with Devops - OWASP EU 2014

Questions?

@stephendv