SECURITY ENGINEERING · PART 2 · NETWORKING FOR SECURITY · SNIFFING · 34 OF 229

Intercepting Proxies: mitmproxy and Burp Basics

The main tool of web security testing: a proxy you place between your own browser and an application, to read and change requests the user interface would never send. How it decrypts HTTPS with a certificate authority you install yourself, intercept, repeat and replay, mitmproxy and Burp Suite, testing mobile apps, certificate pinning, and why this proves that client-side checks are not security.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. 22
  22. 23
  23. 24
  24. 25
  25. 26
  26. 27
  27. 28
  28. 29
  29. 30
  30. 31
  31. 32
  32. 33
  33. 34
  34. 35
  35. 36
  36. 37
  37. 38
  38. 39
  39. 40
  40. 41
  41. 42
  42. 43
  43. 44
  44. 45
  45. 46
  46. 47
  47. 48
  48. 49
  49. 50
  50. 51
  51. 52
  52. 53
  53. 54
  54. 55
  55. 56
  56. 57
  57. 58
  58. 59
  59. 60
  60. 61
  61. 62
  62. 63
  63. 64
  64. 106
  65. 107
  66. 108
  67. 109
  68. 110
  69. 111
  70. 112
  71. 113
  72. 114
  73. 115
  74. 116
  75. 117
  76. 118
  77. 119
  78. 120
  79. 121
  80. 122
  81. 123
  82. 124
  83. 125
  84. 126
  85. 127
  86. 128
  87. 129
  88. 130
  89. 131
  90. 132
  91. 133
  92. 134
  93. 135
  94. 136
  95. 137
  96. 138
  97. 139
  98. 140
  99. 141
  100. 142
  101. 143
  102. 144
1 / 13

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • A consented man in the middle
  • your own CA decrypts your TLS
  • intercept, repeat, automate
  • never trust the client

Notes

What it does

You configure your browser to send all of its traffic to the proxy, which runs on your own machine. The proxy forwards each request to the application and passes the response back. In between, you see the raw HTTP exactly as it travels: the method, the path, every header, every cookie and the body. Web pages hide all of this behind buttons and forms. The proxy shows you the actual conversation the browser and server are having.

A proxy in the path
  • the browser is told to send all traffic to the proxy (127.0.0.1:8080)
  • the proxy forwards it to the application
  • and passes the response back
  • in between, you see the raw HTTP: method, path, headers, cookies, body

HTTPS

How does it read HTTPS? The proxy creates its own certificate authority, and you install that authority's certificate into your test browser. From then on the proxy presents a certificate for each site, signed by its own authority, and your browser accepts it. There are really two TLS connections: browser to proxy, and proxy to site. It is exactly the man in the middle attack from earlier, except that you set it up, on your own device, by choice.

Reading your own TLS
  • the proxy generates its own certificate authority (CA)
  • you install that CA in your test browser
  • the proxy presents a certificate for each site, signed by its CA
  • two TLS connections: browser to proxy, proxy to site
  • this is a consented man in the middle

A warning

A warning that matters. Whoever holds that certificate authority's private key can impersonate any website to a browser that trusts it. So keep it contained. Use a separate browser profile only for testing, never install a proxy authority on a device you use for banking or personal accounts, and remove it when you finish. The same mechanism is how corporate networks inspect encrypted traffic, which is why that practice needs careful rules too.

Keep the CA contained
  • anyone holding that CA's private key can impersonate any site to that browser
  • use a separate browser profile just for testing
  • never install a proxy CA on a device you bank with remove it when you finish
  • the same idea powers corporate TLS inspection

Intercept and edit

With interception on, each request pauses and waits for you. Now you can change anything before it continues. A hidden form field holding a price. The order number in the address, from your order to someone else's. A cookie. A value the page limited with a dropdown or a maximum length. Even the method. The question you are asking every time is the same: does the server check this, or was the web page the only thing stopping me?

What you can change
  • a hidden form field: price, role, user id
  • the id in the path: /api/orders/1001 to 1002
  • a cookie or header
  • a value the page restricted with a dropdown or a max length
  • the method: GET to DELETE
  • the question: does the server check, or only the page?

The core features

Proxies come with a small toolbox. The history keeps every request so you can search it later. The repeater resends one request with small changes while you compare the responses, which is where most testing happens. An automation tool tries a list of values in one position, such as a range of order numbers. Some include an automated scanner. And the scope setting limits everything to your target, so you never accidentally send test traffic to a third party.

Tools inside the tool
  • history: every request, kept and searchable
  • repeater: resend one request with small changes, compare the responses
  • intruder / fuzzer: try a list of values in one position
  • scanner: automated checks (Burp Pro, ZAP)
  • scope: limit the tool to your target only

Which tool

There are three good tools. Burp Suite is the industry standard; its community edition is free, and the paid version adds an automated scanner. OWASP ZAP is free and open source, with good support for running scans inside a pipeline. And mitmproxy runs in a terminal and can be scripted in Python, which makes it excellent for APIs and mobile apps. Your browser's developer tools are fine for looking at requests, but not for systematic testing.

Burp, ZAP, mitmproxy
  • Burp Suite: the industry standard. Community edition is free; Pro adds a scanner
  • OWASP ZAP: free, open source, good automation for CI
  • mitmproxy: terminal and Python scripting; great for APIs and mobile
  • browser dev tools: fine for looking, not for editing at scale

Mobile and pinning

Mobile apps add a step. You point the phone or emulator at the proxy and install the proxy's certificate authority, but modern Android apps ignore user-installed authorities by default. Many apps go further with certificate pinning: the app accepts only its own expected certificate or key. Pinning is a useful defense against interception on hostile networks. It does not replace server-side checks, because a determined tester with their own device can still remove it.

Mobile apps
  • point the phone or emulator at the proxy; install the proxy CA
  • modern Android apps ignore user-installed CAs by default
  • certificate pinning: the app accepts only its own certificate or key
  • pinning does not replace server-side checks

The lesson

Here is the lesson this tool teaches better than any lecture. Everything the client sends is under the user's control, and therefore the attacker's. JavaScript validation is skipped. Disabled buttons and hidden fields are ignored. The price in the form is edited. The mobile app's logic is bypassed entirely. So the server must check everything again: who you are, whether you may do this, and whether every value is sane. Client-side checks help honest users. They stop no one else.

Never trust the client
  • JavaScript validation: skipped
  • disabled buttons and hidden fields: ignored
  • the price in the form: edited
  • the mobile app's logic: bypassed
  • the server must re-check everything: identity, permission, values, limits
  • the client is a convenience, not a control

For defenders

This is not only an attacker's tool. Developers and security engineers use it daily. To see exactly what an application sends, including to third-party trackers. To reproduce a bug report precisely. To check security headers and cookie flags. To debug an API without a user interface. And, most valuable, to verify a fix: save the request that demonstrated the vulnerability, and replay it after the patch. If it still works, the fix did not.

Everyday uses
  • see exactly what your own app sends, including to third parties
  • reproduce a bug report
  • check security headers and cookie flags
  • verify a fix: replay the attack request
  • debug an API without the UI
  • test a mobile app's backend calls

Common mistakes

Mistakes. Testing applications you do not own or have no permission for. Forgetting to set a scope, so your tools send attack traffic to third-party services the page happens to load. Installing the proxy's certificate authority in your everyday browser. Pointing an active scanner at a production system. Trusting client-side validation as a developer. And the classic: leaving the proxy configured and wondering why every website is broken.

Avoid these
  • testing sites you do not own
  • no scope set: traffic to third parties gets attacked
  • proxy CA on your everyday browser
  • running an active scanner against production
  • trusting client-side checks
  • leaving the proxy on and wondering why sites break

Say it like this

In the interview: client-side validation cannot be trusted because the client is under the user's control. With an intercepting proxy such as Burp, I can pause and edit any request after the page's own checks have run: hidden fields, object identifiers, prices, headers and cookies. So every check that matters has to be enforced on the server: authentication, authorization on each object, and validation of every value. Client-side checks are only for usability.

In the interview
  • "Because the client is under the user's control. With an intercepting proxy I can edit
  • any request after the page's
  • checks: hidden fields, ids, prices, headers. So every check that matters must run
  • on the server: authentication, authorization, validation."

Interview questions

Q1What is an intercepting proxy?

A tool such as Burp Suite, OWASP ZAP or mitmproxy placed between a client and a server that records every HTTP(S) request and response and lets the tester pause, modify, replay and automate them, to see how the server handles input the user interface would never send.

Q2How can an intercepting proxy read HTTPS traffic?

The proxy generates its own certificate authority, which the tester installs as trusted in the test browser or device. The proxy then presents certificates signed by that CA for each site, creating two TLS sessions (client to proxy, proxy to server) and seeing plaintext in between.

Q3Why should the proxy CA be kept to a dedicated test profile?

Any party holding that CA’s private key can impersonate any site to a browser that trusts it. Limiting it to a separate test browser or device, and removing it afterwards, prevents it from undermining TLS for everyday browsing.

Q4Why is client-side validation not a security control?

Requests can be changed after the browser’s checks, or sent without the browser at all. Hidden fields, disabled controls, length limits and JavaScript checks are all bypassed, so the server must independently enforce authentication, authorization and input validation.

Q5What are Burp Repeater and Intruder used for?

Repeater resends a single request with manual changes so responses can be compared, which is the basis of most manual testing. Intruder automates sending many variations of a request, for example iterating identifiers or testing a list of inputs in one position.

Q6What is certificate pinning?

An app accepts only a specific certificate or public key for its server instead of any certificate trusted by the device. It prevents interception by rogue or user-installed CAs on hostile networks, but it does not replace server-side security checks.

Q7Why is setting the scope important in a proxy tool?

Pages load resources from many third-party hosts. Without a scope, automated tools may send test or attack traffic to systems you have no permission to test. Scope restricts recording and active testing to the authorised target.

Q8How do defenders use intercepting proxies?

To inspect exactly what their application sends and to whom, check headers and cookie flags, reproduce reported vulnerabilities, debug APIs, and verify fixes by replaying the original exploit request after a patch.