FunctionToString overflows on cyclic Proxy prototype chains
维护者通常 1 天内回复
还没有人认领这个 Issue。
- #25964 来自 @chiliec —— 已关闭,未合并
评估
- 难度
- 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 天 19 小时
- 30 天内合并 PR
- 664
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
getsentry/sentry-javascript 的其他 Issue
-
Bug Package: node Spans vercel ai
难度 2/5 1-3 小时 新手友好度 73/100
getsentry/sentry-javascript#26079 · 1 条评论 ·
维护者通常 1 天内回复
-
Bug Node.js
难度 2/5 1-3 小时 新手友好度 68/100
getsentry/sentry-javascript#25950 · 2 条评论 ·
维护者通常 1 天内回复
-
Browser Bug
难度 2/5 1-3 小时 新手友好度 85/100
getsentry/sentry-javascript#25946 · 2 条评论 ·
维护者通常 1 天内回复
-
normalize() throws when a getter throws a Symbol or a null-prototype object可能已有人在做 @rjmcgee53192 于 4 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
getsentry/sentry-javascript#25920 · 2 条评论 ·
维护者通常 1 天内回复
-
Only create Nuxt database and storage spans when there is a parent span可能已有人在做 @nicohrubec 于 6 天前认领。 未关闭Improvement Nuxt
难度 2/5 1-3 小时 新手友好度 83/100
getsentry/sentry-javascript#25805 · 2 条评论 ·
维护者通常 1 天内回复
查看 getsentry/sentry-javascript 的全部 Issue
相似的 Issue
-
reproduced
难度 2/5 1-3 小时 新手友好度 68/100
anomalyco/opencode#61640 · 1 条评论 ·
维护者通常 1 天内回复
-
ai-driven-fuzzing bug Minor
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
ai-driven-fuzzing bug claude Minor
难度 2/5 1-3 小时 新手友好度 82/100
linagora/twake-calendar-frontend#1944 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
Add: Yichang TV未关闭check:passed streams:add
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复