You already know what ZAP is and what pieces it's made of. Now we're going to get it running and, above all, properly configured to test BazarNube. Installing ZAP is easy; the real work is in the configuration: intercepting HTTPS with the root certificate, defining a context and a scope that bound what can be touched, and setting up authentication to reach BazarNube's protected areas (seller panel, checkout, orders API). Without that preparation, ZAP will only see the public part of the store and will miss exactly where the juiciest findings live.

Contents

  1. Ways to install ZAP
  2. Installing with Docker
  3. First steps in the GUI
  4. Configuring the browser and the proxy
  5. Installing the root certificate for HTTPS
  6. Defining the context and the scope
  7. Configuring BazarNube's authentication
  8. Verifying that everything works

Ways to install ZAP

ZAP is distributed in several ways. Choose based on your use:

Method When to use it Note
Installer (Windows/macOS/Linux) Interactive GUI use on your machine Includes an embedded JRE in recent versions
.tar.gz / cross-platform package Linux without an installer, servers Requires Java 17+
Docker (zaproxy/zap-stable) CI/CD, reproducible environments, headless The preferred method for automation
Distro package (apt, snap) Convenience on Linux May lag behind on version

Installing on Linux from the cross-platform package:

# Download and unpack (adjust the version to the latest stable)
cd /opt
curl -L -o ZAP.tar.gz \
  https://github.com/zaproxy/zaproxy/releases/download/v2.15.0/ZAP_2.15.0_Linux.tar.gz
tar -xzf ZAP.tar.gz
cd ZAP_2.15.0

# Launch the GUI
./zap.sh

# Or launch it in daemon mode (no GUI), listening for the API on 8090
./zap.sh -daemon -port 8090 -host 127.0.0.1

Check that you have Java available if you use the cross-platform package:

java -version   # Must be 17 or higher for ZAP 2.14+

Installing with Docker

For BazarNube we'll use Docker often, because staging already runs in containers and this way ZAP lives in the same world. Official images:

  • zaproxy/zap-stable: latest stable version (the one we'll use).
  • zaproxy/zap-weekly: weekly build, for very recent features.
# Pull the stable image
docker pull zaproxy/zap-stable

# Start ZAP in daemon mode, exposing the API on 8090
docker run -u zap -p 8090:8090 -i zaproxy/zap-stable \
  zap.sh -daemon -host 0.0.0.0 -port 8090 \
  -config api.addrs.addr.name=.* \
  -config api.addrs.addr.regex=true

# Launch the ZAP GUI accessible via browser (webswing) on 8080
docker run -u zap -p 8080:8080 -p 8090:8090 -i zaproxy/zap-stable zap-webswing.sh

-config api.addrs.addr.* authorizes API clients. On real networks, restrict the addresses instead of using .*. We'll go deeper into this in 06-04, when the API takes center stage.

For ZAP in Docker to reach BazarNube's staging that also runs in Docker, connect them to the same network:

docker network create bazarnube-net
# ... start the BazarNube app on that network ...
docker run --network bazarnube-net -u zap -i zaproxy/zap-stable \
  zap.sh -daemon -host 0.0.0.0 -port 8090
# Within that network, the app is reachable by its service name, e.g. http://web:3000

First steps in the GUI

When you open the GUI for the first time, ZAP asks whether you want to persist the session. For serious work on BazarNube choose "Yes, I want to persist this session": that way you keep the sites tree, alerts, and history.

Main areas of the interface:

  • Sites (left): the tree of everything discovered about BazarNube.
  • Request / Response (center): the detail of the selected request.
  • History / Search / Alerts / Output (bottom): working tabs. Alerts is where you'll live.
  • Mode bar (top left): the Safe/Protected/Standard/Attack dropdown we saw in 06-01. Set it to Protected.

Configuring the browser and the proxy

ZAP listens by default as a proxy on localhost:8080. You have two paths:

Option A — Built-in browser (recommended to start). ZAP can launch a Firefox/Chrome already preconfigured with the proxy and certificate in place. In the GUI, click "Manual Explore" or "Explore your application" and Launch Browser. It's the frictionless route.

Option B — Your own browser. Point the system or browser proxy to ZAP. Example of manual proxy configuration:

HTTP proxy server:  127.0.0.1
Port:               8080
Use the same proxy for HTTPS: yes

With Firefox and a dedicated profile from the command line:

# Firefox using ZAP as a proxy (isolated profile so you don't pollute yours)
firefox -no-remote -profile /tmp/zap-profile \
  -setDefaultBrowser about:blank &
# Then configure the manual proxy 127.0.0.1:8080 in that profile

If you prefer an extension, FoxyProxy lets you toggle the ZAP proxy with a click.

Installing the root certificate for HTTPS

BazarNube uses HTTPS. For ZAP to see and modify the encrypted traffic, it acts as a legitimate man-in-the-middle: it generates certificates on the fly signed by its own root CA (ZAP Root CA). Your browser must trust that CA, or you'll see certificate errors on every request.

Steps:

  1. In the GUI: Tools > Options > Network > Server Certificates (in older versions, Dynamic SSL Certificates).
  2. Click Save to export the root certificate to a file, e.g. zap_root_ca.cer.
  3. Import it as a trusted CA in the browser or in the system.

Export the certificate from the command line (handy for automation):

# With ZAP running as a daemon and the API on 8090
curl -s "http://127.0.0.1:8090/OTHER/network/other/rootCaCert/" \
  -o zap_root_ca.cer

Trust the CA on Linux (Debian/Ubuntu):

sudo cp zap_root_ca.cer /usr/local/share/ca-certificates/zap_root_ca.crt
sudo update-ca-certificates

In Firefox: Settings > Privacy & Security > Certificates > View Certificates > Authorities > Import and tick "Trust this CA to identify websites".

Security: the private key of that CA lives in your ZAP. Anyone who has it could intercept your traffic. Don't share your ZAP root certificate or leave it installed in day-to-day browsers. Generate a new one periodically from the same panel.

Defining the context and the scope

A context in ZAP is a logical grouping of URLs that represent one application and its rules: which URLs belong to it (scope), how it authenticates, what users there are, what's excluded. It's the key unit for working with focus.

For BazarNube we'll create a context called BazarNube-Staging:

  1. In the Sites tree, right-click on the staging domain > Include in Context > New Context.
  2. Define the scope with include and exclude regular expressions.

Example scope patterns:

Type Pattern Reason
Include https://staging\.bazarnube\.local.* The whole staging app
Exclude https://staging\.bazarnube\.local/logout.* Prevents the spider from logging you out
Exclude https://staging\.bazarnube\.local/api/payments.* Don't trigger real test charges
Exclude .*pay\.tercero\.com.* External gateway: out of scope

The /logout exclusion pattern is one of the most useful tricks: without it, the spider follows the "Log out" link, loses the authenticated session, and stops seeing the private areas.

Configuring BazarNube's authentication

Much of BazarNube's risk (the IDOR in /api/orders/{id}, the seller panel) is behind the login. For ZAP to test those areas, you have to teach it to authenticate and to keep the session alive.

BazarNube uses form login that returns a JWT in a session cookie. Configuration in the context:

1. Authentication method (Context > Authentication). Choose Form-based Authentication and define the login request:

Login form target URL:  https://staging.bazarnube.local/api/auth/login
Login request POST data: {"email":"{%username%}","password":"{%password%}"}
Content-Type:            application/json

2. Session indicators — how ZAP knows whether it's still authenticated:

  • Logged-in indicator (regex that appears ONLY when authenticated): \"role\":\"seller\" or the text "Log out".
  • Logged-out indicator (regex that appears when the session is lost): Sign in or a 401.

3. Session management (Session Management). For a JWT in a header, use HTTP Header Based Session Management, or Cookie-based if it travels in a cookie.

4. Users (Context > Users). Create staging test users (never real production credentials):

User 1:  buyer_test    / Password123!
User 2:  seller_test   / Password123!

Having two users lets you test access control (can buyer_test read seller_test's orders?), which is the essence of the backlog's IDOR.

How the whole session flow fits together:

graph TD
    A[ZAP sends login POST] --> B{Does the response contain<br/>the logged-in indicator?}
    B -->|Yes| C[Valid session: store token/cookie]
    B -->|No| D[Retry authentication]
    C --> E[Spider and scanner use the session]
    E --> F{Is the<br/>logged-out indicator detected?}
    F -->|Yes| D
    F -->|No| E

Quick check with the ZAP API (context and user already created):

# Force authentication of a user and check that the session is valid
curl "http://127.0.0.1:8090/JSON/users/action/setUserEnabled/" \
  --data-urlencode "contextId=1" \
  --data-urlencode "userId=1" \
  --data-urlencode "enabled=true"

Verifying that everything works

Before scanning (lesson 06-03), confirm this checklist:

  • [ ] ZAP starts (GUI or daemon) and the proxy listens on 8080 / the API on 8090.
  • [ ] The browser routes through ZAP and no certificate errors appear on HTTPS.
  • [ ] When browsing BazarNube, requests appear in History and the Sites tree grows.
  • [ ] The BazarNube-Staging context exists with correct include/exclude scope.
  • [ ] With Force User authenticated, ZAP accesses the seller panel without asking for a login.

Proxy smoke test with curl:

# Send a request through ZAP's proxy and ignore the system CA
curl -x http://127.0.0.1:8080 -k https://staging.bazarnube.local/ -I
# Should return 200 and the request should appear in ZAP's History

Common Mistakes and Tips

  • Certificate errors on every page: you haven't imported (or trusted) the ZAP Root CA. Re-export it and import it as an authority.
  • The spider logs out your session: you're missing the /logout exclusion in the scope, or you didn't configure the logged-out indicator.
  • ZAP doesn't see the React frontend's traffic: the SPA's fetch/XHR may ignore the system proxy; use ZAP's built-in browser or configure the proxy in the browser itself, not just in the OS.
  • Using real production credentials: never. Create test users exclusive to staging.
  • Port 8080 in use: another app (or the legacy Java Tomcat) is using 8080. Change ZAP's port with -port or under Tools > Options > Network > Local Servers/Proxies.
  • Tip: save the exported context (Context > Export Context) as a versioned file; you'll reuse it in the automation in 06-04.

Exercises

Exercise 1. You're intercepting BazarNube over HTTPS and the browser shows "The connection is not secure" on every page. What is the most likely cause and how do you fix it?

Exercise 2. Write the include and exclude scope patterns for a context that covers https://staging.bazarnube.local, prevents the spider from logging out, and doesn't touch the external gateway pay.tercero.com.

Exercise 3. You want ZAP to test the seller panel, which requires a login. List the four elements you must configure in the context so that ZAP keeps the authenticated session.

Solutions

Solution 1. The browser doesn't trust the ZAP Root CA, which signs on the fly the certificates ZAP presents. Solution: export the root certificate from Tools > Options > Network > Server Certificates, import it as a trusted authority in the browser/system, and reload. Quick alternative: use ZAP's built-in browser, which already has it configured.

Solution 2.

  • Include: https://staging\.bazarnube\.local.*
  • Exclude: https://staging\.bazarnube\.local/logout.*
  • Exclude: .*pay\.tercero\.com.*

The patterns are regular expressions; remember to escape the dots.

Solution 3. (1) Authentication method (form-based with the URL and POST data of /api/auth/login); (2) session indicators (logged-in and logged-out) so ZAP can detect whether it's still authenticated; (3) session management (cookie or header depending on how the JWT travels); (4) at least one test user with its staging credentials.

Conclusion

With ZAP installed, the root certificate trusted, the proxy routing BazarNube's traffic, and a context with well-defined scope and authentication, you have the platform ready for serious work. All this preparation isn't bureaucracy: it's what lets the scanner reach the authenticated areas where the real risk lives, without straying out to attack third parties.

In the next lesson, 06-03 Vulnerability Scanning, we set the machinery in motion: we'll explore BazarNube with the spider and the AJAX Spider, let the passive scanner work, launch the active scanner with an appropriate policy, and learn to interpret the alerts, triage false positives, and generate reports that map the findings to the Top Ten and to BazarNube's backlog.

OWASP Course: Guidelines and Standards for Web Application Security

Module 1: Introduction to OWASP

Module 2: Main OWASP Projects

Module 3: OWASP Top Ten 2021 in Depth

Module 4: OWASP ASVS (Application Security Verification Standard)

Module 5: OWASP SAMM (Software Assurance Maturity Model)

Module 6: OWASP ZAP (Zed Attack Proxy)

Module 7: Best Practices and Recommendations

Module 8: Practical Exercises and Case Studies

Module 9: Assessment and Certification

© Copyright 2026. All rights reserved