SlideShare a Scribd company logo
November 15, 2016
The OWASP Foundation
http://www.owasp.org
Copyright © The OWASP Foundation
Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License.
Security Scanning
using OWASP ZAP
in a CI pipeline
Simon Bennetts
OWASP ZAP Project Lead
Mozilla Cloud Security Team
psiinon@gmail.com
AllDayDevOps.com
2016
The Plan
• Who is this for?
• What are we trying to solve?
• What can you get out of this?
• Introduction to ZAP
• Where to start
• Where to go from there
3
Who is this for?
• Developers
• QA
• Operations
• Security
• Consultants
• (Managers)
• Whoever is involved in automation ;)
4
What are we trying to solve?
• Find security issues as early as possible
• Integration into the devops pipeline
• Finding all of the possible vulnerabilities
• Putting pentesters out of a job :P
5
What are we not trying to solve?
What can you get out of this?
• A way to quickly evaluate your apps
• Options for more thorough scanning
• An introduction to the ZAP API
6
7
ZAP Introduction
• An easy to use webapp pentest tool
• Completely free and open source
• OWASP Flagship project
• Ideal for beginners
• But also used by professionals
• Ideal for devs, esp. for automated security tests
• Included in all major security distributions
• ToolsWatch.org Top Security Tool of 2015
• Not a silver bullet!
8
ZAP Features
• Swing based UI for desktop mode
• Comprehensive API for daemon mode
• Plugin architecture (add-ons)
• Online ‘marketplace’ (all free:)
• Release, beta and alpha quality add-ons
• Traditional and ajax spiders
• Passive and active scanning
• Highly configurable, eg scan policies
• Highly scriptable
Some ZAP use cases
• Point and shoot – the Quick Start tab
• Proxying via ZAP, and then scanning
• Manual pentesting
• Automated security regression tests
• Debugging
• Part of a larger security program
9
ZAP Install Options
• Windows .exe
• Linux .tar.gz
• Mac OS .dmg
• Docker Images
• owasp/zap2docker-stable
• owasp/zap2docker-weekly
• Distros like Kali
10
Where to start?
• The Baseline scan
• Completely safe
• Runs quickly (1-2 minutes?)
• Can be easily integrated into CI/CD
• Easy to get started – just required the target:
• Very configurable if needed
11
• docker pull owasp/zap2docker-weekly
• docker run -t owasp/zap2docker-weekly 
zap-baseline.py -t https://www.example.com
Baseline scan
• Uses docker (the only dependency)
• Time limited spider of target (default 1 min)
• Just passive scanning
• By default warns on all issues
• Can change to ignore, info or fail
• Can include any ZAP cmdline option
• Can ignore any url regex for any rule
12
Baseline scan - issues
• All release and beta passive scan rules, eg
• Missing / incorrect security headers
• Cookie problems
• Information / error disclosure
• Missing CSRF tokens
•...
• Can optionally include alpha pscan rules
13
Baseline scan – usage
14
Usage: zap-baseline.py -t <target> [options]
-t target target URL including the protocol, eg https://www
Options:
-c config_file config file to use to INFO, IGNORE or FAIL warnin
-u config_url URL of config file to use to INFO, IGNORE or FAIL
-g gen_file generate default config file (all rules set to WA
-m mins the number of minutes to spider for (default 1)
-r report_html file to write the full ZAP HTML report
-w report_md file to write the full ZAP Wiki (Markdown) report
-x report_xml file to write the full ZAP XML report
-a include the alpha passive scan rules as well
-d show debug messages
-i default rules not in the config file to INFO
-j use the Ajax spider in addition to the traditiona
-l level minimum level to show: PASS, IGNORE, INFO, WARN o
-s short output format - dont show PASSes or example
-z zap_options ZAP command line options e.g. -z "-config aaa=bbb
Baseline scan – output
16
./zap-baseline.py -t https://www.example.com
3 URLs
PASS: Cookie No HttpOnly Flag [10010]
PASS: Cookie Without Secure Flag [10011]
PASS: Password Autocomplete in Browser [10012]
<snip>
WARN: Incomplete or No Cache-control and Pragma HTTP Header Set [10015]
https://www.example.com
WARN: Web Browser XSS Protection Not Enabled [10016] x 3
https://www.example.com
https://www.example.com/robots.txt
https://www.example.com/sitemap.xml
WARN: X-Frame-Options Header Not Set [10020] x 1
https://www.example.com
WARN: X-Content-Type-Options Header Missing [10021] x 1
https://www.example.com
FAIL: 0 WARN: 4 INFO: 0 IGNORE: 0 PASS: 22
Baseline scan – conf file
• Use -g option to generate, -c or -u to use
17
# zap-baseline rule configuration file
# Change WARN to IGNORE to ignore rule or FAIL to fail if rule matches
# Only the rule identifiers are used - the names are just for info
# You can add your own messages to each rule by appending them after a
10010 WARN(Cookie No HttpOnly Flag)
10011 WARN(Cookie Without Secure Flag)
10012 WARN(Password Autocomplete in Browser)
10015 WARN(Incomplete or No Cache-control and Pragma HTTP Header Set)
10016 WARN(Web Browser XSS Protection Not Enabled)
10017 WARN(Cross-Domain JavaScript Source File Inclusion)
10019 WARN(Content-Type Header Missing)
10020 WARN(X-Frame-Options Header Scanner)
10021 WARN(X-Content-Type-Options Header Missing)
10023 WARN(Information Disclosure - Debug Error Messages)
10024 WARN(Information Disclosure - Sensitive Information in URL)
10025 WARN(Information Disclosure - Sensitive Information in HTTP Refer
Where next?
• Mass Baseline scan
• Provides a simple dashboard
• Shows the detailed results
• Shows the per service history
18
Mass Baseline scan
• Part of the community-scripts repo:
zaproxy/community-scripts/api/mass-baseline
19
Full Scans
• Packaged options:
• Cmdline quick scan
• Jenkins plugin
• Sdlc-integration scripts
• Daemon mode + API
• (ZAP as a Service – in development)
20
Cmdline Quick Scan
21
./zap.sh -cmd -quickurl 
http://example.com/ -quickprogress
• Spidering
• Active scanning
• [====================] 100%
• Attack complete
• <?xml version="1.0"?><OWASPZAPReport
version="2.5.0" generated="Tue, 4 Oct 2016
09:31:53">
• <site name="http://example.com" ...
Old Jenkins plugin
• https://github.com/jenkinsci/zaproxy-plugin
• Developed by 3rd
party
• No longer maintained
• Doesn’t work well with latest versions of ZAP
22
New Jenkins plugin
New Jenkins plugin
• Fork and rewrite of the old plugin
• Maintained by the ZAP core team
• Supports authentication, scan policies, Jira integration
• To be released very soon - hopefully next week!)
• Will be at https://github.com/jenkinsci/zap-plugin
• Will be featured on the ZAP blog zaproxy.blogspot.com
• Will work best with weekly releases
(until ZAP 2.6.0 is released)
24
Sdlc integration scripts
• Part of the community-scripts repo:
zaproxy/community-scripts/api/sdlc-integration
• Spidering, passive and active scanning
• Supports authentication
• Supports JIRA integration
• Linux only, requires some file editing
25
Useful cmdline options
• Turn off db recovery (speeds things up)
-config database.recoverylog=false
• Update all add-ons
-addonupdate
• Install a non default add-on
-addoninstall addonname
• Setting the API key
-config api.key=j8WdOEq8dhwWE24VGDsreP
• Disable API key in a safe environment
-config api.disablekey=true
26
Using the ZAP API
• Intro to the API
• Exploring
• Scanning
• Reporting
• Authenticating
• Tuning
27
Intro to the API
• RESTish – ok, only uses GET requests
http(s)://zap/<format>/<component>/
<operation>/<op name>[/?<params>]
• Maps closely to the UI / code
• Theres a v basic (but complete) web UI for it
• And clients in various langs:
Java, Python, Node JS, .Net, PHP, Go …
• Clients are generated from the code
28
API UI – Top Level
API Pro Tips
1. Experiment with the Desktop UI
2. Export configs from the UI (contexts, scan policies..)
3. Then reproduce using the API UI
4. Finally convert to a script
30
Intro – Python API
• Install from pypi:
pip install python-owasp-zap-v2.4
• In your script:
from zapv2 import ZAPv2
zap = ZAPv2()
zap = ZAPv2(proxies={
'http': 'http://localhost:8080',
'https': 'http://localhost:8090'})
31
h
from zapv2 import ZAPv2
zap = ZAPv2()
zap = ZAPv2(proxies={
'http': 'http://localhost:8090',
'https': 'http://localhost:8090'})
• zap.urlopen(target)
• pip install python-owasp-zap-v2.4
Exploring
• Proxy Regression / Unit tests
• Traditional Spider (crawler)
• Ajax Spider (browsers)
• Spider SOAP definition (via alpha add-on)
• Import ModSecurity2 logs (via alpha add-on)
32
Spider Desktop and API UIs
Spider Desktop and API UIs
Exploring – Trad Spider
35
h
zap.spider.scan(target)
• time.sleep(5)
• while int(zap.spider.status()) < 100:
• print ('Spider progress %: ' +
zap.spider.status())
• time.sleep(5)
• print ('Spider completed')
Exploring – Ajax Spider
36
h
zap.ajaxSpider.scan(target)
• time.sleep(5)
• while zap.ajaxSpider.status() == 'running':
• print ('Ajax Spider # results: ' +
zap.ajaxSpider.number_of_results())
• time.sleep(5)
• print ('Ajax Spider completed')
Scanning – Passive Scan
37
while int(zap.pscan.records_to_scan()) > 0:
• print ('Pscan records : ' +
zap.pscan.records_to_scan())
• time.sleep(5)
• print ('Pscan completed')
h
• Passive scanning happens automatically when
proxying
• To tell when its finished:
Scanning – Active Scan
38
h
zap.ascan.scan(target)
• time.sleep(5)
• while int(zap.ascan.status()) < 100:
• print ('Ascan progress %: ' +
zap.ascan.status())
• time.sleep(5)
• print ('Ascan completed')
Reporting – HTML + XML
39
h
# HTML Report
• with open ('report.html', 'w') as f:
f.write(zap.core.htmlreport())
# XML Report
• with open ('report.xml', 'w') as f:
f.write(zap.core.xmlreport())
Reporting – all alert data
40
h
# Use paging for lots of alerts
• offset = 0; page = 5000
• alerts = zap.core.alerts('', offset, page)
• while len(alerts) > 0:
• for alert in alerts:
• # Do whatever you want with alert
• offset += page
• alerts = zap.core.alerts('', offset, page)
And dont forget...
41
h
# Your work here is done...
• zap.core.shutdown()
Authenticating
• Authentication can be hard :(
• Simple form based auth should be ok
• Authentication scripts should be able to handle anything
• But if you have complex SSO or equiv you may want a
simpler option in your test env
• Pro Top: use the UI to set authentication up!
42
Tuning - speed
• Spider time limits
• Data driven content
• Technology
• Active scan
• Scan rules
• Input vectors
• Attack strength
43
Tuning - feedback
• Active scan stats
• Response stats
• Authentication stats (alpha add-on)
• Statsd support
44
Tuning - accuracy
• Attack thresholds
• Rule configuration (post 2.5.0)
– Forms that dont need CSRF tokens
– Increase timing attacks from 5 seconds
45
And if you need help...
• ZAP Getting Started Guide
• ZAP User Guide
• ZAP User Group
• ZAP Developer Group
• ZAP wiki, includes links to videos
• irc.mozilla.com #websectools
46
Talk Summary
• Use the baseline scan for a quick security overview
• Use the mass baseline to create a dashboard
• Use the new Jenkins plugin for more depth
• Use the ZAP API for even more control
• If you need help, just ask :)
47
November 15, 2016
November 15, 2016

More Related Content

ODP
Automating OWASP ZAP - DevCSecCon talk
Simon Bennetts
 
PPTX
[NDC17] Kubernetes로 개발서버 간단히 찍어내기
SeungYong Oh
 
PDF
[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기
Chanwoong Kim
 
PDF
【B-4】オープンソース開発で、フリー静的解析ツールを使ってみる
Developers Summit
 
PDF
AstriCon 2017 - Docker Swarm & Asterisk
Evan McGee
 
PDF
Containerd Internals: Building a Core Container Runtime
Phil Estes
 
PDF
Dockerfileを改善するためのBest Practice 2019年版
Masahito Zembutsu
 
PDF
[OpenInfra Days Korea 2018] (Track 2) Neutron LBaaS 어디까지 왔니? - Octavia 소개
OpenStack Korea Community
 
Automating OWASP ZAP - DevCSecCon talk
Simon Bennetts
 
[NDC17] Kubernetes로 개발서버 간단히 찍어내기
SeungYong Oh
 
[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기
Chanwoong Kim
 
【B-4】オープンソース開発で、フリー静的解析ツールを使ってみる
Developers Summit
 
AstriCon 2017 - Docker Swarm & Asterisk
Evan McGee
 
Containerd Internals: Building a Core Container Runtime
Phil Estes
 
Dockerfileを改善するためのBest Practice 2019年版
Masahito Zembutsu
 
[OpenInfra Days Korea 2018] (Track 2) Neutron LBaaS 어디까지 왔니? - Octavia 소개
OpenStack Korea Community
 

What's hot (20)

PDF
Fluent Bit: Log Forwarding at Scale
Eduardo Silva Pereira
 
PPTX
나의 이직 이야기
종립 이
 
PDF
Laravelとテストについて
Takeo Noda
 
PPT
Docker introduction
Phuc Nguyen
 
PDF
Oss貢献超入門
Michihito Shigemura
 
PDF
글로벌 게임 플랫폼에서 무정지, 무점검 서버 개발과 운영 사례
if kakao
 
PDF
JenkinsとDockerって何が良いの? 〜言うてるオレもわからんわ〜 #jenkinsstudy
Kazuhito Miura
 
PDF
コンテナイメージの脆弱性スキャンについて
YASUKAZU NAGATOMI
 
PDF
[야생의 땅: 듀랑고] 서버 아키텍처 - SPOF 없는 분산 MMORPG 서버
Heungsub Lee
 
PDF
低レイヤー入門
demuyan
 
PDF
From Zero to Docker
Abhishek Verma
 
PDF
webエンジニアのためのはじめてのredis
nasa9084
 
PDF
アジャイル開発のストーリーをGherkin記法で作成
Shinya Nakajima
 
PDF
GoによるWebアプリ開発のキホン
Akihiko Horiuchi
 
PPTX
How Kubernetes scheduler works
Himani Agrawal
 
PDF
Dockerからcontainerdへの移行
Kohei Tokunaga
 
PDF
AWS Lambdaを紐解く
Keisuke Nishitani
 
PPTX
Backstage at CNCF Madison.pptx
BrandenTimm1
 
PDF
こんなに使える!今どきのAPIドキュメンテーションツール
dcubeio
 
PDF
실시간 게임 서버 최적화 전략
YEONG-CHEON YOU
 
Fluent Bit: Log Forwarding at Scale
Eduardo Silva Pereira
 
나의 이직 이야기
종립 이
 
Laravelとテストについて
Takeo Noda
 
Docker introduction
Phuc Nguyen
 
Oss貢献超入門
Michihito Shigemura
 
글로벌 게임 플랫폼에서 무정지, 무점검 서버 개발과 운영 사례
if kakao
 
JenkinsとDockerって何が良いの? 〜言うてるオレもわからんわ〜 #jenkinsstudy
Kazuhito Miura
 
コンテナイメージの脆弱性スキャンについて
YASUKAZU NAGATOMI
 
[야생의 땅: 듀랑고] 서버 아키텍처 - SPOF 없는 분산 MMORPG 서버
Heungsub Lee
 
低レイヤー入門
demuyan
 
From Zero to Docker
Abhishek Verma
 
webエンジニアのためのはじめてのredis
nasa9084
 
アジャイル開発のストーリーをGherkin記法で作成
Shinya Nakajima
 
GoによるWebアプリ開発のキホン
Akihiko Horiuchi
 
How Kubernetes scheduler works
Himani Agrawal
 
Dockerからcontainerdへの移行
Kohei Tokunaga
 
AWS Lambdaを紐解く
Keisuke Nishitani
 
Backstage at CNCF Madison.pptx
BrandenTimm1
 
こんなに使える!今どきのAPIドキュメンテーションツール
dcubeio
 
실시간 게임 서버 최적화 전략
YEONG-CHEON YOU
 
Ad

Viewers also liked (15)

PDF
Proxies are Awesome!
Brendan Eich
 
PPTX
Scripts that automate OWASP ZAP as part of a continuous delivery pipeline
Sherif Mansour
 
PPTX
The OWASP Zed Attack Proxy
Aditya Gupta
 
PPTX
Bennett's hierarchy of outcomes
Tan Ching
 
PPTX
Potomac school 2016 small
Stephen Maguire
 
ODP
2014 ZAP Workshop 2: Contexts and Fuzzing
Simon Bennetts
 
ODP
BlackHat 2014 OWASP ZAP Turbo Talk
Simon Bennetts
 
PPTX
Veracode - Inglês
DeServ - Tecnologia e Servços
 
PPTX
Zap vs burp
Tomasz Fajks
 
PDF
Selecting a Research Proposal Topic, Spring 2012
utepgrad
 
PPT
Bennett Models Of Change
svirani
 
PDF
Healthcare application-security-practices-survey-veracode
Veracode
 
PPTX
My research proposal.ppt
nanimamat
 
PPT
The Research Proposal
guest349908
 
PPTX
Case study-research-method
Renu Susan Thomas
 
Proxies are Awesome!
Brendan Eich
 
Scripts that automate OWASP ZAP as part of a continuous delivery pipeline
Sherif Mansour
 
The OWASP Zed Attack Proxy
Aditya Gupta
 
Bennett's hierarchy of outcomes
Tan Ching
 
Potomac school 2016 small
Stephen Maguire
 
2014 ZAP Workshop 2: Contexts and Fuzzing
Simon Bennetts
 
BlackHat 2014 OWASP ZAP Turbo Talk
Simon Bennetts
 
Veracode - Inglês
DeServ - Tecnologia e Servços
 
Zap vs burp
Tomasz Fajks
 
Selecting a Research Proposal Topic, Spring 2012
utepgrad
 
Bennett Models Of Change
svirani
 
Healthcare application-security-practices-survey-veracode
Veracode
 
My research proposal.ppt
nanimamat
 
The Research Proposal
guest349908
 
Case study-research-method
Renu Susan Thomas
 
Ad

Similar to AllDayDevOps ZAP automation in CI (20)

ODP
Simon Bennetts - Automating ZAP
DevSecCon
 
ODP
2017 Codemotion OWASP ZAP in CI/CD
Simon Bennetts
 
PDF
Security Testing with OWASP ZAP in CI/CD - Simon Bennetts - Codemotion Amster...
Codemotion
 
PDF
N Different Strategies to Automate OWASP ZAP - OWASP APPSec BUCHAREST - Oct 1...
gmaran23
 
PDF
2021 ZAP Automation in CI/CD
Simon Bennetts
 
ODP
Automating Web Application Security Testing With OWASP ZAP DOT NET API - Tech...
gmaran23
 
ODP
JavaOne 2014 Security Testing for Developers using OWASP ZAP
Simon Bennetts
 
PDF
N Different Strategies to Automate OWASP ZAP - Cybersecurity WithTheBest - Oc...
gmaran23
 
PDF
we45 DEFCON Workshop - Building AppSec Automation with Python
Abhay Bhargav
 
PPTX
DC612 Day - Hands on Penetration Testing 101
dc612
 
PPT
Automating security test using Selenium and OWASP ZAP - Practical DevSecOps
Mohammed A. Imran
 
PDF
DAST in CI/CD pipelines using Selenium & OWASP ZAP
srini0x00
 
PPTX
OWASP ZAP Workshop for QA Testers
Javan Rasokat
 
PDF
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
Christian Schneider
 
ODP
OWASP 2013 APPSEC USA Talk - OWASP ZAP
Simon Bennetts
 
ODP
OWASP 2013 APPSEC USA ZAP Hackathon
Simon Bennetts
 
PDF
OpenSCAP Overview(security scanning for docker image and container)
Jooho Lee
 
PDF
Large-scaled Deploy Over 100 Servers in 3 Minutes
Hiroshi SHIBATA
 
PDF
Silent web app testing by example - BerlinSides 2011
Abraham Aranguren
 
PPTX
Riga Dev Day - Automated Android Continuous Integration
Nicolas Fränkel
 
Simon Bennetts - Automating ZAP
DevSecCon
 
2017 Codemotion OWASP ZAP in CI/CD
Simon Bennetts
 
Security Testing with OWASP ZAP in CI/CD - Simon Bennetts - Codemotion Amster...
Codemotion
 
N Different Strategies to Automate OWASP ZAP - OWASP APPSec BUCHAREST - Oct 1...
gmaran23
 
2021 ZAP Automation in CI/CD
Simon Bennetts
 
Automating Web Application Security Testing With OWASP ZAP DOT NET API - Tech...
gmaran23
 
JavaOne 2014 Security Testing for Developers using OWASP ZAP
Simon Bennetts
 
N Different Strategies to Automate OWASP ZAP - Cybersecurity WithTheBest - Oc...
gmaran23
 
we45 DEFCON Workshop - Building AppSec Automation with Python
Abhay Bhargav
 
DC612 Day - Hands on Penetration Testing 101
dc612
 
Automating security test using Selenium and OWASP ZAP - Practical DevSecOps
Mohammed A. Imran
 
DAST in CI/CD pipelines using Selenium & OWASP ZAP
srini0x00
 
OWASP ZAP Workshop for QA Testers
Javan Rasokat
 
Security DevOps - Staying secure in agile projects // OWASP AppSecEU 2015 - A...
Christian Schneider
 
OWASP 2013 APPSEC USA Talk - OWASP ZAP
Simon Bennetts
 
OWASP 2013 APPSEC USA ZAP Hackathon
Simon Bennetts
 
OpenSCAP Overview(security scanning for docker image and container)
Jooho Lee
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Hiroshi SHIBATA
 
Silent web app testing by example - BerlinSides 2011
Abraham Aranguren
 
Riga Dev Day - Automated Android Continuous Integration
Nicolas Fränkel
 

More from Simon Bennetts (14)

PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PDF
2022 OWASP AppSec USA Keynote
Simon Bennetts
 
PDF
2020 OWASP Thailand - ZAP intro
Simon Bennetts
 
PDF
2020 ADDO Spring Break OWASP ZAP Automation
Simon Bennetts
 
ODP
2017 DevSecCon ZAP Scripting Workshop
Simon Bennetts
 
ODP
OWASP 2015 AppSec EU ZAP 2.4.0 and beyond..
Simon Bennetts
 
ODP
2014 ZAP Workshop 1: Getting Started
Simon Bennetts
 
ODP
OWASP 2014 AppSec EU ZAP Advanced Features
Simon Bennetts
 
ODP
BSides Manchester 2014 ZAP Advanced Features
Simon Bennetts
 
ODP
OWASP 2013 Limerick - ZAP: Whats even newer
Simon Bennetts
 
ODP
JoinSEC 2013 London - ZAP Intro
Simon Bennetts
 
ODP
OWASP 2013 AppSec EU Hamburg - ZAP Innovations
Simon Bennetts
 
ODP
OWASP 2013 EU Tour Amsterdam ZAP Intro
Simon Bennetts
 
ODP
OWASP 2012 AppSec Dublin ZAP Intro
Simon Bennetts
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
2022 OWASP AppSec USA Keynote
Simon Bennetts
 
2020 OWASP Thailand - ZAP intro
Simon Bennetts
 
2020 ADDO Spring Break OWASP ZAP Automation
Simon Bennetts
 
2017 DevSecCon ZAP Scripting Workshop
Simon Bennetts
 
OWASP 2015 AppSec EU ZAP 2.4.0 and beyond..
Simon Bennetts
 
2014 ZAP Workshop 1: Getting Started
Simon Bennetts
 
OWASP 2014 AppSec EU ZAP Advanced Features
Simon Bennetts
 
BSides Manchester 2014 ZAP Advanced Features
Simon Bennetts
 
OWASP 2013 Limerick - ZAP: Whats even newer
Simon Bennetts
 
JoinSEC 2013 London - ZAP Intro
Simon Bennetts
 
OWASP 2013 AppSec EU Hamburg - ZAP Innovations
Simon Bennetts
 
OWASP 2013 EU Tour Amsterdam ZAP Intro
Simon Bennetts
 
OWASP 2012 AppSec Dublin ZAP Intro
Simon Bennetts
 

Recently uploaded (20)

PPTX
Parallel & Concurrent ...
yashpavasiya892
 
PDF
LOGENVIDAD DANNYFGRETRRTTRRRTRRRRRRRRR.pdf
juan456ytpro
 
PDF
DNSSEC Made Easy, presented at PHNOG 2025
APNIC
 
PDF
BGP Security Best Practices that Matter, presented at PHNOG 2025
APNIC
 
PPTX
Blue and Dark Blue Modern Technology Presentation.pptx
ap177979
 
PPTX
Perkembangan Perangkat jaringan komputer dan telekomunikasi 3.pptx
Prayudha3
 
PPT
Introduction to dns domain name syst.ppt
MUHAMMADKAVISHSHABAN
 
PPTX
原版北不列颠哥伦比亚大学毕业证文凭UNBC成绩单2025年新版在线制作学位证书
e7nw4o4
 
PPTX
Slides Powerpoint: Eco Economic Epochs.pptx
Steven McGee
 
PPT
1965 INDO PAK WAR which Pak will never forget.ppt
sanjaychief112
 
PPTX
谢尔丹学院毕业证购买|Sheridan文凭不见了怎么办谢尔丹学院成绩单
mookxk3
 
PPTX
LESSON-2-Roles-of-ICT-in-Teaching-for-learning_123922 (1).pptx
renavieramopiquero
 
PPTX
Unlocking Hope : How Crypto Recovery Services Can Reclaim Your Lost Funds
lionsgate network
 
PDF
UI/UX Developer Guide: Tools, Trends, and Tips for 2025
Penguin peak
 
PPTX
Artificial-Intelligence-in-Daily-Life (2).pptx
nidhigoswami335
 
PPTX
Different Generation Of Computers .pptx
divcoder9507
 
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
APNIC
 
PPTX
The Latest Scam Shocking the USA in 2025.pptx
onlinescamreport4
 
PDF
Latest Scam Shocking the USA in 2025.pdf
onlinescamreport4
 
PDF
KIPER4D situs Exclusive Game dari server Star Gaming Asia
hokimamad0
 
Parallel & Concurrent ...
yashpavasiya892
 
LOGENVIDAD DANNYFGRETRRTTRRRTRRRRRRRRR.pdf
juan456ytpro
 
DNSSEC Made Easy, presented at PHNOG 2025
APNIC
 
BGP Security Best Practices that Matter, presented at PHNOG 2025
APNIC
 
Blue and Dark Blue Modern Technology Presentation.pptx
ap177979
 
Perkembangan Perangkat jaringan komputer dan telekomunikasi 3.pptx
Prayudha3
 
Introduction to dns domain name syst.ppt
MUHAMMADKAVISHSHABAN
 
原版北不列颠哥伦比亚大学毕业证文凭UNBC成绩单2025年新版在线制作学位证书
e7nw4o4
 
Slides Powerpoint: Eco Economic Epochs.pptx
Steven McGee
 
1965 INDO PAK WAR which Pak will never forget.ppt
sanjaychief112
 
谢尔丹学院毕业证购买|Sheridan文凭不见了怎么办谢尔丹学院成绩单
mookxk3
 
LESSON-2-Roles-of-ICT-in-Teaching-for-learning_123922 (1).pptx
renavieramopiquero
 
Unlocking Hope : How Crypto Recovery Services Can Reclaim Your Lost Funds
lionsgate network
 
UI/UX Developer Guide: Tools, Trends, and Tips for 2025
Penguin peak
 
Artificial-Intelligence-in-Daily-Life (2).pptx
nidhigoswami335
 
Different Generation Of Computers .pptx
divcoder9507
 
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
APNIC
 
The Latest Scam Shocking the USA in 2025.pptx
onlinescamreport4
 
Latest Scam Shocking the USA in 2025.pdf
onlinescamreport4
 
KIPER4D situs Exclusive Game dari server Star Gaming Asia
hokimamad0
 

AllDayDevOps ZAP automation in CI

  • 2. The OWASP Foundation http://www.owasp.org Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. Security Scanning using OWASP ZAP in a CI pipeline Simon Bennetts OWASP ZAP Project Lead Mozilla Cloud Security Team [email protected] AllDayDevOps.com 2016
  • 3. The Plan • Who is this for? • What are we trying to solve? • What can you get out of this? • Introduction to ZAP • Where to start • Where to go from there 3
  • 4. Who is this for? • Developers • QA • Operations • Security • Consultants • (Managers) • Whoever is involved in automation ;) 4
  • 5. What are we trying to solve? • Find security issues as early as possible • Integration into the devops pipeline • Finding all of the possible vulnerabilities • Putting pentesters out of a job :P 5 What are we not trying to solve?
  • 6. What can you get out of this? • A way to quickly evaluate your apps • Options for more thorough scanning • An introduction to the ZAP API 6
  • 7. 7 ZAP Introduction • An easy to use webapp pentest tool • Completely free and open source • OWASP Flagship project • Ideal for beginners • But also used by professionals • Ideal for devs, esp. for automated security tests • Included in all major security distributions • ToolsWatch.org Top Security Tool of 2015 • Not a silver bullet!
  • 8. 8 ZAP Features • Swing based UI for desktop mode • Comprehensive API for daemon mode • Plugin architecture (add-ons) • Online ‘marketplace’ (all free:) • Release, beta and alpha quality add-ons • Traditional and ajax spiders • Passive and active scanning • Highly configurable, eg scan policies • Highly scriptable
  • 9. Some ZAP use cases • Point and shoot – the Quick Start tab • Proxying via ZAP, and then scanning • Manual pentesting • Automated security regression tests • Debugging • Part of a larger security program 9
  • 10. ZAP Install Options • Windows .exe • Linux .tar.gz • Mac OS .dmg • Docker Images • owasp/zap2docker-stable • owasp/zap2docker-weekly • Distros like Kali 10
  • 11. Where to start? • The Baseline scan • Completely safe • Runs quickly (1-2 minutes?) • Can be easily integrated into CI/CD • Easy to get started – just required the target: • Very configurable if needed 11 • docker pull owasp/zap2docker-weekly • docker run -t owasp/zap2docker-weekly zap-baseline.py -t https://www.example.com
  • 12. Baseline scan • Uses docker (the only dependency) • Time limited spider of target (default 1 min) • Just passive scanning • By default warns on all issues • Can change to ignore, info or fail • Can include any ZAP cmdline option • Can ignore any url regex for any rule 12
  • 13. Baseline scan - issues • All release and beta passive scan rules, eg • Missing / incorrect security headers • Cookie problems • Information / error disclosure • Missing CSRF tokens •... • Can optionally include alpha pscan rules 13
  • 14. Baseline scan – usage 14 Usage: zap-baseline.py -t <target> [options] -t target target URL including the protocol, eg https://www Options: -c config_file config file to use to INFO, IGNORE or FAIL warnin -u config_url URL of config file to use to INFO, IGNORE or FAIL -g gen_file generate default config file (all rules set to WA -m mins the number of minutes to spider for (default 1) -r report_html file to write the full ZAP HTML report -w report_md file to write the full ZAP Wiki (Markdown) report -x report_xml file to write the full ZAP XML report -a include the alpha passive scan rules as well -d show debug messages -i default rules not in the config file to INFO -j use the Ajax spider in addition to the traditiona -l level minimum level to show: PASS, IGNORE, INFO, WARN o -s short output format - dont show PASSes or example -z zap_options ZAP command line options e.g. -z "-config aaa=bbb
  • 15. Baseline scan – output 16 ./zap-baseline.py -t https://www.example.com 3 URLs PASS: Cookie No HttpOnly Flag [10010] PASS: Cookie Without Secure Flag [10011] PASS: Password Autocomplete in Browser [10012] <snip> WARN: Incomplete or No Cache-control and Pragma HTTP Header Set [10015] https://www.example.com WARN: Web Browser XSS Protection Not Enabled [10016] x 3 https://www.example.com https://www.example.com/robots.txt https://www.example.com/sitemap.xml WARN: X-Frame-Options Header Not Set [10020] x 1 https://www.example.com WARN: X-Content-Type-Options Header Missing [10021] x 1 https://www.example.com FAIL: 0 WARN: 4 INFO: 0 IGNORE: 0 PASS: 22
  • 16. Baseline scan – conf file • Use -g option to generate, -c or -u to use 17 # zap-baseline rule configuration file # Change WARN to IGNORE to ignore rule or FAIL to fail if rule matches # Only the rule identifiers are used - the names are just for info # You can add your own messages to each rule by appending them after a 10010 WARN(Cookie No HttpOnly Flag) 10011 WARN(Cookie Without Secure Flag) 10012 WARN(Password Autocomplete in Browser) 10015 WARN(Incomplete or No Cache-control and Pragma HTTP Header Set) 10016 WARN(Web Browser XSS Protection Not Enabled) 10017 WARN(Cross-Domain JavaScript Source File Inclusion) 10019 WARN(Content-Type Header Missing) 10020 WARN(X-Frame-Options Header Scanner) 10021 WARN(X-Content-Type-Options Header Missing) 10023 WARN(Information Disclosure - Debug Error Messages) 10024 WARN(Information Disclosure - Sensitive Information in URL) 10025 WARN(Information Disclosure - Sensitive Information in HTTP Refer
  • 17. Where next? • Mass Baseline scan • Provides a simple dashboard • Shows the detailed results • Shows the per service history 18
  • 18. Mass Baseline scan • Part of the community-scripts repo: zaproxy/community-scripts/api/mass-baseline 19
  • 19. Full Scans • Packaged options: • Cmdline quick scan • Jenkins plugin • Sdlc-integration scripts • Daemon mode + API • (ZAP as a Service – in development) 20
  • 20. Cmdline Quick Scan 21 ./zap.sh -cmd -quickurl http://example.com/ -quickprogress • Spidering • Active scanning • [====================] 100% • Attack complete • <?xml version="1.0"?><OWASPZAPReport version="2.5.0" generated="Tue, 4 Oct 2016 09:31:53"> • <site name="http://example.com" ...
  • 21. Old Jenkins plugin • https://github.com/jenkinsci/zaproxy-plugin • Developed by 3rd party • No longer maintained • Doesn’t work well with latest versions of ZAP 22
  • 23. New Jenkins plugin • Fork and rewrite of the old plugin • Maintained by the ZAP core team • Supports authentication, scan policies, Jira integration • To be released very soon - hopefully next week!) • Will be at https://github.com/jenkinsci/zap-plugin • Will be featured on the ZAP blog zaproxy.blogspot.com • Will work best with weekly releases (until ZAP 2.6.0 is released) 24
  • 24. Sdlc integration scripts • Part of the community-scripts repo: zaproxy/community-scripts/api/sdlc-integration • Spidering, passive and active scanning • Supports authentication • Supports JIRA integration • Linux only, requires some file editing 25
  • 25. Useful cmdline options • Turn off db recovery (speeds things up) -config database.recoverylog=false • Update all add-ons -addonupdate • Install a non default add-on -addoninstall addonname • Setting the API key -config api.key=j8WdOEq8dhwWE24VGDsreP • Disable API key in a safe environment -config api.disablekey=true 26
  • 26. Using the ZAP API • Intro to the API • Exploring • Scanning • Reporting • Authenticating • Tuning 27
  • 27. Intro to the API • RESTish – ok, only uses GET requests http(s)://zap/<format>/<component>/ <operation>/<op name>[/?<params>] • Maps closely to the UI / code • Theres a v basic (but complete) web UI for it • And clients in various langs: Java, Python, Node JS, .Net, PHP, Go … • Clients are generated from the code 28
  • 28. API UI – Top Level
  • 29. API Pro Tips 1. Experiment with the Desktop UI 2. Export configs from the UI (contexts, scan policies..) 3. Then reproduce using the API UI 4. Finally convert to a script 30
  • 30. Intro – Python API • Install from pypi: pip install python-owasp-zap-v2.4 • In your script: from zapv2 import ZAPv2 zap = ZAPv2() zap = ZAPv2(proxies={ 'http': 'http://localhost:8080', 'https': 'http://localhost:8090'}) 31 h from zapv2 import ZAPv2 zap = ZAPv2() zap = ZAPv2(proxies={ 'http': 'http://localhost:8090', 'https': 'http://localhost:8090'}) • zap.urlopen(target) • pip install python-owasp-zap-v2.4
  • 31. Exploring • Proxy Regression / Unit tests • Traditional Spider (crawler) • Ajax Spider (browsers) • Spider SOAP definition (via alpha add-on) • Import ModSecurity2 logs (via alpha add-on) 32
  • 34. Exploring – Trad Spider 35 h zap.spider.scan(target) • time.sleep(5) • while int(zap.spider.status()) < 100: • print ('Spider progress %: ' + zap.spider.status()) • time.sleep(5) • print ('Spider completed')
  • 35. Exploring – Ajax Spider 36 h zap.ajaxSpider.scan(target) • time.sleep(5) • while zap.ajaxSpider.status() == 'running': • print ('Ajax Spider # results: ' + zap.ajaxSpider.number_of_results()) • time.sleep(5) • print ('Ajax Spider completed')
  • 36. Scanning – Passive Scan 37 while int(zap.pscan.records_to_scan()) > 0: • print ('Pscan records : ' + zap.pscan.records_to_scan()) • time.sleep(5) • print ('Pscan completed') h • Passive scanning happens automatically when proxying • To tell when its finished:
  • 37. Scanning – Active Scan 38 h zap.ascan.scan(target) • time.sleep(5) • while int(zap.ascan.status()) < 100: • print ('Ascan progress %: ' + zap.ascan.status()) • time.sleep(5) • print ('Ascan completed')
  • 38. Reporting – HTML + XML 39 h # HTML Report • with open ('report.html', 'w') as f: f.write(zap.core.htmlreport()) # XML Report • with open ('report.xml', 'w') as f: f.write(zap.core.xmlreport())
  • 39. Reporting – all alert data 40 h # Use paging for lots of alerts • offset = 0; page = 5000 • alerts = zap.core.alerts('', offset, page) • while len(alerts) > 0: • for alert in alerts: • # Do whatever you want with alert • offset += page • alerts = zap.core.alerts('', offset, page)
  • 40. And dont forget... 41 h # Your work here is done... • zap.core.shutdown()
  • 41. Authenticating • Authentication can be hard :( • Simple form based auth should be ok • Authentication scripts should be able to handle anything • But if you have complex SSO or equiv you may want a simpler option in your test env • Pro Top: use the UI to set authentication up! 42
  • 42. Tuning - speed • Spider time limits • Data driven content • Technology • Active scan • Scan rules • Input vectors • Attack strength 43
  • 43. Tuning - feedback • Active scan stats • Response stats • Authentication stats (alpha add-on) • Statsd support 44
  • 44. Tuning - accuracy • Attack thresholds • Rule configuration (post 2.5.0) – Forms that dont need CSRF tokens – Increase timing attacks from 5 seconds 45
  • 45. And if you need help... • ZAP Getting Started Guide • ZAP User Guide • ZAP User Group • ZAP Developer Group • ZAP wiki, includes links to videos • irc.mozilla.com #websectools 46
  • 46. Talk Summary • Use the baseline scan for a quick security overview • Use the mass baseline to create a dashboard • Use the new Jenkins plugin for more depth • Use the ZAP API for even more control • If you need help, just ask :) 47