FunctionToString overflows on cyclic Proxy prototype chains
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
- #25964 von @chiliec — ohne Merge geschlossen
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript, typescript
- Bereich
- devtools
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
--
- Vorherrschende Sprache
- TypeScript
- Sterne
- 8.8k
- Forks
- 1.9k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 664
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus getsentry/sentry-javascript
-
Bug Package: node Spans vercel ai
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
getsentry/sentry-javascript#26079 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug Node.js
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
getsentry/sentry-javascript#25950 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Browser Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
getsentry/sentry-javascript#25946 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
normalize() throws when a getter throws a Symbol or a null-prototype objectEvtl. vergeben @rjmcgee53192 hat das vor 4 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
getsentry/sentry-javascript#25920 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Only create Nuxt database and storage spans when there is a parent spanEvtl. vergeben @nicohrubec hat das vor 5 Tagen übernommen. OffenImprovement Nuxt
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
getsentry/sentry-javascript#25805 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in getsentry/sentry-javascript
Ähnliche Issues
-
needs investigation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 60/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
area:visualizer tech-debt
Schwierigkeit 2/5 Unter einer Stunde Anfängerfreundlichkeit 66/100
jmbarzee/temporal-architect#292 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
riverqueue/river#1576 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
colbymchenry/codegraph#3228 ·
Maintainer antworten meist innerhalb von 1 Tag