Android: Add the Intent parameter of the onActivityResult method as a source
#6963
Conversation
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.
Context
In Android, an Activity (and, up to API level 28, a Fragment too) can start another Activity expecting to receive an Intent in response using the method
startActivityForResult.If the target Activity is started with an implicit Intent, which means that any application could intercept it and return a response, the Intent that the original Activity receives back becomes potentially tainted since it comes from an untrusted source.
This PR introduces a new
RemoteFlowSourcethat attempts to model this behavior, considering theIntentparameter ofonActivityResulta source, only when the Activity or Fragment that implements it also callsstartActivityForResultwith an implicit Intent.Caveats
To properly model the source, data flow analysis is needed. This means that a
DataFlow5::Configurationinstance is brought into the global scope, which is not ideal. I'm open to suggestions about how to improve this. I guess we could create another copy of theDataFlowlibrary as we did withDataFlowForSerializability, but that doesn't sound like a desirable solution in the long run.In the current implementation, the source is only correctly identified if both the callable in which the call to
startActivityForResultoccurs and the implementation ofonActivityResultare declared in the same type (Activity or Fragment). Check theTestMissing.javatest case to see an example of a source that isn't supported by this PR.The text was updated successfully, but these errors were encountered: