-
Notifications
You must be signed in to change notification settings - Fork 1.8k
RB: add a query flagging uses of Kernel.open()
that are not with a constant string
#10708
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
Conversation
Kernel.open()
that are not with a constant string
There's a compile warning which should be fixed if you rebase against |
@@ -0,0 +1,44 @@ | |||
/** | |||
* Provides a utility classes and predicates for queries reasoning about Kernel.open and related methods. |
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.
* Provides a utility classes and predicates for queries reasoning about Kernel.open and related methods. | |
* Provides utility classes and predicates for reasoning about `Kernel.open` and related methods. |
private import codeql.ruby.frameworks.core.Kernel::Kernel | ||
|
||
/** A call to a method that might access a file or start a process. */ | ||
abstract class AmbiguousPathCall extends DataFlow::CallNode { |
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.
My understanding is that we don't want to be adding any new abstract classes which are exposed to end users (unless we expect them to be extending it, and then we should use the range pattern). E.g. we moved a load of these into an internal
directory in this PR. We may want to do the same thing or something similar here.
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've changed it to a simple non-abstract class, and moved the implementations into that class.
We can always change that to the Range::
pattern later without breaking changes.
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 looks good, but I wonder if there's a problem if we have two queries that can generate alerts for the same vulnerability? Will that lead to duplicate alerts in code scanning and/or some weird UX?
880100f
to
9fe18e5
Compare
QHelp previews: ruby/ql/src/queries/security/cwe-078/KernelOpen.qhelpUse of
|
This query has quite a lot of results, but they all seem to make sense. There are quite a lot of cases like |
@hmac do you have anymore comments? |
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 think the duplicate alert is a bit unfortunate, but not a huge deal. The large number of results is also a little scary but hopefully since this is a "warning" with lowish severity, users won't mind too much...
CVE-2019-10780: TP/TN
CVE-2019-13574: TP/TN
CVE-2019-5477: TP/TN
CVE-2020-8130: TP/TN
CVE-2021-21289: TP/TN
CVE-2021-31799: TP/TN
The alert-message and severity are different from
rb/kernel-open
.But I think the existing
qhelp
forrb/kernel-open
fit nicely, so I reused it completely.Evaluation looks fine. Performance is good.
There are plenty of results, but the results look OK to me.
Although I don't think many of them are exploitable.
The QHelp preview CI fails hard, and I'm not sure why.
It works fine locally, and the qhelp check passes.
So it's a problem with the preview workflow, and not with the qhelp itself.