Repository navigation
JS: Stop treating parseInt and parseFloat as whole-string number guards #23121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Checks of the form `isNaN(parseInt(x))` and `isNaN(parseFloat(x))` are no longer treated as checking that `x` is a number, since `parseInt` and `parseFloat` only validate a numeric prefix of `x`. This can reveal previously missed alerts, for example from `js/shell-command-constructed-from-input` and `js/unsafe-jquery-plugin`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -989,13 +989,6 @@ module TaintTracking { | |
| | | ||
| operand = isNaN.getArgument(0).asExpr() | ||
| or | ||
|
|
||
| exists(DataFlow::CallNode parse | | ||
| parse = DataFlow::globalVarRef(["parseInt", "parseFloat"]).getACall() | ||
| | | ||
| parse = isNaN.getArgument(0) and | ||
| operand = parse.getArgument(0).asExpr() | ||
| ) | ||
| or | ||
|
Comment on lines
-992
to
-998
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A corresponding disjunct should be added to the characteristic predicate of NumberGuard for prototype pollution, as the case that is being removed is still valid for the purpose of that class.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻 Added in 1317435 |
||
| exists(UnaryExpr unary | unary.getOperator() = ["+", "-"] | | ||
| unary = isNaN.getArgument(0).asExpr() and | ||
| operand = unary.getOperand() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be investigated before merging.