FunctionToString overflows on cyclic Proxy prototype chains
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
- #25964 de @chiliec — fechado sem integrar
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- javascript, typescript
- Domínio
- devtools
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
--
- Linguagem predominante
- TypeScript
- Estrelas
- 8.8k
- Forks
- 1.9k
- Merge médio
- 1d 19h
- PRs com merge (30d)
- 664
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de getsentry/sentry-javascript
-
Bug Node.js
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
getsentry/sentry-javascript#25950 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Browser Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
getsentry/sentry-javascript#25946 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
normalize() throws when a getter throws a Symbol or a null-prototype objectTalvez já em andamento @rjmcgee53192 assumiu há 4 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
getsentry/sentry-javascript#25920 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Only create Nuxt database and storage spans when there is a parent spanTalvez já em andamento @nicohrubec assumiu há 5 dias. AbertaImprovement Nuxt
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
getsentry/sentry-javascript#25805 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Only create Cloudflare storage and D1 db spans when there is a parent spanTalvez já em andamento @nicohrubec assumiu há 5 dias. AbertaCloudflare Workers Improvement Spans
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
getsentry/sentry-javascript#25804 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de getsentry/sentry-javascript
Issues semelhantes
-
needs investigation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 60/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Makefile names visualizer gate targets that do not exist; the TS packages have no test runnerAbertaarea:visualizer tech-debt
Dificuldade 2/5 Menos de uma hora Facilidade para iniciantes 66/100
jmbarzee/temporal-architect#292 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
riverqueue/river#1576 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
colbymchenry/codegraph#3228 ·
Mantenedores costumam responder em até 1 dia