-
Notifications
You must be signed in to change notification settings - Fork 1.7k
python: model send_header
from http.server
#19432
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 | ||
--- | ||
* Added header write model for `send_header` in `http.server`. |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1963,6 +1963,21 @@ module StdlibPrivate { | |||||||||||||
/** Gets a reference to an instance of the `BaseHttpRequestHandler` class or any subclass. */ | ||||||||||||||
DataFlow::Node instance() { instance(DataFlow::TypeTracker::end()).flowsTo(result) } | ||||||||||||||
|
||||||||||||||
/** A call to a method that writes to a response header. */ | ||||||||||||||
private class HeaderWriteCall extends Http::Server::ResponseHeaderWrite::Range, | ||||||||||||||
DataFlow::MethodCallNode | ||||||||||||||
{ | ||||||||||||||
HeaderWriteCall() { this.calls(instance(), "send_header") } | ||||||||||||||
|
||||||||||||||
override DataFlow::Node getNameArg() { result = this.getArg(0) } | ||||||||||||||
|
||||||||||||||
override DataFlow::Node getValueArg() { result = this.getArg(1) } | ||||||||||||||
|
||||||||||||||
override predicate nameAllowsNewline() { any() } | ||||||||||||||
|
||||||||||||||
override predicate valueAllowsNewline() { any() } | ||||||||||||||
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. [nitpick] Consider refining the predicate for valueAllowsNewline if feasible, to improve the accuracy of tracking header values in the taint analysis.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback 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. Same as for the name argument above. |
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
private class AdditionalTaintStep extends TaintTracking::AdditionalTaintStep { | ||||||||||||||
override predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) { | ||||||||||||||
nodeFrom = instance() 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.
[nitpick] Consider refining the predicate for nameAllowsNewline if possible, rather than using a blanket 'any()' which may reduce the precision of the taint tracking.
Copilot uses AI. Check for mistakes.
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.
It is not about the argument itself, but rather wether the server configuration would allow a newline to appear here.
http.server
does not have any protection against this, soany
is correct.