Exercise A: Proxy History Intelligence
Burp’s proxy history has default columns for the obvious things: method, URL, status, MIME type, length. The interesting metadata is the stuff it doesn’t give you a column for, sitting inside response headers you’d otherwise open each response to read. When you’re probing a cache, the header that matters is X-Cache: it tells you whether a response was served from the cache (hit) or came fresh from the origin (miss), and there’s no built-in column for it.
In this exercise you’ll pull that header out into its own column, so it’s visible at a glance across your whole history. Then you’ll add a filter that keeps only the rows matching a value you’re looking for.
Table of contents
- The goal
- Before you start
- How to approach it
- Check your work
- The complete Bambdas
- Taking it further
The goal
By the end you’ll have two Bambdas working together:
- A custom column that shows the
X-Cachevalue (hitormiss) on every row. - A filter that hides every row except the cache hits (where
X-Cachecontainshit).
With both active at once, your history becomes a focused view: only the responses being served from the cache, with the cache status already on screen. When you’re hunting cache poisoning, “which of these is cached?” is exactly the question you’re asking.
Before you start
Lab to launch
Launch this lab: Web cache poisoning with an unkeyed header, from the Web cache poisoning category on Web Security Academy.
Open it in Burp’s browser (click the browser icon in the top-right of Burp, then paste the lab’s URL) and browse it so its traffic fills your proxy history before you add the column. You don’t need to solve the lab; you just need its traffic. Every response carries an
X-Cacheheader, so you’ll have plenty of column values to observe.
Once traffic is flowing:
- Reload the home page once or twice. The first request for a URL is a
miss(fresh from the origin); a reload within the cache’s lifetime comes back as ahit. Getting both values into your history is what makes the column interesting to look at. - Keep the Bambda output console in mind for debugging: anything you log with
logging.logToOutput(...)appears there.
Note: It doesn’t matter where you’re logged into Web Security Academy. Browse the lab from Burp’s browser and the traffic reaches your history regardless.
New to this? What you'll have open, and why
Everything here happens inside Burp, across a few places:
- Proxy > HTTP history: the table you’re adding a column and a filter to.
- The custom column editor and the filter window: both hold a Bambda, a short piece of Java Burp runs for you. You open each from the history table (the steps below show where).
- The Bambda output console: where anything you log with
logging.logToOutput(...)appears. Keep it in mind when a Bambda isn’t doing what you expect. - Burp’s browser (the icon in the top-right of Burp): how you browse the lab so its traffic fills your history.
There’s no build step and no restart: you edit the Bambda, click Apply, and see the result immediately.
How to approach it
Never coded before? The Java you need, in one place
A Bambda is a short piece of Java. You don’t write a whole program: Burp hands you an object to work with, you write a few lines, and you give back an answer with return. Here is the whole vocabulary those lines use, and it’s all you need for this exercise.
- Statement and comment. Each instruction is a statement and ends with a semicolon (
;). Anything after//is a comment: a note for you that Burp ignores. - Value and type. A value is a piece of data. Its type says what kind it is: a
Stringis text ("X-Cache"), abooleanistrueorfalse, anintis a whole number. - Variable. A named box that holds a value.
var response = requestResponse.response();puts the response into a box calledresponse.varjust means “Java, work out the type for me.” - Object and method. An object is a thing you can act on, such as the response. A method is an action you ask it to perform, written with a dot and parentheses:
response.headerValue("X-Cache")asks the response for that header’s value. Some methods take an input inside the parentheses; some take none. - Chaining. A method often hands back another object, so you can keep going with another dot:
requestResponse.response().headerValue("X-Cache")reads left to right. return. Your Bambda’s job is to produce one answer and hand it back withreturn. What the answer means depends on the Bambda type: a filter returnstrueto keep a row orfalseto hide it; a column returns the text to show, or""for a blank cell.null. Sometimes there is no object at all (no response has arrived yet, say). Java calls thatnull, and askingnullfor anything crashes the Bambda, which is why you check first. The guard reveal in Step 2 walks through this.
You’ll meet each of these in action as you go. If a line ever looks like a wall, come back here.
Tip: Staring at a blank editor? If you have Burp AI credits, the AI Bambda Generator BApp drafts a Bambda from a plain-English description. Refine its output from there. You can also try using Burp AT, Burp’s agentic AI.
Read and understand what either tool produces first. The aim is to learn the approach, not only to run it.
Part 1: The custom column
Step 1: Open the custom column editor
In Proxy > HTTP history, click the options menu (the vertical ⋮ icon above the table) and click Add custom column. A code editor opens. This is where your Bambda runs, once per row, with a requestResponse variable already in scope.
Step 2: Get the response, safely
A column Bambda returns an Object. Here we’ll return a String directly. Your first job is to reach into requestResponse, get the response, and pull out a header value.
Two things need guarding before you return:
- There might be no response: a request might not have received one yet (timed out, still intercepted). When there’s none,
requestResponse.response()isnull, and reading a header offnullthrows aNullPointerException. Check a response exists first. - The header might not be present on the response. Every cached response here carries
X-Cache, but that won’t stay true once you swap in other headers in Step 4, so guard for it now. Check the header exists before reading its value, and return an empty string when it’s absent so the cell renders blank.
Think about how you’d guard both cases before returning.
Tip: New to null-safety in Java? See Programming Concepts: Guard before you read.
New to null-safety? Walk me through the guards
requestResponse.response() hands back the response object, but sometimes there isn’t one: a request might still be waiting or have timed out. In that case it returns null, which means “no object here.” Calling a method like hasHeader(...) on null throws a NullPointerException, and your Bambda stops with an error.
So you check before you read:
requestResponse.hasResponse()istrueonly when a response exists.response.hasHeader("X-Cache")istrueonly when that header is present.
The pattern is: test with the guard, and if it fails, return the “no match” value straight away (here "", which renders a blank cell). Only once both guards pass do you reach response.headerValue("X-Cache"), where there’s no null left to worry about. That’s exactly the three-line shape in the hint below.
Hint: the shape of it
Guard with requestResponse.hasResponse() and return "" if there’s no response. Then get requestResponse.response(), check response.hasHeader("X-Cache"), and return "" if the header is absent. Otherwise return response.headerValue("X-Cache").
Solution
if (!requestResponse.hasResponse()) return "";
var response = requestResponse.response();
if (!response.hasHeader("X-Cache")) return "";
return response.headerValue("X-Cache");
requestResponse.hasResponse(): guards against a request that has no response yet.response.hasHeader("X-Cache"): true only when the response carries anX-Cacheheader; return""otherwise so the cell renders blank.response.headerValue("X-Cache"): safe to read once you know the header is present, so there’s nonullto handle.
Step 3: Apply, name it, and observe
Give the column a name (for example, Cache) and click Apply. The new column appears in your history. Scroll your traffic: you should see miss on the first request for each URL and hit on any you reloaded. If you only ever see miss, reload a page or two and watch the reload come back as hit.
If every row is blank, then the header name may be wrong. Click a row and open Response > Headers to see exactly what the response contains, then copy the name into your Bambda.
To find where your Bambda goes wrong, log values from inside it with logging.logToOutput(...) and read them in the Bambda output console.
Step 4: Iterate on the header
Swap "X-Cache" for "Age" and click Apply again: the cache reports how many seconds each response has been stored, so you’ll see the number climb on hits. Now try "Set-Cookie". Only the fresh responses that start a session show a value; the cache hits render blank, because a cached response is replayed as-is and never sets a new cookie. That blank cell is exactly the header-absent case your second guard handles. Notice there’s no compile step and no restart: this fast feedback loop is the point of Bambdas.
To edit or delete the Cache column later:
- Open the options menu (the vertical ⋮ icon).
- Click Table layout.
- Click Edit column or Delete column for it.
Note: Table layout also shows and hides columns; drag the column headers to reorder them.
Part 2: The companion filter
Step 5: Open the filter editor
In the filter bar at the top of the history table, click to open the HTTP history filter window, then go to the Script mode tab.
Step 6: Return true only for the rows you want
A filter Bambda returns a boolean: true keeps the row visible, false hides it. You want true only for rows whose X-Cache header says hit, so the cache misses drop away and you’re left looking only at responses the cache is serving.
The same two presence checks from the column apply here, but this time you return false when there’s nothing to match.
Hint: case sensitivity
Header values aren’t normalized for you. Lower-case the value before you call contains("hit") so a Hit or HIT from some other cache still matches.
Solution
if (!requestResponse.hasResponse()) return false;
var response = requestResponse.response();
if (!response.hasHeader("X-Cache")) return false;
return response.headerValue("X-Cache").toLowerCase().contains("hit");
Swap "hit" for "miss" to flip the view and see only the responses that reached the origin.
Step 7: Apply and test
Click Apply & close. The table now shows only the cache hits; the misses disappear. Clear the filter (reopen the window and go back to Settings mode) and reapply to confirm the difference.
Step 8: Combine the two
With the custom column and the filter both active, you have a view that shows only the rows you care about, with the relevant header already visible. No more opening each response one at a time.
Check your work
- The column shows a value on rows that carry the header, and is blank (not an error) on rows that don’t.
- The filter hides non-matching rows and restores them when you clear it.
- Switching the header name or match string and re-applying takes effect immediately.
The complete Bambdas
Both Bambdas in their finished state. Each goes in its own editor: the column in Add custom column, the filter in the filter window’s Script mode tab.
Custom column: `X-Cache`
if (!requestResponse.hasResponse()) return "";
var response = requestResponse.response();
if (!response.hasHeader("X-Cache")) return "";
return response.headerValue("X-Cache");
Filter: rows served from the cache
if (!requestResponse.hasResponse()) return false;
var response = requestResponse.response();
if (!response.hasHeader("X-Cache")) return false;
return response.headerValue("X-Cache").toLowerCase().contains("hit");
Taking it further
Target a custom application header. If the app adds its own header (a request ID, a session token type, a feature flag), extract it into a column and filter on its values.
Write each Bambda as a single expression
Once the guards are second nature, you can collapse either Bambda onto one line. Because hasResponse() and hasHeader(...) both return booleans, && chains them and short-circuits: the moment one is false, evaluation stops and nothing to its right runs, so headerValue(...) is only ever reached once you know the header is there. The filter needs no ternary, since the whole expression is already a boolean.
Try collapsing both the column and the filter yourself before you reveal the code.
Tip: For the language mechanics here, see Programming Concepts: Short-circuit evaluation and The ternary.
New to && chains and the ternary? Walk me through it
&& means “and”: the whole expression is true only when every part is true. Java evaluates it left to right and short-circuits, meaning it stops the moment a part is false and never runs anything to its right. So a guard on the left protects a read on the right: in hasResponse() && response().hasHeader(...) && response().headerValue(...), the headerValue(...) call is only ever reached once both guards have passed. That’s why the collapsed filter needs no separate if statements.
A ternary is an if/else that produces a value: condition ? valueIfTrue : valueIfFalse. A column has to return a value, so the ternary lets you pick one in a single expression: if the guards pass, use the header value; otherwise use "".
One more thing that makes the multi-line version read cleanly: Java ends a statement at its semicolon (;), not at the end of a line. So a single return can spread over several indented lines without changing what it does.
Solution
Column, as a ternary:
return requestResponse.hasResponse() && requestResponse.response().hasHeader("X-Cache")
? requestResponse.response().headerValue("X-Cache") : "";
Filter, as a plain && chain:
return requestResponse.hasResponse()
&& requestResponse.response().hasHeader("X-Cache")
&& requestResponse.response().headerValue("X-Cache").toLowerCase().contains("hit");
Note: The tradeoff is that
requestResponse.response()is evaluated more than once. It’s cheap here, but reading the response into a variable once avoids the repeat. Pick whichever reads more clearly to you.
Filter by request path
You can filter on any property of the request, not just response headers. See if you can write a filter that shows only requests to /api/ endpoints, using the request’s path().
Solution
return requestResponse.request().path().startsWith("/api/");
Combine conditions
Use && and || to combine checks in a single expression. Try writing a filter that shows only non-200 responses from the API or admin area: match either path, then require a non-200 status. Watch the operator precedence when you mix && and ||.
Solution
return requestResponse.hasResponse()
&& (requestResponse.request().path().startsWith("/api/")
|| requestResponse.request().path().startsWith("/admin/"))
&& requestResponse.response().statusCode() != 200;
The parentheses matter: && binds tighter than ||, so without them the two path checks wouldn’t group together and the logic would change. The response guard leads so statusCode() is only reached once a response exists.
More filter and column examples live in the community Bambdas repo.