FunctionToString overflows on cyclic Proxy prototype chains
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
- #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時間
- マージ済み PR(30日)
- 664
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 が 5 日前に担当しました。 オープンImprovement Nuxt
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
getsentry/sentry-javascript#25805 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
getsentry/sentry-javascript の issue をすべて見る
似ている issue
-
test: claim-conflict drop leaves both facts active and is never re-proposed (untested review cell)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
[Feature]: Usage page should show API-equivalent cost and say when a connected plan shows info onlyオープンenhancement from-x
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
nightly-labs/openbot#4867 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
egonSchiele/agency-lang#1377 ·
メンテナーはふだん 1 日以内に返信
-
normalizePath removes the Windows device namespace prefix対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
caprover/caprover-frontend#273 ·
メンテナーはふだん 1 日以内に返信