88
Dynamic Security Testing November 2017 @omerlh @yshayy

Security Testing with Zap

  • Upload
    soluto

  • View
    201

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Security Testing with Zap

Dynamic Security TestingNovember 2017

@omerlh@yshayy

Page 2: Security Testing with Zap
Page 3: Security Testing with Zap

http://www.align.com/wp-

content/uploads/2017/09/Equifax_Infographic.png

Page 4: Security Testing with Zap

And it affects the stock price...

disclosed

Page 5: Security Testing with Zap

http://www.zdnet.com/article/equifax-confirms-apache-struts-flaw-it-

failed-to-patch-was-to-blame-for-data-breach/

Page 6: Security Testing with Zap

https://nvd.nist.gov/vuln/detail/CVE-2017-5638

Page 7: Security Testing with Zap

Will you be the next Equifax?

Page 8: Security Testing with Zap

What can we do?

● Threat Modeling

● Design/Code review

● Bug bounties

● Security tests

● And many more…

Page 9: Security Testing with Zap

Security Tests in CI

Page 10: Security Testing with Zap

What's a feature management solution?

Page 11: Security Testing with Zap

Let’s try to change the design a bit to

increase engagement

Demo e-commerce app

Example 1 - A/B Testing

Page 12: Security Testing with Zap

Feature flags

Page 13: Security Testing with Zap

Tweek is mission critical

Page 14: Security Testing with Zap

Tweek is open source...

Page 15: Security Testing with Zap

GitHub Flow

Source: GitHub

Checks - Quality Feedback

Page 16: Security Testing with Zap

PR Quality Feedback

Page 17: Security Testing with Zap

Security Department

Source: IT Crowd

Page 18: Security Testing with Zap

Can we add security checks?

Page 19: Security Testing with Zap

The best defense is a good offense

Source: http://community-sitcom.wikia.com/wiki/File:Dual_wielding_Chang.jpg

Page 20: Security Testing with Zap

And run it in CI

Let’s take a hacking tool

Page 22: Security Testing with Zap

OWASP Zaproxy

https://www.openhub.net/p/zaproxy

Free and Open Source hacking tool

Page 23: Security Testing with Zap
Page 24: Security Testing with Zap

Zap has two modes:

Passive Active

Page 25: Security Testing with Zap

Let’s Hack Tweek!

Page 26: Security Testing with Zap

Tweek’s Architecture

Page 27: Security Testing with Zap

Passive Mode

Page 28: Security Testing with Zap

What Zap does?

● Inspecting request and response

● Run passive scan rules:○ Cookies misconfiguration

○ Security HTTP Headers

○ Mixed Content

○ And many more

Page 29: Security Testing with Zap

Setup Proxy

Page 30: Security Testing with Zap

Browse Editor

Page 31: Security Testing with Zap

Many findings

Page 32: Security Testing with Zap

Potential issue

Page 33: Security Testing with Zap

Why?

Page 34: Security Testing with Zap

Zap does not only find the issues

It will also help you fix them!

Page 35: Security Testing with Zap

Active Mode

Page 36: Security Testing with Zap

What Zap does?

● Find all URLS/Paths

● Run active scan rules:○ SQL injections

○ XSS

○ Directory browsing

○ Remote file inclusion

○ And many more

Page 37: Security Testing with Zap
Page 38: Security Testing with Zap

Zap can parse the spec

Page 39: Security Testing with Zap

And now we can attack it…

Page 40: Security Testing with Zap

Let’s push the red button

Page 41: Security Testing with Zap

Now relax and drink some coffee

Page 42: Security Testing with Zap

Massive attack

Page 43: Security Testing with Zap

Many findings

Page 44: Security Testing with Zap

Potential issue

Page 45: Security Testing with Zap

Why?

Page 47: Security Testing with Zap

Questions so far?

Page 48: Security Testing with Zap

And run it in CI

Let’s take a Hacking Tool

Page 49: Security Testing with Zap

Zap has two modes:

Passive Active

Page 50: Security Testing with Zap

Passive Mode

Page 51: Security Testing with Zap

Tweek’s Security Testing

TweekAPI

TweekEditor

IntegrationTests

REST

UI Automation

Tests

Selenium

ZAP Proxy

ZAP Proxy

REST

Selenium

Page 52: Security Testing with Zap

Let’s use Docker

● Tweek is designed as a multi-container app

● Every microservice has an offical Docker image

● Tweek uses Docker-native CI (Codefresh)

● Test suites also run as docker containers

● Zap has an official docker image

Page 53: Security Testing with Zap

Containerized them all!

TweekAPI

TweekEditor

Smoke Tests

REST

UI Automation

Tests

Selenium

ZAP Proxy

ZAP Proxy

REST

Selenium

Page 54: Security Testing with Zap
Page 55: Security Testing with Zap
Page 56: Security Testing with Zap

docker-compose up

Page 57: Security Testing with Zap

docker-compose is widely supported

Page 58: Security Testing with Zap

Running it in CI

Page 59: Security Testing with Zap

Zap API

Page 60: Security Testing with Zap
Page 61: Security Testing with Zap

Curl/CLI/SDK

Page 62: Security Testing with Zap

So we have Security Tests...

Page 63: Security Testing with Zap

But it’s not perfect…

Page 65: Security Testing with Zap

OWASP Glue

Security Tool Filtering Reporting

Free and Open Source CI tool

Page 66: Security Testing with Zap

Let’s add some glue to our CI

Page 67: Security Testing with Zap

Using Glue

ruby /usr/bin/glue/bin/glue -t zap --zap-host http://zap-e2e --zap-port 8090 --zap-passive-mode -f text --exit-on-warn 0 http://editor --finding-file-path /usr/src/wrk/glue.json

Page 68: Security Testing with Zap

Let’s look at the findings…

Page 69: Security Testing with Zap

Zap’s findings for the API

● Insecure cookies

● Missing security headers

● Insecure hash

FIXED

FIXED

IGNORE

Page 70: Security Testing with Zap

Active Mode

Page 71: Security Testing with Zap

Simply docker

docker run -t --net=host -v $(pwd):/zap/wrkowasp/zap2docker-weekly zap-api-scan.py-t http://localhost:4003/api/swagger.json-f openapi-r report.html

Find out more on Zap’s wiki...

Page 72: Security Testing with Zap

And the results...

Page 73: Security Testing with Zap

Questions so far?

Page 74: Security Testing with Zap

So we have dynamic security tests...

Page 75: Security Testing with Zap

Let’s see if it works…

Page 76: Security Testing with Zap

Should I approve this pull request?

Page 77: Security Testing with Zap

Let's review it...

Page 78: Security Testing with Zap

That looks good...

Page 79: Security Testing with Zap

But the tests are failing...

Page 80: Security Testing with Zap

Let's see why...

Page 81: Security Testing with Zap

Source: https://giphy.com/gifs/thisisgiphy-reaction-audience-l4HodBpDmoMA5p9bG

Page 82: Security Testing with Zap

Conclusion

Page 83: Security Testing with Zap

Security Testing Options

Passive (Proxy) Active (OpenAPI)

Simple to integrate Simple to integrate

Wide coverage Wide Coverage

Fast Slow

Mixing tests types Dedicated tests types

Page 84: Security Testing with Zap
Page 85: Security Testing with Zap

GitHub Only?

Page 86: Security Testing with Zap

How can you use it?

Page 87: Security Testing with Zap

Useful links

● Pull Request – adding security tests to Tweek

● Malicious Pull Request – The one show a few slides above

● Demo repo – Adding security tests to vulnerable app - Juice Shop

● Blog Post – how I added security tests to Tweek

@omerlh@yshayy

Page 88: Security Testing with Zap

@omerlh@yshayy

Thank You!