-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Ruby: Add some missing Rails sinks #12493
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
hmac
commented
Mar 12, 2023
- Ruby: Add reorder as a SQL sink
- Ruby: Add count_by_sql as SQL sink
- Ruby: Taint flow through ActionController params
- Ruby: ActiveRecord::Connection.execute SQL sink
In recent versions of Rails this method doesn't seem to be vulnerable, but it may be in previous versions. There's a slight FP risk here, but I think it is small.
We were not recognising "require" as returning a Parameters instance.
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.
A quick comment about the use of API graphs, but otherwise LGTM (but maybe get a second pair of eyes on the new sinks; I haven't looked at Ruby in a while)
exists(DataFlow::CallNode executeCall | | ||
executeCall.getReceiver() = activeRecordConnectionInstance() and | ||
executeCall.getMethodName() = "execute" and | ||
this = executeCall.getArgument(0) and | ||
unsafeSqlExpr(this.asExpr().getExpr()) |
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.
exists(DataFlow::CallNode executeCall | | |
executeCall.getReceiver() = activeRecordConnectionInstance() and | |
executeCall.getMethodName() = "execute" and | |
this = executeCall.getArgument(0) and | |
unsafeSqlExpr(this.asExpr().getExpr()) | |
this = activeRecordConnectionInstance().getAMethodCall("execute").getArgument(0) and | |
unsafeSqlExpr(this.asExpr().getExpr()) |
We get more benefit from global flow if we stay at the level of API nodes as long as possible before lowering to data-flow nodes.
private DataFlow::Node activeRecordConnectionInstance() { | ||
result = activeRecordClassApiNode().getAMethodCall("connection") | ||
} | ||
|
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.
private DataFlow::Node activeRecordConnectionInstance() { | |
result = activeRecordClassApiNode().getAMethodCall("connection") | |
} | |
private API::Node activeRecordConnectionInstance() { | |
result = activeRecordClassApiNode().getReturn("connection") | |
} |
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.
LGTM aside from Asger's suggestions.