Skip to content

Harden CreateMessageActivity against external navigation injection#3228

Merged
sosnovsky merged 9 commits into
masterfrom
fix_prevent_sending_database_as_att
Jul 10, 2026
Merged

Harden CreateMessageActivity against external navigation injection#3228
sosnovsky merged 9 commits into
masterfrom
fix_prevent_sending_database_as_att

Conversation

@DenBond7

@DenBond7 DenBond7 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

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

  • sanitize incoming Intent extras before Navigation can treat them as internal deep-link state;
  • preserve normal public compose/share entry behavior while preventing external navigation injection;
  • Keep outgoing attachment handling restricted to FlowCrypt-managed sources only.

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:

  • normal ACTION_SEND, ACTION_SEND_MULTIPLE, and mailto: flows still open compose as expected;
  • internal reply/forward/draft flows still work;
  • crafted external intents can no longer reach the internal outgoing-message creation dialog;
  • unsafe attachment URIs outside FlowCrypt-managed locations are rejected.

close #3227


Tests (delete all except exactly one):

  • Tests added or updated

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities

@DenBond7 DenBond7 added this to the 1.6.5 milestone Jun 15, 2026
@DenBond7 DenBond7 removed this from the 1.6.5 milestone Jun 24, 2026
@DenBond7
DenBond7 marked this pull request as ready for review July 1, 2026 15:47
@DenBond7
DenBond7 requested a review from sosnovsky as a code owner July 1, 2026 15:47
@DenBond7

DenBond7 commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

@martgil Please test this one

Comment on lines +42 to +44
if (authority !in allowedContentAuthorities) {
throw IllegalArgumentException("Attachment content URI authority is not allowed: $authority")
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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:

Image

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.documents or com.android.externalstorage.documents. addAttachmentInfoFromUri() stores those content:// URIs directly in composeMsgViewModel, and ProcessingOutgoingMessageInfoHelper now calls this validator before opening them, so sending a manually attached file will fail. The sink should reject unsafe file:// paths, but still allow externally granted content:// URIs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, you are right. Thanks for pointing this out! I’ll fix the issue.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@sosnovsky I've fixed it and updated tests

@martgil

martgil commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

@martgil Please test this one

Will do - I'll keep you posted as soon as possible.

@martgil

martgil commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

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).

@DenBond7
DenBond7 requested a review from sosnovsky July 10, 2026 18:08

@sosnovsky sosnovsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

works well now, thanks!

@sosnovsky
sosnovsky merged commit 8940c71 into master Jul 10, 2026
7 checks passed
@sosnovsky
sosnovsky deleted the fix_prevent_sending_database_as_att branch July 10, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

External intent can trigger internal send flow and attach FlowCrypt-private files

3 participants