FunctionToString overflows on cyclic Proxy prototype chains
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
- #25964 par @chiliec — fermée sans fusion
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- javascript, typescript
- Domaine
- devtools
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
--
- Langage dominant
- TypeScript
- Étoiles
- 8.8k
- Forks
- 1.9k
- Merge moyen
- 1 j 19 h
- PR mergées (30 j)
- 664
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de getsentry/sentry-javascript
-
Bug Node.js
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
getsentry/sentry-javascript#25950 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Browser Bug
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
getsentry/sentry-javascript#25946 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
normalize() throws when a getter throws a Symbol or a null-prototype objectPeut-être pris @rjmcgee53192 l’a pris il y a 4 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
getsentry/sentry-javascript#25920 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Only create Nuxt database and storage spans when there is a parent spanPeut-être pris @nicohrubec l’a pris il y a 5 jours. OuverteImprovement Nuxt
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
getsentry/sentry-javascript#25805 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Only create Cloudflare storage and D1 db spans when there is a parent spanPeut-être pris @nicohrubec l’a pris il y a 5 jours. OuverteCloudflare Workers Improvement Spans
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
getsentry/sentry-javascript#25804 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de getsentry/sentry-javascript
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
riverqueue/river#1576 ·
Les mainteneurs répondent en général sous 1 jour
-
[bug] A prompt queued during a run is assessed without its textPeut-être pris @jwiegley l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
DevMortimer/pi-warden#211 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 1/5 Moins d'une heure Accessibilité débutants 84/100
mattermost/compass-design#191 ·
Les mainteneurs répondent en général sous 1 jour
-
Add unit tests for the organization admin role checkPeut-être pris @SaffuSafwan l’a pris aujourd’hui. Ouvertearea/core good first issue help wanted
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
elmohq/elmo#1095 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
HorusGoul/trizum#559 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour