TExcelTAD
Home › Web Application Security: OWASP Top 10, APIs & Authentication › Intercepting Proxies: Burp Suite and ZAP

Intercepting Proxies: Burp Suite and ZAP

The browser hides most of HTTP from its user, and DevTools only lets you look. An intercepting proxy sits between the browser and the application, records every request and response, lets you stop and edit a request before it leaves, replay it with changes, and automate thousands of variations. It is the main tool of web testing. The two most used are Burp Suite (PortSwigger; a free Community Edition and a commercial Professional edition with a scanner) and ZAP (Zed Attack Proxy, open source, originally an OWASP project). This lesson shows their core workflow as labelled lab sessions against the lab's OWASP Juice Shop instance, and reproduces the heart of it, edit and replay a raw request, in your sandbox. You built a small logging proxy yourself in Programming for Security; these are that idea with a thousand features.

Scope for the lab sessions below: an authorised home lab. OWASP Juice Shop runs at juice.lab.test (10.10.0.20) on the isolated lab network 10.10.0.0/24; the tester's machine is 10.10.0.5. The proxy's CA certificate is installed only in a dedicated lab browser profile.

The workflow

  1. Set up: the proxy listens on 127.0.0.1:8080; a browser profile (Burp's and ZAP's built-in Chromium, or Firefox with a proxy setting) sends traffic through it; the proxy's own CA certificate is trusted in that profile only, so the proxy can decrypt HTTPS for inspection.
  2. Define the scope in the tool (Burp: Target → Scope; ZAP: Contexts). Out-of-scope hosts are not logged, not scanned and not attacked; this is how tools enforce the rules of engagement.
  3. Map: browse the whole application as each test user; the site map / history fills with every request.
  4. Inspect and replay: send interesting requests to Repeater (Burp) / Requester (ZAP), change one thing at a time, compare.
  5. Automate: Intruder (Burp) / Fuzzer (ZAP) for payload lists; extensions such as Autorize (replay as another user), JWT Editor, Param Miner; the active scanner (Burp Pro, ZAP) for known vulnerability classes.
  6. Record evidence: save requests and responses for the report.

Lab session: Repeater on an object id

console
lab-session (Burp Suite Community, Repeater tab, target https://juice.lab.test, in scope)

Request (as test user tester1@lab.test, whose basket id is 6):
GET /rest/basket/6 HTTP/2
Host: juice.lab.test
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.<lab token for tester1>
Accept: application/json

Response:
HTTP/2 200 OK
Content-Type: application/json; charset=utf-8

{"status":"success","data":{"id":6,"UserId":21,"Products":[{"name":"Apple Juice (1000ml)", ...}]}}

Request edited in Repeater: only the id changed, same token:
GET /rest/basket/2 HTTP/2
...
Response:
HTTP/2 200 OK
{"status":"success","data":{"id":2,"UserId":2,"Products":[...]}}

Changing one number in Repeater and getting another user's basket is the IDOR test of IDOR and BOLA; Juice Shop contains this flaw deliberately as one of its challenges. In a report, the two request/response pairs are the evidence.

Lab session: ZAP baseline scan

ZAP's baseline scan spiders the target for a minute and reports passive findings (it doesn't attack), which makes it safe to run in CI against your own staging site:

console
lab-session$ docker run --rm --network lab-net -t ghcr.io/zaproxy/zaproxy:stable \
    zap-baseline.py -t https://juice.lab.test -I
Total of 97 URLs
PASS: Cookie No HttpOnly Flag [10010]
PASS: Cookie Without Secure Flag [10011]
PASS: Anti-clickjacking Header [10020]
...
WARN-NEW: Content Security Policy (CSP) Header Not Set [10038] x 11
WARN-NEW: Strict-Transport-Security Header Not Set [10035] x 9
WARN-NEW: Cross-Domain Misconfiguration [10098] x 12
WARN-NEW: Timestamp Disclosure - Unix [10096] x 3
FAIL-NEW: 0	FAIL-INPROG: 0	WARN-NEW: 4	WARN-INPROG: 0	INFO: 0	IGNORE: 0	PASS: 52

Each line names a passive rule and its id; a rules file can promote rules to FAIL so a pipeline breaks on them. The findings match the security headers and CORS lessons. A baseline scan is a hygiene check, not a penetration test: it found no access-control or injection problem because it never tried any.

The same idea in your sandbox: edit and replay a raw request

Repeater's core is simple: keep a request as text, change a line, send the bytes again. The session saves a raw request the way Burp's "Copy to file" does, sends it to a toy API on 127.0.0.1 with ncat, edits one header with sed, and sends it again.

bash · try it yourself
cat > api.py <<'PY'
from wsgiref.simple_server import make_server, WSGIRequestHandler
class Quiet(WSGIRequestHandler):
    def log_message(self, *args):
        pass
def app(environ, start_response):
    role = environ.get("HTTP_X_ROLE", "customer")          # BUG: trusts a client header for authorization
    body = "admin report: 3 refunds pending\n" if role == "admin" else f"hello {role}, nothing to see\n"
    start_response("200 OK", [("Content-Type", "text/plain"), ("Content-Length", str(len(body)))])
    return [body.encode()]
make_server("127.0.0.1", 8000, app, handler_class=Quiet).serve_forever()
PY
python3 api.py &
for i in $(seq 50); do curl -s -o /dev/null http://127.0.0.1:8000/ && break; sleep 0.1; done
printf 'GET /reports HTTP/1.0\r\nHost: 127.0.0.1\r\nX-Role: customer\r\n\r\n' > req.txt
echo "== original request"; tr -d '\r' < req.txt
echo "== response";         ncat 127.0.0.1 8000 < req.txt | tr -d '\r' | sed -n '1p;$p'
sed -i 's/X-Role: customer/X-Role: admin/' req.txt
echo "== edited request";   tr -d '\r' < req.txt | grep X-Role
echo "== response";         ncat 127.0.0.1 8000 < req.txt | tr -d '\r' | sed -n '1p;$p'
kill %1
== original request
GET /reports HTTP/1.0
Host: 127.0.0.1
X-Role: customer

== response
HTTP/1.0 200 OK
hello customer, nothing to see
== edited request
X-Role: admin
== response
HTTP/1.0 200 OK
admin report: 3 refunds pending

One edited header turned a customer into an administrator, because the toy API took its authorization decision from a value the client controls (the first fact of the trust model). The fix is server-side: derive the role from the authenticated session, never from a request header.

How defenders notice proxy-driven testing

Proxy traffic looks like browser traffic, but testing leaves patterns: requests in rapid sequence that differ in one parameter, values no UI produces (edited ids, roles, negative numbers), scanner signatures (ZAP and Burp's active scanners send recognisable payloads and sometimes headers), and bursts of 4xx/5xx from one session. In your own staging environment, that is a useful test of your monitoring: run a baseline scan and check that your alerts fire.

Pitfalls

  • Installing the proxy CA in your everyday browser or system store: anyone with that CA key can impersonate every site to you. Use a separate profile and remove it after the engagement.
  • Running active scans against production or out-of-scope hosts: active scanners submit forms, send thousands of requests and can delete data. Scope first; agree on timing; test on staging when possible.
  • Treating scanner output as the report: triage every finding, remove false positives, and add the manual findings scanners can't produce.

Practice

1. Why does the proxy need its own CA certificate trusted by the lab browser?

To read HTTPS, the proxy terminates TLS itself and presents a certificate for each site, signed by its own CA. The browser only accepts those certificates if it trusts that CA, which you allow in the lab profile and nowhere else.

2. A ZAP baseline scan of your app passes with no warnings. What can you conclude?

Only that passive checks (headers, cookies, information leaks on the pages the spider found) didn't flag anything. Authorization, injection, business logic and anything behind login weren't tested.

Test yourself

What does Burp Repeater (ZAP Requester) let you do?

  1. Scan the Internet
  2. Edit a captured request and resend it, comparing responses
  3. Crack passwords
  4. Generate certificates

Why define a scope in the proxy tool?

  1. Speed
  2. So out-of-scope hosts are not logged, scanned or attacked: the tool enforces the rules of engagement
  3. It is required for HTTPS
  4. To hide traffic

What does ZAP's baseline scan do?

  1. Exploits SQL injection
  2. Spiders the site and reports passive findings without attacking
  3. Brute-forces logins
  4. Tests access control

In the sandbox session, what was the vulnerability?

  1. SQL injection
  2. The API took the role from a client-controlled header
  3. Missing TLS
  4. CORS