> 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/business-logic/logical-flaw-allowing-you-to-generate-infinite-money.md).

# Logical Flaw Allowing You to Generate Infinite Money

Logical Flaw Allowing You to Generate Infinite Money notes for PortSwigger Web Security Academy labs, including exploitation workflow, payload testing, Burp Suite validation, and remediation context.

### Infinite Money Logic Flaw

**Description of lab**

This lab contains a logical flaw in the purchasing process. By using a bad interaction between \*\* gift cards\*\*, \*\* promotional coupons\*\* and **order confirmation**, it is possible to generate credit unlimitedly, then buy the Lightweight l33t leather jacket.

Identifier provided:

* **User**: wiener
* **Password**: peter

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d6266562de36e2204ea2a273ddcc86d4cde9b77a%2F%7BB513ED00-D597-4B79-A334-DA892468C359%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Fault Principle

After registration for the newsletter, a promotional coupon is awarded:

* **Coupon** : `SIGNUP30`

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cec3ae61aa8aa88dfce9fdb38e896f416bcb2d8d%2F%7BD56D3280-BB4D-43F8-8847-6272878AAA4B%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-4facaaf5bc9fb5535fa62262eaefe8e69dbaa337%2F%7BAD53D7B2-725A-4FFC-95FD-DFA14AF52FE4%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

In the shop it is possible to buy \*\* gift cards\*\*.

The problem is that the coupon can be applied when purchasing these cards.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-638bd9d523a18f5fbc134ee4c3e1881a831a5357%2F%7BA5CC399E-BDD2-43A3-AC1A-7FF29C413D6D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Initial Exploitation Example

* Purchase of a gift card of **$10**
* Coupon application `SIGNUP30`
* Final price paid: **$7**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2b0c49ff4d33bdf84258dd94c311db53c0605d76%2F%7B218DFB98-4FA8-49E4-870E-3E1BD7F2B23A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Receipt of a **gift card code** (example: `DbWseYFi2v`)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-bf544400cbdd52f0edd21528a147adf250381bd9%2F%7B05028327-3014-4261-AC5C-87AE4946C996%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-15228b23eb9e8d5f47d4f9499c64b44caf503f82%2F%7B2922EBC9-E4DA-4AFA-BF5C-77AFE41E241B%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

When this code is used in the Gift Cards section, the account balance increases by **10$** while only **7$** was spent.

The net gain is therefore **$3**, increasing the total credit to **$103**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5cfa35b4bf87c872cc9d6bb96abafaa4fb2c80cd%2F%7B5F7BEF80-054D-4C94-8965-2D2DDB5EB7D4%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Logic Issues Identified

1. The coupon can be used **several times** to buy gift cards.
2. Credit for gift cards is **still applied at full value**, regardless of the price actually paid.
3. Order confirmation via the endpoint:

   ```bash
   /cart/order-confirmation?order-confirmed=true
   ```

allows dynamic recovery of the gift card code.

No limitation prevents automation of this process.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-55e2eabaee74030c602861c50f46a4dd23222418%2F%7B9C7CB844-596C-4813-8814-5CD251A30BE7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Attack Automation (macro)

To exploit the large-scale fault, a **macro Burp Suite** is implemented.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-27e5c0020d46100245515c8757fda9e0d537b793%2F%7BC0FB1618-3BD6-4892-8DD0-09C160A6911E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Requests Intercepted in the Macro

1. Add a product **Gift card** to the basket
2. Application of the newsletter coupon (`SIGNUP30`)
3. Order validation (`place order`)
4. Recovery of order confirmation response
5. Registration of gift card on user account

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0c7ded1307665efdedff408fffc7c0c44263d3e5%2F%7BA0690E08-23D1-409E-85CF-82E673868463%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Key Macro Points

* The **gift card code** is extracted dynamically from the `cart/order-confirmation` response.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-322587d183fd337eacf0b571ecefa119f9f85dde%2F%7B509B7CC2-BE19-44A3-9990-84933C1553E9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* This code is then reinjected by POST request to the Gift Card Management Endpoint.
* A custom **parameter** is set in the GET query to store the code value.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9bca90655a458d0f44ef9b653d82e1eea128ff43%2F%7B147C5FCB-AA53-4DDF-8B09-ADE105FABEF6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

The applied coupon recovers its value from a previous query, allowing for automatic re-use.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9c9764756e9d9cfb63a9a9054dad2bc4e8068a43%2F%7B0B3C9369-8100-4A35-AF59-3DB19D928851%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Mass Execution

Once the macro is configured:

All requests for the **URL scope** automatically trigger the macro.

* A **Intruder** query is sent to the site root.
* Configuration:
* **500 requests**
* **Payload null**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6faa199c2f98a292c939ce81df7669a9096245f4%2F%7BFB2280E9-9ABE-4875-93B2-CBD08DCB4B7B%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Resource pool** limited to **1 concurrent request**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8c20676ac7b015e7dae383d1e5a649146196c9f0%2F%7B7B673C75-A05B-4061-8C29-80E55C2DBF87%7D.png?alt=media" alt="" width="364"><figcaption></figcaption></figure>

This approach makes it possible to chain purchases, confirmations and credits of gift cards without interruption.

#### Result

The account balance increases indefinitely. / Once sufficient credit is accumulated, the purchase of the **Lightweight l33t leather jacket** becomes possible without financial constraint.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e6e2cd1996c83495734638cd08179a54e2a5cbf5%2F%7B9EBF5FDD-31DC-41F4-9B62-DC0272D14FDD%7D.png?alt=media" alt="" width="375"><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/business-logic/logical-flaw-allowing-you-to-generate-infinite-money.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.
