Skip to content

fix: add NFC_PREFERRED_PAYMENT_INFO permission to prevent HCE stack contention#259

Closed
a1denvalu3 wants to merge 1 commit intomainfrom
fix/nfc-preferred-payment-dos
Closed

fix: add NFC_PREFERRED_PAYMENT_INFO permission to prevent HCE stack contention#259
a1denvalu3 wants to merge 1 commit intomainfrom
fix/nfc-preferred-payment-dos

Conversation

@a1denvalu3
Copy link
Copy Markdown
Collaborator

Summary

This PR fixes a critical silent failure introduced by updating the targetSdk to 35 (Android 15) which effectively broke the core NFC payment functionality.

Root Cause

Android 15 strictly requires the android.permission.NFC_PREFERRED_PAYMENT_INFO permission whenever an application calls CardEmulation.setPreferredService(). The system enforces this at the API level unconditionally—even though Numo is only registering an NDEF tag (CATEGORY_OTHER).

Because this permission was omitted from AndroidManifest.xml, calling cardEmulation.setPreferredService(this, componentName) inside PaymentRequestActivity and ModernPOSActivity threw a SecurityException. This exception was caught and logged, causing a silent failure where the OS routed incoming NFC tap events to the device's default payment app (e.g., Google Wallet) instead of Numo's NdefHostCardEmulationService.

Changes Made

  • Added the <uses-permission android:name="android.permission.NFC_PREFERRED_PAYMENT_INFO" /> to app/src/main/AndroidManifest.xml to satisfy the API level requirement.

…id 15

    Android 15 (targetSdk 35) requires the NFC_PREFERRED_PAYMENT_INFO permission
    when calling `CardEmulation.setPreferredService()`, even when only
    using a standard NDEF AID. If this permission is absent, the call throws a
    `SecurityException`, which was previously caught and logged but caused a
    silent failure where the POS terminal couldn't prioritize its own HCE service.
    This caused NFC payments to be intercepted by the default payment app
    (e.g., Google Wallet).
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 20.65%. Comparing base (22b7b9f) to head (8bab586).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #259      +/-   ##
============================================
+ Coverage     20.64%   20.65%   +0.01%     
  Complexity      773      773              
============================================
  Files           145      145              
  Lines         18575    18575              
  Branches       2274     2274              
============================================
+ Hits           3834     3837       +3     
+ Misses        14261    14256       -5     
- Partials        480      482       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@a1denvalu3 a1denvalu3 changed the title fix: add NFC_PREFERRED_PAYMENT_INFO permission to prevent DoS on Android 15 fix: add NFC_PREFERRED_PAYMENT_INFO permission to prevent HCE stack contention Apr 13, 2026
@a1denvalu3
Copy link
Copy Markdown
Collaborator Author

This is complete bullshit. I tried to log the security exception in question and it never appears...

@a1denvalu3 a1denvalu3 closed this Apr 13, 2026
@github-project-automation github-project-automation bot moved this from Backlog to Done in Numo Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant