Swift: Fix defaultImplicitTaintRead on fields #14661
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix a bug in the
defaultImplicitTaintRead
mechanism for reading from field access paths at sinks. Assumingsource()
is a taint source andMid.field
is a sink (say, defined through models-as-data), consider:Base
does not have afield
.source()
to the access ofmid
with an access path for.field
.defaultImplicitTaintRead
recognizes that the sink is an access toMid
and permits any field ofMid
to be stripped off the access path, and we get a result.source()
to the access ofderived
with an access path for.field
. But this timedefaultImplicitTaintRead
sees that the sink is an access toDerived
and permits any field ofDerived
to be stripped off the access path. That's not good enough, it needs to consider fields of base classes ofDerived
as well in order to findMid.field
.In fact we had logic for this, but it was implemented the wrong way around.
TL;DR:
getABaseType*()
was in the wrong place. Moving it fixes some sinks.I definitely want to do a DCA run on this one.