Skip to content

Swift: Support MaD summaries #10699

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

Merged
merged 8 commits into from
Oct 6, 2022
Merged

Conversation

MathiasVP
Copy link
Contributor

@MathiasVP MathiasVP commented Oct 6, 2022

This PR does a couple of MaD-summary related things:

A commit-by-commit review is encouraged. The first commit adds support for selecting fields as flow sources. This is motivated by #10597, and this PR changes those flow sources to specified using MaD.

The remaining commits adds support for specifying summaries in MaD for Swift. It took some extra dataflow work to support callbacks, but in the end, we can now track flow from taintedUrl to data! in the call to sink:

URLSession.shared.dataTask(with: taintedUrl) { (data, response, error) in
  sink(data: data!) // tainted
}

@MathiasVP MathiasVP added the Swift label Oct 6, 2022
@MathiasVP MathiasVP requested a review from a team as a code owner October 6, 2022 00:10
@MathiasVP MathiasVP changed the title C++: Support MaD summaries for Swift Swift: Support MaD summaries Oct 6, 2022
@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label Oct 6, 2022
@MathiasVP MathiasVP force-pushed the swift-mad-summaries branch from 1b48c66 to 56523d4 Compare October 6, 2022 08:41
@MathiasVP MathiasVP force-pushed the swift-mad-summaries branch from 56523d4 to 0065a5a Compare October 6, 2022 09:30
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

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

LGTM, a big improvement for taint.

private class UrlSessionSummaries extends SummaryModelCsv {
override predicate row(string row) {
row =
";URLSession;true;dataTask(with:completionHandler:);;;Argument[0];Argument[1].Parameter[0];taint"
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding this, along with the test for it!

I think the data returned from a dataTask should ultimately be a taint source rather than a summary - it doesn't really matter if the URL itself was tainted, the data returned from it is. But at the very least we have something here and we know we can cope with callbacks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Indeed, I agree that this should be a taint source as well. Having a taint summary will still be useful though (so that we can still track flow through these library calls in queries that don't pick any RemoteFlowSource as a taint source).

Copy link
Contributor

Choose a reason for hiding this comment

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

I've added it to the taint source TODO list.

MathiasVP and others added 2 commits October 6, 2022 16:59
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
@MathiasVP MathiasVP merged commit 10eb548 into github:main Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Swift
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants