-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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() } | ||||||||||||||
|
||||||||||||||
| override predicate valueAllowsNewline() { any() } | |
| override predicate valueAllowsNewline() { | |
| not exists(DataFlow::Node value | value = this.getValueArg() | | |
| value.toString().matches("%0A") or value.toString().matches("%0D") | |
| ) | |
| } |
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.
Same as for the name argument above.
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.
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.serverdoes not have any protection against this, soanyis correct.