Add models for the read side of golang.org/x/net/html#373
Add models for the read side of golang.org/x/net/html#373smowton merged 5 commits intogithub:mainfrom
Conversation
607f4b3 to
f8b4734
Compare
|
Expanded this a little to cover the |
8d1f35a to
014a734
Compare
|
The generalisation finds us 23 new true positives on LGTM, mostly due to use of other The base net/html stuff still doesn't find any results, but I'm inclined to keep it as generally useful and reasonably small. |
| @@ -0,0 +1,2 @@ | |||
| lgtm,codescanning | |||
| * Added partial support for the `golang.org/x/net/html` package, modelling tainted data flow from a retrieved HTML document to its attributes and other data. | |||
There was a problem hiding this comment.
| * Added partial support for the `golang.org/x/net/html` package, modelling tainted data flow from a retrieved HTML document to its attributes and other data. | |
| * Added partial support for the `golang.org/x/net/html` package, modeling tainted data flow from a retrieved HTML document to its attributes and other data. |
As far as I know QL uses American English.
014a734 to
d4ab06a
Compare
sauyon
left a comment
There was a problem hiding this comment.
Sorry for the slow review, I've vaguely been waiting for you to address comments but I suppose it makes more sense for you to wait for all the reviews before making changes...
| @@ -0,0 +1,2 @@ | |||
| lgtm,codescanning | |||
| * Added partial support for the `golang.org/x/net/html` package, modelling tainted data flow from a retrieved HTML document to its attributes and other data. | |||
| /** Gets the package name `golang.org/x/net/html`. */ | ||
| string packagePath() { result = "golang.org/x/net/html" } | ||
|
|
||
| private class EscapeString extends HtmlEscapeFunction, TaintTracking::FunctionModel { |
There was a problem hiding this comment.
I think it would be good to have EscapeFunction extend FunctionModel and then have its output for be exposed on it so that its specific output so that escape functions that don't return the escaped result can be modeled, but that should probably be separate from this PR.
| override predicate hasTaintFlow(DataFlow::FunctionInput input, DataFlow::FunctionOutput output) { | ||
| getName() = ["Buffered", "Raw", "Text", "Token"] and input.isReceiver() and output.isResult(0) | ||
| or | ||
| getName() = "TagAttr" and input.isReceiver() and output.isResult(1) |
There was a problem hiding this comment.
I skipped TagName along with attribute keys guessing that the charset restrictions on tag and attribute names would render them sanitary for most purposes
There was a problem hiding this comment.
Fair enough. I don't see these functions being much use in taint flow anyway. Maybe add a comment, though?
d4ab06a to
b1bdc8a
Compare
|
Applied Sauyon's comments; will merge once passing CI |
b1bdc8a to
d28c3bb
Compare
|
So this proved difficult -- the FunctionOutput gives me a postUpdateNode, which doesn't match up with the |
|
Hm, I feel like |
|
I thought walking having the model take us to the post-update node, then reversing that in getANode (even though we're identifying an input here -- the response writer that was written) was messier than asking for the input to begin with. Do you feel strongly against the current solution? Shall we get a third opinion? |
|
Well, I think that |
d28c3bb to
2acee74
Compare
|
@sauyon ok, I've gone for the reversing-from-post-update-node approach. |
|
I hadn't realised that |
This covers cases where an HTML document is retrieved and then parts of its structure are output without proper escaping.
This covers cases where an HTML document is retrieved and then parts of its structure are output without proper escaping.
This entails generalising Http::ResponseBody to account for any modelled function writing to a ResponseWriter.
2acee74 to
a78c35b
Compare
|
Pushed Sauyon's changes here, will merge on green |
This covers cases where an HTML document is retrieved and then parts of its structure are output without proper escaping.