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
[draft] DB reads as taint sources #7474
base: main
Are you sure you want to change the base?
Conversation
| @@ -57,6 +57,26 @@ module Knex { | |||
| ) | |||
| } | |||
|
|
|||
| override DataFlow::Node getAQueryArgument() { none() } | |||
| override DataFlow::Node getAResult() { | |||
| ( | |||
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.
the knex model is a bit unusual in that it classifies both the expression producing the promise, as well as the await expression as database accesses. getAResult, in this case, follows the implementation of the characteristic predicate. LMK what you think.
| @@ -84,6 +84,7 @@ abstract class FileNameSource extends DataFlow::Node { } | |||
| abstract class DatabaseAccess extends DataFlow::Node { | |||
| /** Gets an argument to this database access that is interpreted as a query. */ | |||
| abstract DataFlow::Node getAQueryArgument(); | |||
| abstract DataFlow::Node getAResult(); | |||
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.
Missing Ql Doc.
| (this = database().getMember("run").getACall() and result = this.getCallback(_).getParameter(1)) | ||
| or | ||
| (this = transaction().getMember("run").getACall() and result = this.getCallback(_).getParameter(1)) | ||
| or | ||
| (this = snapshot().getMember("run").getACall() and result = this.getCallback(_).getParameter(1)) |
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 you should be able to simplify this using set-literals to
this = [database(), transaction(), snapshot()].getMember("run").getACall() and result = this.getCallback(_).getParameter(1))| @@ -52,3 +52,13 @@ class RemoteServerResponse extends HeuristicSource, RemoteFlowSource { | |||
|
|
|||
| override string getSourceType() { result = "a response from a remote server" } | |||
| } | |||
|
|
|||
| class DatabaseAccessResultRemoteFlowSource extends HeuristicSource, RemoteFlowSource { | |||
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.
Missing Ql Doc.


This adds DB reads as taint sources in
AdditionalSources.qllas requested in github/codeql-javascript-team#348.This is not yet complete, as it's not handling streaming database queries where the result is consumed by a pipe call (eg, knex, spanner, have such features).
This also partially fixes (not yet complete) github/codeql-javascript-team#355
The text was updated successfully, but these errors were encountered: