Exercise B: JWT Triage
When you test an app that authenticates with JWTs, you can’t tell at a glance which requests carry a token. You also can’t tell how each one is signed. Reading the alg claim means copying a token into a decoder every time.
In this exercise you’ll build a two-part triage view. A filter isolates JWT-bearing requests, and a custom column decodes each token and shows its signing algorithm right in the history. Weak configurations like alg: none stand out.
Table of contents
- The goal
- Before you start
- How to detect and read a JWT
- How to approach it
- Check your work
- The complete Bambdas
- Taking it further
The goal
Two Bambdas working together:
- A filter that returns
trueonly for requests carrying a JWT in thesessioncookie. - A custom column that decodes the token’s header segment and displays the
algvalue (HS256,RS256,none, …).
Before you start
Lab to launch
Launch this lab: JWT authentication bypass via unverified signature, from the JWT attacks 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), log in, and browse so your history has some token traffic to work with.
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.
How to detect and read a JWT
A JWT is three Base64url-encoded parts separated by dots: header.payload.signature.
- Because the header (first part) always encodes a JSON object, its Base64url form always begins with
eyJ(the encoding of{"). That gives you a reliable way to detect a JWT anywhere without fully parsing it. - The
algclaim lives in the header, not the payload. It names the signing algorithm. Watch for thenonevalue. - JWTs use the URL-safe Base64 alphabet (
-and_instead of+and/), so you need a URL decoder, not the standard one. Burp’sutilities().base64Utils().decode(data, Base64DecodingOptions.URL)does exactly this. - A token may appear in more than one place. Real APIs typically send it as
Authorization: Bearer eyJ..., but the Web Security Academy JWT labs put it in asessioncookie. Look before you assume. - Burp parses cookies for you. The
Cookieheader holds the fullname=value; name2=value2string, but Montoya also exposes each cookie as a parameter:request.parameterValue("session", HttpParameterType.COOKIE)returns just thesessioncookie’s value, so there’s no header string to split by hand. Guard withrequest.hasParameter("session", HttpParameterType.COOKIE)first. (If you need the cookie’s other attributes,request.parameter(...)returns aParsedHttpParameter.)
Before writing anything, inspect the traffic by hand to confirm where the token is. In Proxy > HTTP history, click a request that follows login and read its headers in the Request panel. Look for the eyJ prefix: is it in an Authorization header, a Cookie header, or somewhere else? Your Bambda should target whatever you find. This lab keeps it in the session cookie, so that’s what your filter has to catch. Getting into the habit of checking first saves you debugging a Bambda that was looking in the wrong place all along.
How to approach it
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 JWT filter
Step 1: Open the filter editor
In Proxy > HTTP history, click the filter bar to open the HTTP history filter window, then go to the Script mode tab.
Step 2: Match the eyJ prefix
You want true for requests carrying a JWT. In this lab the token resides in the session cookie, so read that cookie parameter and test its value for the eyJ prefix. Guard with hasParameter(...) before calling parameterValue(...), so you never read a cookie that isn’t there. You don’t need to split or decode anything yet: startsWith("eyJ") is the Base64url prefix every JWT header begins with.
Tip: On the
&&guard-and-read pattern, see Programming Concepts: Short-circuit evaluation.
Solution
var request = requestResponse.request();
return request.hasParameter("session", HttpParameterType.COOKIE)
&& request.parameterValue("session", HttpParameterType.COOKIE).startsWith("eyJ");
hasParameter("session", HttpParameterType.COOKIE): check the cookie is present before you read it. Java’s&&short-circuits, soparameterValue(...)only runs oncehasParameter(...)istrue.startsWith("eyJ"): the Base64url prefix every JWT header starts with. Because the cookie parameter gives you the value alone (nosession=prefix), the token is right at the start.
Note: If you’re testing a bearer-token API instead, the token arrives in the
Authorizationheader, not a cookie. There you’d readheaderValue("Authorization")andcontains("eyJ"). Inspect the traffic first to see where your target puts it.
Step 3: Apply and observe
Click Apply & close. The table now shows only requests carrying a JWT. Against a Web Security Academy JWT lab, the matches come from the session cookie.
Part 2: The algorithm column
Step 4: Open the custom column editor
In Proxy > HTTP history, click the options menu (the vertical ⋮ icon above the table) and click Add custom column.
Step 5: Decode the header and extract alg
This is the core of the exercise. Work it through in stages. Each stage has a null or malformed case to handle:
- Read the token. In this lab it resides in the
sessioncookie, so read that cookie parameter (guard withhasParameter(...)before reading it). The parameter value is the raw token, nosession=prefix to strip. Confirm it looks like a JWT withstartsWith("eyJ"). - Split it. Split on the literal dot (
"\\."in Java regex) into its parts; the header is the first part. - Decode the header. Base64url-decode the first part with Burp’s
utilities().base64Utils(): that’s wherealglives. - Pull out
alg. Find thealgkey in the decoded JSON and return its value. Wrap the decode and parse in atry/catchso a malformed token returns""instead of throwing.
Try to write it before opening the hints.
Tip: This step combines several core ideas. See Programming Concepts on Working with String, Arrays and indexing, and try/catch.
Hint: how Pattern and Matcher work
Pattern and Matcher work
You’ll reach for regex once here, to read alg out of the decoded header, so it’s worth knowing the shape. For a standalone reference on this API, see Programming Concepts: Regular expressions. Java regex is a two-step API, both classes preimported in Bambdas:
var matcher = Pattern.compile("some(regex)here").matcher(theTextToSearch);
if (matcher.find()) {
String whole = matcher.group(0); // the entire match
String first = matcher.group(1); // the text captured by the 1st (...) group
}
Pattern.compile(...)builds the pattern;.matcher(text)binds it to the string you’re scanning..find()returnstrueif the pattern occurs anywhere in the string, and moves an internal cursor to that match. (.matches()is stricter: it demands the whole string match. You want.find()here.)- Parentheses
(...)in the pattern are a capturing group. After a successful.find(),.group(1)returns what the first group matched..group(0)is the full match. - In Java string literals every regex backslash doubles up: a literal dot is
"\\.", and\s(whitespace) becomes"\\s".
Hint: the pattern to use
You don’t need a full JSON parser for one field. To read the algorithm from the decoded header, match "alg"\s*:\s*"([^"]+)" and take .group(1): the ([^"]+) group captures the value between the quotes.
Remember to double the backslashes in the Java string, so \s is written "\\s". To split the token into its three parts, split on a literal dot, which is "\\." in Java regex.
For the Base64url decode, reach for Burp’s own utilities: utilities().base64Utils().decode(part, Base64DecodingOptions.URL), which returns a ByteArray you can .toString(). Bambdas don’t take import statements: Burp preimports the common Montoya and java.util types, so Pattern and Base64DecodingOptions are already in scope.
Solution
var request = requestResponse.request();
if (!request.hasParameter("session", HttpParameterType.COOKIE)) return "";
var token = request.parameterValue("session", HttpParameterType.COOKIE);
if (!token.startsWith("eyJ")) return "";
var parts = token.split("\\.");
try {
// The alg claim is in the JWT header (first part), not the payload
var decoded = utilities().base64Utils().decode(parts[0], Base64DecodingOptions.URL).toString();
var matcher = Pattern.compile("\"alg\"\\s*:\\s*\"([^\"]+)\"").matcher(decoded);
return matcher.find() ? matcher.group(1) : "";
} catch (Exception e) {
return "";
}
- No imports: Bambdas don’t accept
importlines. Burp preimports the Montoya types and commonjava.utilclasses, soHttpParameterType,Pattern, andBase64DecodingOptionsare already in scope. - Guard then read:
hasParameter(...)beforeparameterValue(...)so you never read an absent cookie. Burp hands you thesessionvalue directly, so there’s noCookieheader string to split and nosession=prefix to strip. - Confirm it’s a JWT:
startsWith("eyJ")filters out any non-tokensessionvalue before you try to decode it. - Decode the header:
utilities().base64Utils()is Burp’s own decoder;Base64DecodingOptions.URLhandles the URL-safe variant JWTs use. It returns aByteArray, so.toString()gives you the JSON. The header is always the first part. - Extract
alg: the regex captures the value; thetry/catchswallows malformed tokens.
Note: For a bearer-token API, the token isn’t a cookie: read
headerValue("Authorization")and pull theeyJ...token out of it instead. Inspect the traffic first, then point the Bambda at wherever the token lives.
Step 6: Apply and name the column
Name it alg and click Apply. Rows with JWTs should now show values like HS256, RS256, or HS384.
If a row stays blank or shows the wrong value, log the intermediate values from inside the Bambda with logging.logToOutput(...) and read them in the Bambda output console to see which decoding step breaks down.
To edit or delete the alg 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.
Step 7: Use them together
With the filter and column both active, the filter isolates JWT traffic and the column shows the algorithm at a glance. Both apply to the Proxy > HTTP history table, so the view updates as new proxied requests arrive. To see it move, send a modified token through the proxy: in the unverified-signature lab, catch a request in Proxy > Intercept, edit the token, and forward it. The signature isn’t checked, so the tampered token is accepted, and the forwarded request lands in history as a fresh row with its alg in your column. Go on to a lab that uses the none algorithm or an algorithm-confusion attack and the same column reports that change too.
Check your work
- The filter shows JWT-bearing rows only and clears cleanly.
- The
algcolumn shows the algorithm for JWT rows and is blank (not an error) for others. - Forwarding a request with a tampered token through Proxy > Intercept adds a history row whose column reports the new
alg.
The complete Bambdas
Both Bambdas in their finished state. Each goes in its own editor: the filter in the filter window’s Script mode tab, the column in Add custom column.
Filter: JWT-bearing requests
var request = requestResponse.request();
return request.hasParameter("session", HttpParameterType.COOKIE)
&& request.parameterValue("session", HttpParameterType.COOKIE).startsWith("eyJ");
Custom column: `alg`
var request = requestResponse.request();
if (!request.hasParameter("session", HttpParameterType.COOKIE)) return "";
var token = request.parameterValue("session", HttpParameterType.COOKIE);
if (!token.startsWith("eyJ")) return "";
var parts = token.split("\\.");
try {
// The alg claim is in the JWT header (first part), not the payload
var decoded = utilities().base64Utils().decode(parts[0], Base64DecodingOptions.URL).toString();
var matcher = Pattern.compile("\"alg\"\\s*:\\s*\"([^\"]+)\"").matcher(decoded);
return matcher.find() ? matcher.group(1) : "";
} catch (Exception e) {
return "";
}
Taking it further
Show the token's key ID (`kid`)
The kid claim is also in the header, alongside alg. Adapt the extraction regex to capture kid instead.
Solution
var matcher = Pattern.compile("\"kid\"\\s*:\\s*\"([^\"]+)\"").matcher(decoded);
Surface the token subject (`sub`)
sub lives in the payload (second part), not the header, so you’ll need to decode parts[1] instead of parts[0] before matching.
Solution
var decoded = utilities().base64Utils().decode(parts[1], Base64DecodingOptions.URL).toString();
var matcher = Pattern.compile("\"sub\"\\s*:\\s*\"([^\"]+)\"").matcher(decoded);
Flag the `none` algorithm with a companion filter
Write a filter that keeps only JWT-bearing requests whose header declares alg as none. Reuse the token-finding logic from the column, then check the decoded header for the none value (allowing for optional whitespace after the colon).
Solution
var request = requestResponse.request();
if (!request.hasParameter("session", HttpParameterType.COOKIE)) return false;
var token = request.parameterValue("session", HttpParameterType.COOKIE);
if (!token.startsWith("eyJ")) return false;
var parts = token.split("\\.");
try {
var decoded = utilities().base64Utils().decode(parts[0], Base64DecodingOptions.URL).toString();
return decoded.contains("\"alg\":\"none\"") || decoded.contains("\"alg\": \"none\"");
} catch (Exception e) {
return false;
}
More filter and column examples live in the community Bambdas repo.