Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Security Automation Pipeline

Matt Konda
January 14, 2016

Security Automation Pipeline

IJUG Meetup where we talked about security tools, where they fit in continuous delivery pipelines and how the OWASP pipeline tool can help.

Matt Konda

January 14, 2016
Tweet

More Decks by Matt Konda

Other Decks in Programming

Transcript

  1. Security Automation in
    Software Delivery: A
    Rugged DevOps Pipeline
    Matt Konda
    @mkonda

    View Slide

  2. Prereqs
    • Docker Toolbox
    • pipeline
    • docker pull owasp/pipeline:0.8.1
    • A project to analyze

    View Slide

  3. Introduction
    1997 2006 2014
    Consultant
    Engineer
    Software
    Architect
    Director of
    Engineering
    Rabble Rouser:
    Perl
    Java Applet
    C++
    J2EE
    J2EE

    Spring
    Analytics
    Certificate Authority
    Vulnerability Scanner
    Penetration Test Manager
    Pricing
    Retail
    Banking
    Manufacturing
    Pharma
    Healthcare
    Research
    Ruby
    Rails
    Chicago BSides 2011, 2012
    Defcon Skytalk
    OWASP Chicago, MSP 2013
    AppSec USA 2012, 2013
    ChicagoRuby 2013
    Secure 360
    Lone Star Ruby 2013
    WindyCityRails 2013
    Chicago JUG 2014
    RailsConf 2014
    Converge 2014
    Chicago Coder Conference 2015
    MS in CS
    Founder
    Consultant
    Agile
    Clojure
    Graph Database
    Trying to hack a
    business model that
    succeeds while
    helping developers.
    Domains:
    Projects:
    DevOps / Automation
    Training
    Coaching
    Code Review
    Plugged in to SDLC
    Consulting
    Assessments
    @mkonda
    [email protected]
    DevOps
    Growing

    View Slide

  4. What do I do?
    • Bug bounty
    • Breaking
    • Mostly SDLC
    • Training
    • Automation

    View Slide

  5. Overview
    • Quick overview of security tools
    • DevOps / Continuous Delivery & Rugged
    • Leveraging security automation where possible
    • Hands on with Pipeline for labs (time permitting)

    View Slide

  6. View Slide


  7. http://training.jemurai.com/struts2-blank/
    example/X.action?action:%25{3*4}

    View Slide

  8. training.jemurai.com/struts2-showcase/
    employee/save.action?redirect:%25{(new
    +java.lang.ProcessBuilder(new
    +java.lang.String[]{‘touch’,'/tmp/hi2'})).start()}

    View Slide

  9. View Slide

  10. metasploit + struts

    View Slide

  11. Security Tools

    View Slide

  12. Static Analysis

    View Slide

  13. Static Analysis Live App Scanning

    View Slide

  14. Static Analysis Live App Scanning
    Dynamic Analysis

    View Slide

  15. Static Analysis Live App Scanning
    Dynamic Analysis Dependency Checks

    View Slide

  16. Static Analysis Live App Scanning
    Dynamic Analysis Dependency Checks
    Web Application Firewall Runtime Security Monitoring
    IP Reputation Anti-Automation
    Penetration Testing

    View Slide

  17. View Slide

  18. B+
    C
    B+
    F
    D
    D
    F
    B
    A-
    C
    The items on
    the left are
    the OWASP
    Top 10.
    The grades
    are mine and
    are arbitrary.
    https://www.owasp.org/index.php/Top_10_2013-Top_10

    View Slide

  19. View Slide

  20. View Slide

  21. There is no substitute for
    people with knowledge.

    View Slide

  22. But we can help
    ourselves by leveraging
    tools.

    View Slide

  23. We just have to be smart
    and flexible about it.

    View Slide

  24. So let’s go a bit
    deeper

    View Slide

  25. Find Security Bugs

    View Slide

  26. View Slide

  27. View Slide

  28. View Slide

  29. View Slide

  30. View Slide

  31. View Slide

  32. View Slide

  33. View Slide

  34. OWASP Dependency
    Check

    View Slide

  35. http://dl.bintray.com/jeremy-long/owasp/
    dependency-check-1.2.11-release.zip

    View Slide

  36. /bin/dependency-check.sh -a struts2-showcase -out /tmp/ -s /
    tomcat-root/struts2-showcase/

    View Slide



  37. CVE-2014-0050
    5.0
    Medium
    CWE-264 Permissions, Privileges, and Access Controls
    MultipartStream.java in Apache Commons FileUpload before 1.3.1, as used in Apache Tomcat, JBoss Web, and other products,
    allows remote attackers to cause a denial of service (infinite loop and CPU consumption) via a crafted Content-Type header that bypasses a loop's
    intended exit conditions.


    BID
    http://www.securityfocus.com/bid/65400
    65400


    BUGTRAQ
    http://www.securityfocus.com/archive/1/archive/1/532549/100/0/threaded
    20140625 NEW VMSA-2014-0007 - VMware product updates address security vulnerabilities in Apache Struts library


    BUGTRAQ
    http://www.securityfocus.com/archive/1/archive/1/534161/100/0/threaded
    20141205 NEW: VMSA-2014-0012 - VMware vSphere product updates address security vulnerabilities


    BUGTRAQ
    http://www.securityfocus.com/archive/1/archive/1/535181/100/0/threaded
    20150402 NEW : VMSA-2015-0003 VMware product updates address critical information disclosure issue in JRE


    CONFIRM
    http://advisories.mageia.org/MGASA-2014-0110.html
    http://advisories.mageia.org/MGASA-2014-0110.html


    CONFIRM
    http://svn.apache.org/r1565143
    http://svn.apache.org/r1565143


    CONFIRM
    http://tomcat.apache.org/security-7.html
    http://tomcat.apache.org/security-7.html

    View Slide


  38. CVE-2013-0248
    3.3
    Low
    CWE-264 Permissions, Privileges, and Access Controls
    The default configuration of javax.servlet.context.tempdir in Apache Commons FileUpload 1.0
    through 1.2.2 uses the /tmp directory for uploaded files, which allows local users to overwrite arbitrary files via an unspecified
    symlink attack.


    BUGTRAQ
    http://archives.neohapsis.com/archives/bugtraq/2013-03/0035.html
    20130306 [SECURITY] CVE-2013-0248 Apache Commons FileUpload - Insecure examples


    OSVDB
    http://www.osvdb.org/90906
    90906



    cpe:/a:apache:commons_fileupload:1.0

    View Slide



  39. CVE-2007-0185
    5.0
    Medium
    Getahead Direct Web Remoting (DWR) before 1.1.4 allows attackers to cause a denial of service
    (memory exhaustion and servlet outage) via unknown vectors related to a large number of calls in a batch.


    BID
    http://www.securityfocus.com/bid/21955
    21955


    CONFIRM
    http://getahead.ltd.uk/dwr/changelog
    http://getahead.ltd.uk/dwr/changelog


    OSVDB
    http://osvdb.org/32658
    32658

    View Slide


  40. CVE-2013-2251
    9.3
    High
    CWE-20 Improper Input Validation
    Apache Struts 2.0.0 through 2.3.15 allows remote attackers to execute arbitrary OGNL expressions
    via a parameter with a crafted (1) action:, (2) redirect:, or (3) redirectAction: prefix.


    BID
    http://www.securityfocus.com/bid/64758
    64758

    This is the one that allowed me to metasploit myself.

    View Slide

  41. Lab 1: Running Pipeline from Docker
    1. docker-machine create --driver
    virtualbox default
    2. eval $(docker-machine env default)
    3. docker pull owasp/pipeline:0.8.1
    4. docker run —rm owasp/pipeline:0.8.1 -h
    5. docker run —rm owasp/pipeline:0.8.1 -t
    brakeman https://github.com/Jemurai/
    triage.git

    View Slide

  42. DevOps /
    Continuous Delivery

    View Slide

  43. View Slide

  44. Rugged

    View Slide

  45. I recognize that software has become a foundation of our
    modern world.
    I recognize the awesome responsibility that comes with this
    foundational role.
    I recognize that my code will be used in ways I cannot
    anticipate, in ways it was not designed, and for longer than it
    was ever intended.
    I recognize that my code will be attacked by talented and
    persistent adversaries who threaten our physical, economic
    and national security.
    I recognize these things – and I choose to be rugged.

    View Slide

  46. I recognize that software has become a foundation of our
    modern world.
    I recognize the awesome responsibility that comes with this
    foundational role.
    I recognize that my code will be used in ways I cannot
    anticipate, in ways it was not designed, and for longer than it
    was ever intended.
    I recognize that my code will be attacked by talented and
    persistent adversaries who threaten our physical,
    economic and national security.
    I recognize these things – and I choose to be rugged.

    View Slide

  47. Understand lifecycle

    View Slide

  48. Requirements
    Design
    Code
    Test
    Maintenance
    Classic Waterfall Delivery

    View Slide

  49. Requirements
    Design
    Code
    Test
    Maintenance
    Classic Waterfall Delivery
    Security

    View Slide

  50. continuous delivery

    View Slide

  51. Classic security sees this
    and wants to …

    View Slide

  52. continuous delivery

    View Slide

  53. But we can embrace it.

    View Slide

  54. Being able to deploy quickly is
    my #1 security feature.
    - Nick Galbreath

    View Slide

  55. Think incremental

    View Slide

  56. Story
    Continuous Delivery: The Unit of work is a story
    Requirements Design
    Code
    Test

    View Slide

  57. Story
    Continuous Delivery: The Unit of Work is a Story
    Requirements Design
    Code
    Test
    Security Requirements
    Security Unit Tests
    Exploratory Testing
    Static Analysis on Commit
    Code Review
    Threat model / attack
    surface
    Checklists
    Understand Dependencies

    View Slide

  58. continuous delivery
    Code Review
    Security Unit Tests
    Security Requirements

    View Slide

  59. Automate security tools

    View Slide

  60. continuous delivery
    Security Tool Automation:
    Code analysis
    Security unit tests
    Dynamic scanning
    etc.

    View Slide

  61. continuous delivery
    Security Tests Run
    Exploratory Testing Includes Security

    View Slide

  62. Lab 2: Running Pipeline on Your Project
    docker run —rm
    -v /Users/mk/code/loca:/tmp/target/
    owasp/pipeline:0.8.1 \
    -d \
    -t owaspdependencycheck \
    -f csv \
    /tmp/target/
    * Due to docker ease of setup, please use a directory within your home directory. It is
    possible to do this in other ways, but it requires further setup of shared folders in
    virtual box which we want to avoid for the purposes of this workshop.

    View Slide

  63. Lab 2: Running Pipeline on Your Project
    1. docker run —name pipe jemurai/
    pipeline:0.8
    2.docker exec -it pipe bash
    docker ps
    FIND YOUR IMAGE NAME
    * Due to docker ease of setup, please use a directory within your home directory. It is
    possible to do this in other ways, but it requires further setup of shared folders in
    virtual box which we want to avoid for the purposes of this workshop.

    View Slide

  64. Lab 3: Getting into the Pipeline Docker Image
    1. docker run -rm —i -t —entrypoint=/
    bin/bash owasp/pipeline:0.8.1
    2. cd lib
    3. ../bin/pipeline -h
    Now you’re running from source.
    We can change anything …

    View Slide

  65. Integrations

    View Slide

  66. pre-commit

    View Slide

  67. Lab 5: Running Pipeline on a Git Hook
    1. Copy /hooks/pre-commit to your
    project in /.git/hooks
    2. chmod +x pre-commit
    3. Edit pre-commit to reflect your path
    and tools
    4. Regular process:
    1. Change a
    2. git add
    3. git commit -m “Testing”

    View Slide

  68. View Slide

  69. chat ops

    View Slide

  70. View Slide

  71. View Slide

  72. https://github.com/OWASP/Owbot

    View Slide

  73. Jenkins

    View Slide

  74. View Slide

  75. View Slide

  76. View Slide

  77. View Slide

  78. View Slide

  79. View Slide

  80. View Slide

  81. View Slide

  82. View Slide

  83. View Slide

  84. Issue Tracking

    View Slide

  85. Jira

    View Slide

  86. Github (future)

    View Slide

  87. Process images

    View Slide

  88. spider docker registry

    View Slide

  89. grab ami

    View Slide

  90. Process chef, puppet,
    ansible config …

    View Slide

  91. Custom Application

    View Slide

  92. View Slide

  93. View Slide

  94. View Slide

  95. View Slide

  96. Chat + UI + Queue +
    Pipeline + Jenkins + JIRA

    View Slide

  97. Case Study

    View Slide

  98. Credit: Matt Tesauro at AppSecEU 2015
    http://www.slideshare.net/mtesauro/mtesauro-keynote-appseceu

    View Slide

  99. Pipeline Design

    View Slide

  100. Overview
    • Pipeline is broken into different chunks to try to make it
    easy and straightforward to extend in expected ways.
    • These illustrate the challenges of security automation.
    Mounter Files Code Live Filter Reporter
    “Tasks”

    View Slide

  101. View Slide

  102. Mounter
    git repo, filesystem, iso, docker image

    View Slide

  103. Mounter
    clamav
    hashdeep
    Files

    View Slide

  104. Mounter
    brakeman, bundler-audit,
    owasp-dependency-check, secrets in
    source, retire.js, eslint/scan.js,
    nodesecurityproject.
    Files Code

    View Slide

  105. Mounter
    Currently: ZAP
    Future: guantlt, etc.
    Files Code Live

    View Slide

  106. Recap of “Tasks”
    • File: AV, FIM
    • Code:
    • Ruby/Rails: brakeman, bundler-audit
    • JavaScript: NodeSecurityProject, eslint, retire.js
    • Java: owasp-dependency-check
    • Checkmarx
    • Live: ZAP

    View Slide

  107. Lab 4: Running JS Tools
    1.docker run jemurai/pipeline:0.8 -t
    eslint https://github.com/OWASP/
    NodeGoat.git
    Or interactively:
    1.docker run -t -i —entrypoint=/bin/bash
    jemurai/pipeline:0.8
    2.cd line/pipeline/lib
    3.../bin/pipeline -t eslint https://
    github.com/OWASP/NodeGoat.git
    Try: -t
    eslint,nodesecurityproject,retirejs

    View Slide

  108. Here’s a secret…

    View Slide

  109. I can’t tell you what’s
    going to work for you.

    View Slide

  110. Mounter
    Prevents false positives in JIRA.
    Files Code Live Filter

    View Slide

  111. Mounter
    Reports to JIRA, csv, json, text.
    Files Code Live Filter Reporter

    View Slide

  112. How would you do
    tsv?

    View Slide

  113. How would you do
    github?

    View Slide

  114. Extension Points
    • Mounters: mount, supports?
    • Tasks: run, analyze, supported?
    • Filters: filter
    • Reporter: run_report
    Mounter Files Code Live Filter Reporter
    “Tasks”

    View Slide

  115. Other Internals
    • Within “Tasks”, each of the files, code and app
    phases of the pipeline can be run selectively as
    stages.
    Mounter Files Code Live Filter Reporter
    “Tasks”

    View Slide

  116. ruby bin/pipeline
    -l code (Code analysis)
    -d (Turn on debug)
    -f text (Output format)
    /area53/app/

    View Slide

  117. ruby bin/pipeline
    -t brakeman (Tool)
    -d (Turn on debug)
    -f csv (Output format)
    /area53/app/

    View Slide

  118. Lab 5: Adding a New Tool to Pipeline
    1. docker run -i -t —entrypoint=/bin/
    bash jemurai/pipeline:0.8
    2. cd pipeline/lib/pipeline/tasks/
    3. cp bundler-audit.rb test.rb
    4. Edit to always create a finding (or
    use the following example for grep)
    5. cd /../../lib
    6. …/bin/pipeline -t test /tmp/

    View Slide

  119. Thank you.

    View Slide

  120. References
    • https://github.com/owasp/pipeline
    • https://www.owasp.org/index.php/OWASP_AppSec_Pipeline
    • https://speakerdeck.com/garethr/maintaining-control-by-letting-go-security-and-devops
    • http://www.slideshare.net/nickgsuperstar/devopssec-apply-devops-principles-to-security
    • https://www.rsaconference.com/writable/presentations/file_upload/asd-t07r-continuous-
    security-5-ways-devops-improves-security.pdf
    • http://gotocon.com/goto-london-2015/
    • http://gauntlt.org/
    • https://github.com/PearsonEducation/bag-of-holding
    • https://www.ruggedsoftware.org/

    View Slide