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

PDF
The Secret Life of a Bug Bounty Hunter โ€“ Frans Rosรฉn @ Security Fest 2016
ODP
Automating OWASP ZAP - DevCSecCon talk
PPTX
Owasp zap
PDF
No Easy Breach DerbyCon 2016
PDF
2021 ZAP Automation in CI/CD
PDF
Introduction to SAML 2.0
PPTX
ใ‚นใƒžใƒ›ใ‚ฒใƒผใƒ ใฎใƒใƒผใƒˆๆ‰‹ๆณ•ใจใใฎๅฏพ็ญ– [DeNA TechCon 2019]
ย 
PPTX
Nmap and metasploitable
The Secret Life of a Bug Bounty Hunter โ€“ Frans Rosรฉn @ Security Fest 2016
Automating OWASP ZAP - DevCSecCon talk
Owasp zap
No Easy Breach DerbyCon 2016
2021 ZAP Automation in CI/CD
Introduction to SAML 2.0
ใ‚นใƒžใƒ›ใ‚ฒใƒผใƒ ใฎใƒใƒผใƒˆๆ‰‹ๆณ•ใจใใฎๅฏพ็ญ– [DeNA TechCon 2019]
ย 
Nmap and metasploitable

What's hot (20)

PPTX
์„œ๋ฒ„ ์•„ํ‚คํ…์ฒ˜ ์ดํ•ด๋ฅผ ์œ„ํ•œ ํ”„๋กœ์„ธ์Šค์™€ ์“ฐ๋ ˆ๋“œ
PPTX
OWASP Top 10 2021 Presentation (Jul 2022)
PPT
Pentesting Using Burp Suite
PPTX
Pentesting jwt
PDF
Hyperledger Indy tutorial
PDF
Pentesting like a grandmaster BSides London 2013
PDF
OpenID Connectๅ…ฅ้–€
PPTX
Attacking thru HTTP Host header
ODP
OAuth2 - Introduction
PDF
OWASP API Security Top 10 - API World
PDF
How to steal and modify data using Business Logic flaws - Insecure Direct Obj...
PPTX
The OWASP Zed Attack Proxy
PDF
Insecure direct object reference (null delhi meet)
PPTX
Reverse proxies & Inconsistency
PPTX
Hunting for APT in network logs workshop presentation
PDF
BugBounty Roadmap with Mohammed Adam
PDF
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
PPTX
Pentesting ReST API
PDF
Owasp zap
PDF
Android Developer JeongJaeyun
์„œ๋ฒ„ ์•„ํ‚คํ…์ฒ˜ ์ดํ•ด๋ฅผ ์œ„ํ•œ ํ”„๋กœ์„ธ์Šค์™€ ์“ฐ๋ ˆ๋“œ
OWASP Top 10 2021 Presentation (Jul 2022)
Pentesting Using Burp Suite
Pentesting jwt
Hyperledger Indy tutorial
Pentesting like a grandmaster BSides London 2013
OpenID Connectๅ…ฅ้–€
Attacking thru HTTP Host header
OAuth2 - Introduction
OWASP API Security Top 10 - API World
How to steal and modify data using Business Logic flaws - Insecure Direct Obj...
The OWASP Zed Attack Proxy
Insecure direct object reference (null delhi meet)
Reverse proxies & Inconsistency
Hunting for APT in network logs workshop presentation
BugBounty Roadmap with Mohammed Adam
XXE Exposed: SQLi, XSS, XXE and XEE against Web Services
Pentesting ReST API
Owasp zap
Android Developer JeongJaeyun
Ad

Viewers also liked (14)

PDF
Proxies are Awesome!
PPTX
Scripts that automate OWASP ZAP as part of a continuous delivery pipeline
PPTX
Bennett's hierarchy of outcomes
PPTX
Potomac school 2016 small
ODP
2014 ZAP Workshop 2: Contexts and Fuzzing
ODP
BlackHat 2014 OWASP ZAP Turbo Talk
PPTX
Veracode - Inglรชs
PPTX
Zap vs burp
PDF
Selecting a Research Proposal Topic, Spring 2012
PPT
Bennett Models Of Change
ย 
PDF
Healthcare application-security-practices-survey-veracode
PPTX
My research proposal.ppt
PPT
The Research Proposal
PPTX
Case study-research-method
Proxies are Awesome!
Scripts that automate OWASP ZAP as part of a continuous delivery pipeline
Bennett's hierarchy of outcomes
Potomac school 2016 small
2014 ZAP Workshop 2: Contexts and Fuzzing
BlackHat 2014 OWASP ZAP Turbo Talk
Veracode - Inglรชs
Zap vs burp
Selecting a Research Proposal Topic, Spring 2012
Bennett Models Of Change
ย 
Healthcare application-security-practices-survey-veracode
My research proposal.ppt
The Research Proposal
Case study-research-method
Ad

Similar to AllDayDevOps ZAP automation in CI (20)

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

More from Simon Bennetts (13)

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

Recently uploaded (20)

PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PDF
๐Ÿ’ฐ ๐”๐Š๐“๐ˆ ๐Š๐„๐Œ๐„๐๐€๐๐†๐€๐ ๐Š๐ˆ๐๐„๐‘๐Ÿ’๐ƒ ๐‡๐€๐‘๐ˆ ๐ˆ๐๐ˆ ๐Ÿ๐ŸŽ๐Ÿ๐Ÿ“ ๐Ÿ’ฐ
ย 
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
DOCX
Unit-3 cyber security network security of internet system
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PPTX
Digital Literacy And Online Safety on internet
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PDF
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPT
tcp ip networks nd ip layering assotred slides
PPTX
Internet___Basics___Styled_ presentation
PPTX
artificial intelligence overview of it and more
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PDF
Testing WebRTC applications at scale.pdf
PPTX
presentation_pfe-universite-molay-seltan.pptx
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
innovation process that make everything different.pptx
Job_Card_System_Styled_lorem_ipsum_.pptx
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
๐Ÿ’ฐ ๐”๐Š๐“๐ˆ ๐Š๐„๐Œ๐„๐๐€๐๐†๐€๐ ๐Š๐ˆ๐๐„๐‘๐Ÿ’๐ƒ ๐‡๐€๐‘๐ˆ ๐ˆ๐๐ˆ ๐Ÿ๐ŸŽ๐Ÿ๐Ÿ“ ๐Ÿ’ฐ
ย 
introduction about ICD -10 & ICD-11 ppt.pptx
Unit-3 cyber security network security of internet system
Decoding a Decade: 10 Years of Applied CTI Discipline
Digital Literacy And Online Safety on internet
An introduction to the IFRS (ISSB) Stndards.pdf
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
Paper PDF World Game (s) Great Redesign.pdf
tcp ip networks nd ip layering assotred slides
Internet___Basics___Styled_ presentation
artificial intelligence overview of it and more
Slides PDF The World Game (s) Eco Economic Epochs.pdf
SASE Traffic Flow - ZTNA Connector-1.pdf
Testing WebRTC applications at scale.pdf
presentation_pfe-universite-molay-seltan.pptx
PptxGenJS_Demo_Chart_20250317130215833.pptx
innovation process that make everything different.pptx

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 psiinon@gmail.com 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