Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Conversation

@ghost
Copy link

@ghost ghost commented May 5, 2020

This PR models the golang stdlib io package. It depends on #129.

Here's a brief of changes made.

  1. I have moved Reader.Read,Writer.Write, WriteString which Max wrote in Fix and improve taint-tracking through function arguments #129 into a new IO.qll file. I have also added a few doc comments on them.
  2. I have further modelled multiple function definitions found in the io package. From what I can see, this completes the entire package.
  3. I am yet to add tests but I would like a review before that.

Also, please note that I have based my PR on #129. Since, the PR is not yet merged, you may have to cherry-pick the commits before merging.

Copy link
Contributor

@max-schaefer max-schaefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on the whole, thanks for adding so many models! A few comments on consistency and typos. Perhaps a few tests would be good as well, they would have helped catch some of the latter.

Once #129 has landed we'll need to do an evaluation of this PR.

private class Copy extends TaintTracking::FunctionModel, Function {
// Include the Copy and CopyBuffer functions but exclude the
// CopyN function as it can't be realistically determined how long
// a buffer is enough for a particular exploit.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting point, but I'd like to see a false positive first before excluding it.

Copy link
Author

@ghost ghost May 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a normal webapp, you can imagine a case where an untrusted parameter or something flows into a XSS sink through a copyN call. Now, for most purposes, if n is small enough say 5-10 bytes, regardless of whether the input is sanitised by any other means or not, the flow would not lead to any security issues as an attacker can't realisticaly frame any decent XSS Payload with just 5 bytes. This would lead to a false positive.

The issue may be more prominent in low level systems and crypto code but unfortunately, off the top of my head, I can't come up with any bad examples as of now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, I have included this with the PR. I think the True positive/false positive ratio would favor this change.

@ghost
Copy link
Author

ghost commented May 10, 2020

I have added the test now. I am also modelling functions from the bufio and other pacakges for which I will send in another PR soon.

@sauyon
Copy link
Contributor

sauyon commented May 10, 2020

Can you rebase or merge this over master now that the #129 has been merged?

@ghost
Copy link
Author

ghost commented May 11, 2020

Rebased and squashed for easier merging.

@max-schaefer
Copy link
Contributor

I've started an evaluation, once that is done I think this is ready to merge.

Copy link
Contributor

@max-schaefer max-schaefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Evaluation was uneventful; lgtm.

@max-schaefer max-schaefer merged commit d438b5e into github:master May 12, 2020
@max-schaefer max-schaefer added the needs-polishing An external contribution that may need follow-up work. label May 12, 2020
@ghost ghost deleted the IO branch May 12, 2020 19:38
@max-schaefer max-schaefer mentioned this pull request May 13, 2020
@max-schaefer max-schaefer added no-change-note-required and removed needs-polishing An external contribution that may need follow-up work. labels May 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants