Skip to content

JS: Fix resource exhaustion alerts for bounded Math.min - #23221

Draft
hvitved wants to merge 2 commits into
mainfrom
hvitved-js-resource-exhaustion-clamp
Draft

hvitved wants to merge 2 commits into
mainfrom
hvitved-js-resource-exhaustion-clamp

Conversation

@hvitved

@hvitved hvitved commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Avoid resource-exhaustion alerts for values bounded by a finite numeric constant with Math.min.
  • Preserve alerts for unbounded and non-constant limits, and add regression coverage.

Fixes #23219

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The change suppresses valid resource-exhaustion alerts when later operations invalidate inferred upper bounds or mutable variables are incorrectly classified as constants.

4 open issues
What changed in this PR

Updates JavaScript’s js/resource-exhaustion query to reduce false positives for sizes and delays capped by Math.min, addressing #23219.

Changes:

  • Recognizes finite numeric bounds, including signed literals and qualifying variables.
  • Adds regression coverage for bounded calls and cases that should still alert.
  • Updates expected results and adds a release note.
File Description
javascript/​ql/​test/​query-tests/​Security/​CWE-770/​ResourceExhaustion/​ResourceExhaustion.expected Records expected alerts and flow paths for the new tests.
javascript/​ql/​test/​query-tests/​Security/​CWE-770/​ResourceExhaustion/​math-min.js Adds bounded and unbounded Math.min regression cases.
javascript/​ql/​src/​change-notes/​2026-11-24-math-min-resource-exhaustion.md Documents the false-positive reduction.
javascript/​ql/​lib/​semmle/​javascript/​security/​dataflow/​ResourceExhaustionQuery.qll Excludes qualifying bounded Math.min calls from numeric taint propagation.

Review effort: Balanced (adaptive)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@hvitved
hvitved force-pushed the hvitved-js-resource-exhaustion-clamp branch from 20f1c21 to 03aa54f Compare November 24, 2026 11:14
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JS: js/resource-exhaustion reports sizes and delays that are clamped with Math.min

2 participants