> For the complete documentation index, see [llms.txt](https://kunalwalavalkar.gitbook.io/write-ups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kunalwalavalkar.gitbook.io/write-ups/portswigger-labs/server-side-topics/business-logic-vulnerabilities/flawed-enforcement-of-business-rules.md).

# Flawed enforcement of business rules

https\://portswigger.net/web-security/logic-flaws/examples/lab-logic-flaws-flawed-enforcement-of-business-rules

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FE4mUhPUiIbXx1CUxgHeh%2F1.png?alt=media&amp;token=50d1930c-b681-47c9-9562-dac0512fbefd" alt=""><figcaption></figcaption></figure>

We have to login using the following credentials:

| Username | Password |
| -------- | -------- |
| wiener   | peter    |

At the top of the page, we an see the following code:

```
NEWCUST5
```

If we scroll to the bottom, there is a newsletter that we can sign up for.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FkKvdBub04N1yDffpGG0r%2F2.png?alt=media&amp;token=dae3d43d-f895-42de-ae2c-e4d136d95f96" alt=""><figcaption></figcaption></figure>

Once we signup for the newsletter, we get another code:

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FaZDlbUpVqJHWMjyokEUb%2F3.png?alt=media&amp;token=3c77b439-e32e-4f3b-99a7-2bdee7176311" alt=""><figcaption></figcaption></figure>

```
SIGNUP30
```

Now, all we have to do is add the "Lightweight l33t leather jacket" and apply the coupons in an alternating manner.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FGyzJTdOkPQdhNp160o53%2F5.png?alt=media&amp;token=4fd10e55-21ee-4cfa-af15-7370419c9a35" alt=""><figcaption></figcaption></figure>

This works because the server checks if the coupon is not applied right after itself but does not check if it is applied after another coupon.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FsBmsQ4TuBq26XMVanL86%2F6.png?alt=media&amp;token=ae33a820-06f2-478c-8b87-138e75ed57e8" alt=""><figcaption></figcaption></figure>

We have solved the lab.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2F6Kcu543gb834uoAgzm9F%2F7.png?alt=media&amp;token=2bf9c052-d99c-40ac-9bec-c3dd9346b0db" alt=""><figcaption></figcaption></figure>
