38
Merging Security and DevOps - A Tactical and Practical View Abhay Bhargav - CTO, we45

Merging Security with DevOps - An AppSec Perspective

Embed Size (px)

Citation preview

Page 1: Merging Security with DevOps - An AppSec Perspective

Merging Security and DevOps - A Tactical and Practical View

Abhay Bhargav - CTO, we45

Page 2: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargavwe45

Yours Truly• Co-author of Secure Java For Web Application

Development

• Author of PCI Compliance: A Definitive Guide

• Speaker at OWASP Conferences worldwide

• Avid Pythonista and AppSec Automation Junkie

• Specialization in Web Application Security and Security Testing

• Lead Trainer - DevSecOps Workshop

Page 3: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargavwe45

Today's Session

• Setting the Context for AppSec and DevOps

• Approaches to Automating OWASP ZAP for DevOps Goodness

• Conclusions

Page 4: Merging Security with DevOps - An AppSec Perspective

A Gentle Introduction to DevOps

• What is DevOps?

• Where does Security fit in?

Page 5: Merging Security with DevOps - An AppSec Perspective

What is DevOps?

• Key Objective - Harmonize IT Operations by working with Developers and Ops seamlessly

• Rely on processes and automation to achieve higher throughput - Continuous Delivery

Page 6: Merging Security with DevOps - An AppSec Perspective

Without DevOps

Requirements Design Develop Test Deploy

Page 7: Merging Security with DevOps - An AppSec Perspective

With DevOps (hopefully…)

Requirements Design Develop Test Deploy

Page 8: Merging Security with DevOps - An AppSec Perspective

Continuous Delivery PipelineDeveloper Orchestration engine

Coding - Modify and commit

Git: Checkout for build

Jenkins: Continuous Integration

Docker: Publish to

reposuccess

Docker: Deploy to

QA

Selenium: Run tests

QA

success

Docker: Deploy to

Prod

Page 9: Merging Security with DevOps - An AppSec Perspective

But….

Requirements Design Develop Test Deploy

Page 10: Merging Security with DevOps - An AppSec Perspective

Let’s do a security test just before we go live….

The line that has ruined Application Security for all of us.

Page 11: Merging Security with DevOps - An AppSec Perspective

In Short….

Page 12: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargavwe45

Why?• Penetration Testing - Annual/Bi-annual/Quarterly

- Does not quite catch up with Application changes

• Manual Penetration Testing does not scale

• You never seem to fix security issues

• Vulnerability Scanners only find 30% of the actual security issues with your application

• Static Code Analysis finds only 40% of the actual vulnerabilities in your application

Page 13: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargavwe45

In Short….

Page 14: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargavwe45

We need to continuously test for security?

Page 15: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargavwe45

Page 16: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargavwe45

The Need of the Hour….

To Find and Fix Security Bugs early

and often

Security to integrate with your Agile Development

Security to seamlessly work with your

Continuous Delivery Pipeline

Page 17: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargavwe45

CI/CD Pipeline

Trigger ARA

Trigger manual code review

Email notifications

Configuration review

Trigger threat modelling

Run SAST tools

Automatic security testing

Gather metrics

Break the build

Compile and build code

SCA

Risk based security testing

Gather metrics

Break the build

Comprehensive SAST

Pre-commit checks

Commit-time checks

Build-time checks

Page 18: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargavwe45

CI/CD Pipeline

DAST/AST

Malicious code detection

Gather metrics

Break the build

Broader SAST

Pre-deployment checks

Post-deployment checks

Test-time checks

Commit-time checks

Continuous management

Provisioning runtime environment

Security scanning

Vulnerability scanning

Bug bounty program

Threat intelligence

Page 19: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargavwe45

Security in DevOps

Plan

Code

Build

Test

Release

Deploy

Operate

Monitor

Threat modeling

SAST Security - Composition

DAST IAST

Security in IaC

Security monitoring & attack detection

Page 20: Merging Security with DevOps - An AppSec Perspective

Our Approach Today• A View of DAST in the Pipeline

• Tool of Choice: OWASP ZAP

• with:

• Jenkins

• Customized Python Scripts

• ElasticSearch/Redis

• Objective: Explore Automated DAST Testing Approaches with OWASP ZAP and its Python API

Page 21: Merging Security with DevOps - An AppSec Perspective

Why OWASP ZAP?• Free and Open Source Web Application

Vulnerability Scanner

• Feature-Rich, well supported, with several contributors

• Community Support - Plugins, Add-ons, etc.

• Documentation - Better than most scanners out there

• Great API and Scriptable Scanner

Page 22: Merging Security with DevOps - An AppSec Perspective

Security in DevOps

Plan

Code

Build

Test

Release

Deploy

Operate

Monitor

Threat modeling

SAST Security - Composition

DAST IAST

Security in IaC

Security monitoring & attack detection

Page 23: Merging Security with DevOps - An AppSec Perspective

Introduction to the OWASP ZAP API

• OWASP ZAP - Automation

• Concept Overview

• Useful Concepts and API

Page 24: Merging Security with DevOps - An AppSec Perspective

Concept Overview - OWASP ZAP

• Context

• Session

• Active Scan

• Passive Scan

• Scan Policy

• Alert

Page 25: Merging Security with DevOps - An AppSec Perspective

Running Authenticated Scans in OWASP ZAP

• Approaches:

• Selenium-driven Scan Process

• Leveraging canned ZAP Sessions

• Zest Scripting

Page 26: Merging Security with DevOps - An AppSec Perspective

Selenium-Authenticated Scan

Run Selenium and ZAP in Headless Mode

Leverage Functional Scripts

Beats Spidering the app! :)

Page 27: Merging Security with DevOps - An AppSec Perspective

ZAP Session-Authenticated Scan

Programmatically invoked with ZAP API

Maintains state with Sessions/Tokens, etc

Page 28: Merging Security with DevOps - An AppSec Perspective

ZestScript Authenticated Scan

Programmatically invoked with ZAP API

Easily Customizable

Page 29: Merging Security with DevOps - An AppSec Perspective

DEMO: Authenticated ZAP Scan

Demo Gods! Please let this work!!

Page 30: Merging Security with DevOps - An AppSec Perspective

ZAP in the Continuous Delivery Pipeline

Page 31: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargav

Cool!Solves the problem right??

Page 32: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargav

Page 33: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargav

What about??

AUTHORIZATION FLAWS

BUSINESS LOGIC FLAWS

COMPLEX INJECTION FLAWSAUTHENTICATION FLAWS

DOM-BASED FLAWS

Page 34: Merging Security with DevOps - An AppSec Perspective

abhaybhargav abhaybhargav

Custom Scripting Framework

• Great Results from:

• External Pentests

• Bug Bounties

• Internal Pentests and Reviews

• Created as Custom Scripts

• Loaded and run as part of the pipeline

Page 35: Merging Security with DevOps - An AppSec Perspective

OWASP ZAP - Scripting Framework

• Python (Jython)

• Ruby

• Oracle Nashorn ECMAScript

• Zest Scripts

Page 36: Merging Security with DevOps - An AppSec Perspective

OWASP ZAP - Scripting Framework• Active Rules => Scripts invoked during Active Scan

• Authentication Scripts => Scripts invoked to facilitate authentication for a Context

• Fuzzer Processors => Scripts invoked after Fuzzers are run with ZAP

• HTTPSender => Scripts invoked against every request/response received by ZAP

• Proxy => Runs inline and acts on all requests and responses

• Targeted Rules => Invoked on specific urls or on manual start only

• Standalone => Invoked manually

• Passive Rules => Passive Scanning Rules

Page 37: Merging Security with DevOps - An AppSec Perspective

DEMO: Custom ZAP Script

Demo Gods! Please let this work!!

Page 38: Merging Security with DevOps - An AppSec Perspective