A Burp Suite extension that detects session/cookie expiry during active scanning and pauses all scanner traffic until you update your credentials.
When cookies expire mid-scan, the target server returns HTTP redirects or error status codes (e.g., 303, 401, 403). If you have a resource pool running concurrent requests (e.g., 10 concurrent requests), all in-flight requests will fail, and the scanner will continue queueing and firing hundreds of requests with stale tokens. This pollutes your scan logs and fails all test cases, forcing you to restart the entire scan from scratch.
Session Guard monitors HTTP traffic from your selected Burp Suite tools. When it detects any of your configured trigger status codes:
- Blocks Future Traffic Instantly: Future requests are intercepted and held in a thread-safe gate (using
CountDownLatchto sleep threads efficiently with zero CPU spin). - Alerts You Immediately: Triggers a popup alert dialog, plays an audible system beep, and writes a warning to the Burp Suite Alerts tab.
- Resumes Seamlessly: Once you update your cookies/tokens in Burp's Cookie Jar or session headers, click Resume Scanning to release all queued requests.
- Project Persistence: All your configured settings and detection logs are automatically saved and loaded directly from your Burp Suite project file.
| Feature | Mode 1: Plug-and-play (Default) | Mode 2: Strict Mode |
|---|---|---|
| Setup Required | None (Just install and scan) | Session Handling Rule in Burp |
| Test Case Retention | Loses a few in-flight test cases | ~100% test cases retained |
| Retry Logic | Fails in-flight requests | Automatically re-issues held requests |
| Grace Period | ✅ Needed (drains stale pipeline) | ❌ Not needed (requests blocked before sending) |
| Ideal For | Quick scans, easy setup | Deep, comprehensive audits |
Setup: None — just install the extension and scan.
How it works:
Scanner Request → goes to server → Response comes back
↓
┌─ HTTP HANDLER ──────────────┐
│ Response matches trigger? │
│ ↓ YES │
│ Validation probe (if set) │
│ ↓ Confirmed expired │
│ PAUSE gate + notify user │
└──────────────────────────────┘
↓
All future requests BLOCKED
until user clicks ▶ Resume
Steps:
- Configure your scan target and start an active scan.
- Session Guard runs silently in the background.
- Cookie expires → Extension triggers based on your configured status codes or regex patterns:
- Scanner freezes (future requests held in queue).
- Popup alert appears, system beep plays, and Burp Alerts tab shows critical notification.
- You update cookies, tokens, and headers as needed.
- Switch to the Session Guard tab and click ▶ Resume.
- All held requests resume with the updated credentials. (Note: Requests that were already in-flight before the pause will return your configured trigger codes and be ignored via the Grace Period).
Strict Mode uses Burp's native Session Handling Rules to block requests before they are sent. This means almost zero leaked requests with invalid cookies.
How it works:
Scanner Request arrives at Session Handling Rule
↓
┌─ SESSION GUARD ACTION (pre-request) ────────────┐
│ • Gate already paused? → BLOCK immediately │
│ • Cooldown active? → pass through (0 overhead) │
│ • Cooldown expired? → probe validation URL │
│ • Session valid → reset cooldown, pass through │
│ • Session expired → PAUSE gate, notify, BLOCK │
└──────────────────────────────────────────────────┘
↓ (request goes to server)
Response comes back
↓
┌─ HTTP HANDLER (post-response, backup) ───────────┐
│ • Response matches trigger (e.g. 303)? │
│ • Validation probe → false positive? → ignore │
│ • Real expiry → PAUSE gate immediately │
└──────────────────────────────────────────────────┘
↓
All subsequent requests BLOCKED at the Action gate
until user clicks ▶ Resume
Both the Action (pre-request check every ~30s) and the HttpHandler (post-response check) work together to catch session expiry as fast as possible.
Just one rule action. No macros needed.
Step 1: Create Session Handling Rule
- Go to Settings → Sessions → Session Handling Rules.
- Click Add to create a new rule.
- Give it a description (e.g.,
Session Guard).
Step 2: Add Rule Action
- Under Rule Actions, click Add → Invoke a Burp extension.
- Select Session Guard — Pause & Retry from the dropdown.
- Click OK.
Step 3: Configure Scope
- Switch to the Scope tab at the top of the rule editor.
- Under Tools Scope, select the tools you want to protect (e.g., Scanner, Intruder, Repeater).
- Under URL Scope, select Use suite scope or define your target URLs explicitly.
- Click OK to save.
Step 4: Configure the Extension
- Go to the Session Guard tab in Burp.
- Set Trigger Status Codes (e.g.,
303, 401). - Set Validation URL (e.g.,
https://target.com/dashboard). - Change Operating Mode to Mode 2: Strict Mode.
That's it! The extension will automatically probe the validation URL every ~30 seconds and pause instantly when the session expires.
For absolute zero leaked requests, use Burp's "Check session is valid" macro approach. This adds one extra HTTP request before every scanner request but guarantees no request ever goes out with an expired cookie.
Step 1: Record a Macro
- Go to Settings → Sessions → Macros section.
- Click Add.
- Burp will open a recorder. Navigate to your validation URL (e.g.,
https://target.com/dashboard) so it captures the request. - Select that single request and click OK.
- Give it a name (e.g.,
Session Guard Validation) → OK.
Step 2: Create Session Handling Rule
- In Settings → Sessions → Session Handling Rules, click Add.
- Description:
Session Guard Strict Mode.
Step 3: Add "Check session is valid" Action
-
Under Rule Actions, click Add → Check session is valid.
-
Configure it:
-
Make request(s) to validate session:
- Select Run macro → choose the macro you recorded in Step 1.
-
Inspect response to determine session validity:
- Under HTTP headers, check for your trigger (e.g., status code
303, or aLocation:header containing a login redirect). - Or under Response body, enter a regex that matches your login/error page.
- Under HTTP headers, check for your trigger (e.g., status code
-
Define behavior dependent on session validity:
- Under If session is invalid, perform the action below:
- Select Invoke a Burp extension handler → Session Guard — Pause & Retry.
-
-
Click OK.
Step 4: Configure Scope
- Switch to the Scope tab.
- Tools: Select Scanner, Intruder, Repeater (whichever you need).
- URL Scope: Select Use suite scope or define explicitly.
- Click OK.
Step 5: Configure the Extension
- Go to the Session Guard tab.
- Set Trigger Status Codes and Validation URL.
- Change Operating Mode to Mode 2: Strict Mode.
With this setup, Burp checks the session BEFORE every request via the macro. If invalid, our extension is invoked, pauses the gate, and blocks all threads. Zero requests leak through.
You can specify multiple HTTP response status codes that will trigger a session pause.
- How to use it: Enter the codes into the Trigger Status Codes field in the Session Guard tab, separated by commas, spaces, or semicolons (e.g.,
303,404,403or303 401 403). - Under the Hood: The input is parsed dynamically using the regular expression
[,;\s]+. Invalid entries or letters are safely ignored, defaulting back to303if parsing fails.
In addition to status codes, you can detect session expiry by matching custom patterns in the HTTP response.
- Header Match Regex: Provide a regex pattern (e.g.,
Location:.*login\.php) to match against response headers. - Body Match Regex: Provide a regex pattern (e.g.,
Your session has expired) to match against the response body. - If either regex pattern matches, Session Guard will trigger immediately. All regex matches are evaluated case-insensitively.
Note: Grace Period is only applicable in Mode 1 (Plug-and-play). In Strict Mode (Mode 2), requests are blocked before they are sent, so there is no stale pipeline to drain.
If you have a resource pool of
- To prevent Session Guard from instantly pausing again due to these stale responses, set the Grace Period (requests) to match your resource pool size (e.g.,
10). - Upon clicking Resume, the extension will ignore the next
$N$ trigger responses.
- Popup Dialog: Toggles an on-screen modal window to notify you immediately when a session expires, even if Burp is minimized.
- Sound Alert: Emits a system beep when a pause is triggered.
- Burp Event Log: Logs session pause and resume events to the Burp Suite system alert logs.
Some Burp Scanner checks — notably Web Cache Deception (WCD) — intentionally strip the Cookie header from requests. The server responds with a redirect (e.g., 303) because there is no session. Without protection, Session Guard would interpret this as a real session expiry and pause the scanner.
The Validation Probe prevents this by double-checking before pausing:
- Set the Validation URL to any authenticated endpoint on your target (e.g.,
https://target.com/dashboard). - When a trigger response is detected, Session Guard sends a quick probe request to the Validation URL with your real cookies from the Cookie Jar.
- If the probe returns a normal (non-trigger) response → the session is still alive → the original trigger was a false positive (e.g., WCD) → it is silently ignored and scanning continues.
- If the probe also triggers (e.g., also returns
303) → the session is truly expired → scanning is paused as usual.
Tip: The Validation URL should be a lightweight, fast-loading authenticated page. Pick something that responds quickly.
This feature works in both Mode 1 (Plug-and-play) and Mode 2 (Strict Mode).
- Java 17 up to Java 25 (LTS)
- Gradle wrapper (included)
Run the shadow JAR build task to bundle dependencies:
# Windows
.\gradlew.bat shadowJar
# Linux/macOS
./gradlew shadowJarThe output JAR is compiled at: build/libs/session-guard-1.0.0.jar.
- Open Burp Suite Professional.
- Navigate to Extensions → Installed → Add.
- Set Extension type to Java.
- Choose the compiled JAR:
build/libs/session-guard-1.0.0.jar. - Click Next to load the extension. You should see "Session Guard v1.0.0 loaded successfully".
| Control | Description | Default Value |
|---|---|---|
| Status Indicator | Displays ACTIVE — Scanning normally 🟢 or PAUSED — Session Expired! 🔴 |
ACTIVE |
| Requests Blocked / Grace | Shows the count of blocked requests when paused, or remaining grace tokens | 0 |
| Trigger Status Codes ⚹ | Input field for your target codes (e.g., 303, 401, 403) |
303 |
| Header Match Regex | Optional regex pattern to match against response headers (e.g., Location:.*login\.php) |
(empty) |
| Body Match Regex | Optional regex pattern to match against response body (e.g., Your session has expired) |
(empty) |
| Validation URL ⚹ | URL to probe before pausing. Prevents false positives from WCD and similar scanner checks. | (empty) |
| Grace Period (requests) | Number of trigger responses to ignore upon clicking Resume (Mode 1 only) | 10 |
| Show popup notification | Enable modal popups on trigger | Checked |
| Play sound alert | Play an audible system beep on trigger | Checked |
| Operating Mode | Mode 1 (Plug-and-play) or Mode 2 (Strict Mode) | Mode 1 |
| Resume Scanning Button | Resumes traffic, applying the configured Grace Period | Enabled when paused |
| Pause Manually Button | Manually pause scanning/traffic at any time | Enabled when active |
| Clear Log | Clears the detection log window | — |
⚹ = Required fields for proper extension operation
SessionGuardExtension: The entry point implementingBurpExtensionto register HTTP handlers, session handling action, and the UI tab.GateController: Thread-safe manager using aCountDownLatchstate gate. Intercepted threads callawait()to block without spinning the CPU, waking up synchronously uponresume(). Also holds a sharedisProbingflag (with CAS-basedstartProbing()) used by the Validation Probe feature to prevent recursive trigger detection and ensure only one thread probes at a time.SessionGuardHttpHandler: Implements Montoya'sHttpHandler. It inspects responses for trigger codes, runs a validation probe when configured, and blocks requests on the gate when active. Works in both modes as a response-based detection layer.SessionGuardAction: Implements Montoya'sSessionHandlingActionfor Strict Mode. Invoked by Burp's Session Handling Rules, it uses a smart cooldown-based validation probe (~1 probe every 30 seconds) and blocks threads until resume. Provides the pre-request blocking layer for Mode 2.SessionGuardTab: A custom GUI panel built using Swing to provide live control, configuration, and detection logs. All settings are persisted to the Burp project file.