Harden CreateMessageActivity against external navigation injection#3228
Conversation
# Conflicts: # gradle/wrapper/gradle-wrapper.properties
|
@martgil Please test this one |
| if (authority !in allowedContentAuthorities) { | ||
| throw IllegalArgumentException("Attachment content URI authority is not allowed: $authority") | ||
| } |
There was a problem hiding this comment.
looks like current allowlist is too strict - for example, when trying to send email message with attachment from google drive, I received such error message:
got such explanation from Codex:
This allowlist rejects normal user-selected attachments from Android's document picker, whose URIs commonly use authorities such as
com.android.providers.media.documentsorcom.android.externalstorage.documents.addAttachmentInfoFromUri()stores thosecontent://URIs directly incomposeMsgViewModel, andProcessingOutgoingMessageInfoHelpernow calls this validator before opening them, so sending a manually attached file will fail. The sink should reject unsafefile://paths, but still allow externally grantedcontent://URIs.
There was a problem hiding this comment.
Good catch, you are right. Thanks for pointing this out! I’ll fix the issue.
There was a problem hiding this comment.
@sosnovsky I've fixed it and updated tests
Will do - I'll keep you posted as soon as possible. |
|
Hi @DenBond7, I have already done testing this PR and the database was no longer be added as an attachment to the secure email through using the malicious actor's application (in this case, the provided poc). |
sosnovsky
left a comment
There was a problem hiding this comment.
works well now, thanks!
This change hardens the exported compose entry point against untrusted external intents reaching internal send-only flows.
Problem
CreateMessageActivity is intentionally exported to support normal Android share and mail intents. However, untrusted external intents were able to influence internal navigation behavior more than intended and reach the outgoing-message creation path directly. That flow could then process attacker-controlled attachment URIs using FlowCrypt’s own app identity.
What changed
Why
External intents should only initialize the normal compose experience. They must not be able to route directly into internal send logic or supply unsafe attachment locations that are later opened with app privileges.
What verified:
close #3227
Tests (delete all except exactly one):
To be filled by reviewers
I have reviewed that this PR... (tick whichever items you personally focused on during this review):