[DO NOT MERGE] feat(core): add opt-in assertion instrumentation - #6592
[DO NOT MERGE] feat(core): add opt-in assertion instrumentation#6592antonis wants to merge 11 commits into
4 issues
find-bugs: Found 4 issues (3 medium, 1 low)
Medium
Unbounded values iteration in flattenValues allows DoS via large objects - `packages/core/src/js/assertion.ts:225-237`
flattenValues iterates over every key in values without a count cap and calls JSON.stringify(values) on the full object before truncation, allowing a large input object to exhaust CPU and memory.
collectValueIdentifiers bypasses TDZ guard when AST nodes lack location info - `packages/core/src/js/tools/sentryAssertionBabelPlugin.ts:327-334`
When the assertion condition node has no start (e.g., synthesized by an earlier Babel plugin), the TDZ guard in collectValueIdentifiers is skipped entirely and textually-after let/const bindings are captured. Reading them on the report path crashes with a ReferenceError.
ensureErrorBinding alias crashes when globalThis is shadowed by const/let - `packages/core/src/js/tools/sentryAssertionBabelPlugin.ts:483-490`
The hoisted var _Error initializer can throw a ReferenceError if the module contains a const globalThis or let globalThis declaration, because typeof on a TDZ binding throws instead of returning 'undefined'.
Low
Module-level `reportedSites` set in `captureAssertionViolation` has no size bound, risking memory exhaustion with dynamic `siteId` values - `packages/core/test/integrations/reactnativeerrorhandlers.test.ts:211`
captureAssertionViolation uses a module-level Set (reportedSites) that only grows and is never cleared or capped. While the Babel transform generates static siteId values (filename:line:column) that are bounded by the number of assertion call sites, the function is also a public API exported from @sentry/react-native. A manual caller passing dynamically-generated siteId strings with once: true (the default) can cause the set to grow without bound over the lifetime of the JS runtime, leading to gradual memory exhaustion.
Also found at:
packages/core/test/tools/sentryAssertionBabelPlugin.test.ts:104
⏱ 37m 12s · 12.5M in / 602.5k out · $9.83
Annotations
Check warning on line 237 in packages/core/src/js/assertion.ts
sentry-warden / warden: find-bugs
Unbounded values iteration in flattenValues allows DoS via large objects
`flattenValues` iterates over every key in `values` without a count cap and calls `JSON.stringify(values)` on the full object before truncation, allowing a large input object to exhaust CPU and memory.
Check warning on line 334 in packages/core/src/js/tools/sentryAssertionBabelPlugin.ts
sentry-warden / warden: find-bugs
collectValueIdentifiers bypasses TDZ guard when AST nodes lack location info
When the assertion condition node has no `start` (e.g., synthesized by an earlier Babel plugin), the TDZ guard in `collectValueIdentifiers` is skipped entirely and textually-after `let`/`const` bindings are captured. Reading them on the report path crashes with a `ReferenceError`.
Check warning on line 490 in packages/core/src/js/tools/sentryAssertionBabelPlugin.ts
sentry-warden / warden: find-bugs
ensureErrorBinding alias crashes when globalThis is shadowed by const/let
The hoisted `var _Error` initializer can throw a `ReferenceError` if the module contains a `const globalThis` or `let globalThis` declaration, because `typeof` on a TDZ binding throws instead of returning `'undefined'`.