> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/web/race-conditions/race-conditions-that-bypass-limits.md).

# Race Conditions that Bypass Limits

Race Conditions that Bypass Limits notes for PortSwigger Web Security Academy labs, including exploitation workflow, payload testing, Burp Suite validation, and remediation context.

### Limit Overrun Race Conditions

The purchase stream contains a **race condition** that allows you to obtain a **unexpected price** at the time of payment.

#### Objective

Buy successfully the **Lightweight L33t Leather Jacket**.

#### Data / Prerequisites

* Credentials: `wiener:peter`
* Discount code (20%): `PROMO20`
* Credit available: **$50**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0ece9370cb2bdf79fababb3fc8b1d2f0722dd6d2%2F%7B944C81AC-4354-4BC2-8DE1-F965C756CC1A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Cost of jacket: **$1300**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1ecb32fb317fcf10e235a2128b20fb9da81c1978%2F%7BE59C4756-54D8-443B-A799-75A464062A67%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Behavior observation

1. Add the jacket to the basket.
2. Apply the `PROMO20` coupon.
3. If you try to apply the coupon for a second time, the application answers: **Coupon already applied**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-46405c4b9854c6996abcf9adb4bdf076da7f1597%2F%7BF3777B3E-48EE-4557-B9BC-429A5151C008%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

The coupon application query looks like this (form URL-encoded):

```bash
csrf=7QYFGBaACc8P5YOfUHR4S85oo95uA0Vb&coupon=PROMO20
```

### Manual Exploitation (Burp Repeater)

1. Send the application request to **Repeater**.
2. Create a **group** in Repeater.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c5f75c5fc6d82386e6bbbf1eb44f3843b38d9a0e%2F%7B7930725F-7452-4FEB-9AE5-5A3B6689234F%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* Duplicate the request tab /\~20 times (**Duplicate tab**).

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8922ebbefcbb65751bccbd3b31cae3edc7946042%2F%7B584C98C5-87B5-4093-BA1A-FDFF28468AC2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8844568de87af86ef85247fe800333c30c28ca03%2F%7B5D6306B5-1BEB-4008-BB05-D50E1309FFB1%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Send requests **in parallel**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-73f329e096684bf1d66b78855deaaeb158b89d87%2F%7BE6CDA436-5E4B-491A-ACA0-74973BB14353%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

The result is that most requests are **validated**, and the total becomes **/\~37**, which allows you to purchase despite the original price ($1300) and the limited credit.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-bec1d11878b2c95d4318eec35e1b4c591ae6461f%2F%7BBF3732E3-06D8-4A81-B5B6-2190386B9AC9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Automated Exploitation (Burp Suite Pro Custom Action)

The lab recommends using **Trigger race conditions** (Burp Suite Professional) via a **Custom action**.

#### 1) Add Script (Bambda Library)

Go to **Extensions → Bambda library** and add:

* **id**: `eb57d5bd-33e2-4a8c-bf51-bc81bd26613a`
* **name**: `Probe for race condition`
* **function**: `CUSTOM_ACTION`
* **location**: `REPEATER`

```javascript
id: eb57d5bd-33e2-4a8c-bf51-bc81bd26613a
name: Probe for race condition
function: CUSTOM_ACTION
location: REPEATER
source: |+
  /**
  * Repeats the request 10 times to trigger race conditions or request smuggling, using the single-packet attack for HTTP/2, and last-byte synchronisation for HTTP/1
  *
  * @author James Kettle
  **/
  int NUMBER_OF_REQUESTS = 10;
  var reqs = new ArrayList<HttpRequest>();
  for (int i = 0; i < NUMBER_OF_REQUESTS; i++) {
      reqs.add(requestResponse.request());
  }

  var responses = api().http().sendRequests(reqs);
  var codes = responses.stream().map(HttpRequestResponse::response).map(HttpResponse::statusCode).toList();
  logging().logToOutput(codes);
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-74efc545ee462780971b4d839986b812e11b584b%2F%7B69D346CD-E49B-46B1-8F5F-11E850ED3E03%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### 2) Launch from Repeater

1. In Repeater: **Custom action** → add from samples.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ea08324571f36fe57d59d511920f146ea06edb4b%2F%7B668FF286-DE9E-4B8E-BAFC-3EDBE64C17AA%7D.png?alt=media" alt="" width="548"><figcaption></figcaption></figure>

* Load custom action created.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-aca5636ca6c2b8a5d09483aa20b52a1190edbe92%2F%7BC0F85A68-691D-45D2-B99A-C14886278A6A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Test with **30 requests**.

we see **status codes** (for 30 shipments) and we can trigger the race condition more easily

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e192221becf971242f3dc030aefede5444517248%2F%7B4BB4F25E-E949-44D6-9EE7-C487F778830E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/web/race-conditions/race-conditions-that-bypass-limits.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
