Skip to content

fix(share): Add nonce validation to broadcast receiver on Android - #2592

Open
OS-pedrogustavobilro wants to merge 2 commits into
mainfrom
fix/share-plugin/android-exported
Open

fix(share): Add nonce validation to broadcast receiver on Android#2592
OS-pedrogustavobilro wants to merge 2 commits into
mainfrom
fix/share-plugin/android-exported

Conversation

@OS-pedrogustavobilro

@OS-pedrogustavobilroOS-pedrogustavobilro commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Description

⚠️ 🤖 AI-Assisted Development with Claude, with manual review and testing done by me

Validates nonce to prevent other apps from spoofing the chosen component via exported receiver for the share plugin.

Keep RECEIVER_EXPORTED because Android 14+ requires it for system callbacks via PendingIntent.fillIn(). Add nonce validation instead: each share request generates a unique UUID included in the callback PendingIntent. Only broadcasts with a matching nonce are accepted.

The system always delivers the same extras that were provided in the PendingIntent, which is why this solution works.

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

Rationale / Problems Fixed

Closes#2591

Tests or Reproductions

You may use the test app from ionic-team/capacitor-testapp#790 to test (may require --legacy-peer-deps in npm install).

Tested across multiple Android versions (Android 9 to 17), with devices from different manufacturers:

  • ✅ Samsung
  • ✅ OnePlus
  • ✅ Google Pixel
  • ✅ HMD
  • ✅ Xiaomi
  • ✅ Lenovo
  • ✅ Oppo
  • ✅ Vivo
  • ✅ realme
  • ✅ Motorola
  • ⚠️ Huawei: No intent is received, but from my tests this already happens before this PR, so I'm attributing this to the actual OEM; nothing to do here.

Platforms Affected

  • Android
  • iOS
  • Web

Validates nonce to prevent other apps from spoofing the chosen component via exported receiver.
References: #2591
@github-actions

Copy link
Copy Markdown

Released dev build of share with dev version: 8.0.2-dev-2592-20260907T172304.0

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[share] Broadcast receiver registered as RECEIVER_EXPORTED without permission guard (CWE-926)

1 participant

@OS-pedrogustavobilro