FunctionToString overflows on cyclic Proxy prototype chains
維護者通常 1 天內回覆
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript, typescript
- 領域
- devtools
研究方向
Start with functionToStringIntegration and packages/core/src/utils/object.ts, focusing on how getOriginalFunction reads __sentry_original__. Use the reproduction in the issue to investigate the cyclic Proxy case; done means the wrapped toString returns normally for that case without changing native behavior.
由索引模型根據 Issue 內容生成。
描述
The patched Function.prototype.toString from functionToStringIntegration throws RangeError: Maximum call stack size exceeded for a function whose prototype chain loops back through a Proxy. Native toString returns normally for the same function. Anti-tamper and fingerprinting scripts use this kind of probe to detect patched natives.
Reported by Sergio Lombana from a customer on @sentry/[email protected] with Castle bot detection loaded. Their event has a short stack: the Sentry toString wrapper is the top frame and the frames below it are Castle's.
Root cause (high confidence for the repro, unverified for the customer's exact trigger)
The wrapper calls getOriginalFunction(this), which reads this.__sentry_original__ (packages/core/src/utils/object.ts). For a function without that own property, the read walks the prototype chain. If the chain loops back through a Proxy, the walk never ends and overflows inside the wrapper frame. Native toString never reads properties from this, so it doesn't overflow.
This still happens on develop after #25921 / #25922. Those PRs fixed the apply re-entry and huge-argument-list overflows, not this property lookup.
Reproduction
const orig = Function.prototype.toString;
const callOrig = Function.prototype.call.bind(orig);
function f() {}
Object.setPrototypeOf(f, Object.create(new Proxy(f, {})));
Function.prototype.toString.call(f); // native: 'function f() {}'
// same shape as the current wrapper on develop
Function.prototype.toString = function () {
const o = this.__sentry_original__;
return callOrig(o ?? this);
};
Function.prototype.toString.call(f); // RangeError: Maximum call stack size exceeded
Unknowns
- Someone else reproduced this artificial case but couldn't trigger the error with the same Castle and SDK versions. So it's not confirmed that this is the probe Castle runs in the customer's environment.
Workaround
- Filter the RangeError via
ignoreErrors/beforeSend. RemovingfunctionToStringIntegrationcan make Sentry-wrapped functions look tampered to anti-bot scripts, so it isn't recommended here.
Related: #21965, #22515, #25921, #25922
via Sergio.
--
- 主要語言
- TypeScript
- 星號
- 8.8k
- 分支
- 1.9k
- 平均合併
- 1 天 20 小時
- 30 天內合併 PR
- 682
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
getsentry/sentry-javascript 的其他 Issue
-
Workers AI integration drops output of non-streaming chat responses in the OpenAI format (`choices`)未關閉Bug Cloudflare Workers Spans
難度 2/5 1-3 小時 新手友好度 78/100
getsentry/sentry-javascript#26120 · 1 則留言 ·
維護者通常 1 天內回覆
-
Bug Cloudflare Workers
難度 2/5 1-3 小時 新手友好度 78/100
getsentry/sentry-javascript#26091 · 1 則留言 ·
維護者通常 1 天內回覆
-
Vercel AI: `gen_ai.system_instructions` is missing when the system prompt is a message object可能已有人在做 @biggdawg320 於 1 天前認領。 未關閉Bug Package: node Spans vercel ai
難度 2/5 1-3 小時 新手友好度 73/100
getsentry/sentry-javascript#26079 · 1 則留言 ·
維護者通常 1 天內回覆
-
fsIntegration crashes in native ESM when patching the read-only fs namespace可能已有人在做 @chargome 於 1 天前認領。 未關閉Bug Node.js Waiting for: Product Owner
難度 2/5 1-3 小時 新手友好度 68/100
getsentry/sentry-javascript#25950 · 2 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
normalize() throws when a getter throws a Symbol or a null-prototype object可能已有人在做 @rjmcgee53192 於 5 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
getsentry/sentry-javascript#25920 · 2 則留言 ·
維護者通常 1 天內回覆
查看 getsentry/sentry-javascript 的全部 Issue
相似的 Issue
-
[Text] Add Reading Time & Word Count Estimator for Reflection Notes in src/lib/text/reading-time.ts未關閉area:core beginner-friendly community contributions-welcome difficulty:easy enhancement good first issue
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
[fullsend] E2E: scorecard — filecheck GitLab entity metrics unavailable due to initialDelay timing未關閉e2e-failure ready-to-code
難度 2/5 1-3 小時 新手友好度 75/100
redhat-developer/rhdh-plugin-export-overlays#4698 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
devswha/herdr-web-ui#2884 ·
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
b:minor bug
難度 2/5 1-3 小時 新手友好度 78/100
software-mansion/argent#1771 ·
維護者通常 1 天內回覆