-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Javascript] CWE-348: Client supplied ip used in security check #6864
base: main
Are you sure you want to change the base?
Conversation
Thanks. This generally LGTM. I have a few suggestions for code quality improvements. (I trust that all of the learnings from the two other PRs have made it into this PR.) |
javascript/ql/src/experimental/Security/CWE-348/ClientSuppliedIpUsedInSecurityCheckLib.qll
Outdated
Show resolved
Hide resolved
javascript/ql/src/experimental/Security/CWE-348/ClientSuppliedIpUsedInSecurityCheckLib.qll
Show resolved
Hide resolved
javascript/ql/src/experimental/Security/CWE-348/ClientSuppliedIpUsedInSecurityCheckLib.qll
Show resolved
Hide resolved
javascript/ql/src/experimental/Security/CWE-348/ClientSuppliedIpUsedInSecurityCheck.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/experimental/Security/CWE-348/ClientSuppliedIpUsedInSecurityCheck.ql
Outdated
Show resolved
Hide resolved
node.asExpr().(MethodCallExpr).getMethodName() = "split" and | ||
source = node and | ||
not aa.getIndex().getIntValue() = 0 and | ||
source.flowsTo(aa.getAChildExpr().flow()) |
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.
getAChildExpr
should generally not be used, but rather something like getIndex
as seen above. What is being expressed in this final conjunct?
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.
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.
I see now, thanks for clarifying. We should just stick to the DataFlow
library then. Something like the following should do the trick:
exists(DataFlow::MethodCallNode split, DataFlow::PropRead read |
split = node and
 split.getMethodName() = "split" and // n.split(...)
read = split.getAPropertyRead() // <n.split(...)>[...]
 not read.getPropertyNameExpr().getIntValue() = 0 and
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.
Hi @esbena,
Sorry for the late reply, I have modified the isSanitizer
part and it should look good now. Thanks for your awesome suggestions. Do you have a moment to take a look at it again?
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.
Friendly ping! @esbena
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.
@esbena Hey there!
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.
Sorry about the delay. I'll take a look now.
javascript/ql/src/experimental/Security/CWE-348/ClientSuppliedIpUsedInSecurityCheckLib.qll
Outdated
Show resolved
Hide resolved
javascript/ql/src/experimental/Security/CWE-348/ClientSuppliedIpUsedInSecurityCheckLib.qll
Outdated
Show resolved
Hide resolved
9576171
to
a818580
Compare
javascript/ql/src/experimental/Security/CWE-348/ClientSuppliedIpUsedInSecurityCheckLib.qll
Outdated
Show resolved
Hide resolved
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.
Thank you, there's one http/HTTP casing mistake left to fix. I have started a final performance check of the query, I'll approve once it looks good.
javascript/ql/src/experimental/Security/CWE-348/ClientSuppliedIpUsedInSecurityCheck.qhelp
Outdated
Show resolved
Hide resolved
…IpUsedInSecurityCheck.qhelp Co-authored-by: Esben Sparre Andreasen <[email protected]>
Have you run this query with vscode and viewed the results? Example:
|
Draft-stating the PR due to inactivity, but feel free to undraft when you have implemented the requested changes. |
Hi there,
This merge request ports these two similar queries to Javascript:
I also used local data flow to detect more sanitized cases in Javascript.