🛡️ Sentinel: [MEDIUM] Fix DoS vulnerability in version comparison logic #818
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Vulnerability:
The version comparison logic (
compareToinsrc/index.ts) previously attempted to process strings of any length.Attackers could supply extremely long strings (e.g., 10MB+) to methods like
isAtLeastorisAbove, causing:replaceand arrays viasplit).Fix:
Introduced a
MAX_VERSION_LENGTHconstant (256 characters).The
compareTofunction now "fails fast" by returningNaN(which evaluates tofalsein comparisons) if the input string exceeds this limit.Verification:
Added performance/DoS regression tests in
src/security.test.tsensuring that massive strings are rejected immediately (<100ms) and returnfalse.Ran existing tests (
src/index.test.ts) to ensure no regressions for valid inputs.PR created automatically by Jules for task 13226085722345310659 started by @srod
Summary by cubic
Fixes a DoS risk in version comparison by limiting input length to 256 characters and failing fast. Long inputs now return false quickly, preventing memory and CPU spikes.
Written for commit 907bb8f. Summary will update on new commits.