Skip to content

feat: incoming message origin validation for android - #475

Merged
tiagocandido merged 7 commits into
mainfrom
07-15-feat_incoming_message_origin_validation_for_android
Aug 5, 2026
Merged

feat: incoming message origin validation for android#475
tiagocandido merged 7 commits into
mainfrom
07-15-feat_incoming_message_origin_validation_for_android

Conversation

@michaeljsXu

@michaeljsXu michaeljsXu commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What changes are you making?

Add incoming message origin validation to Android, including exact origins, wildcard subdomains, default-port normalization, and IPv6 support. The cart origin and shop.app remain implicitly trusted when validation is enabled.

The SDK rejects non-HTTPS checkout loads and main-frame redirects, reports rejected messages through an optional callback, and isolates callback failures from checkout processing.

How to test

From platforms/android:

./gradlew :lib:testDebugUnitTest :lib:lintDebug :lib:apiCheck

@github-actions github-actions Bot added the #gsd:50662 Rebase Checkout Kit on UCP label Jul 15, 2026

michaeljsXu commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Comment thread platforms/android/lib/src/main/java/com/shopify/checkoutkit/Configuration.kt Outdated
Comment thread platforms/android/lib/src/main/java/com/shopify/checkoutkit/OriginAllowlist.kt Outdated
Comment thread platforms/android/lib/src/main/java/com/shopify/checkoutkit/OriginAllowlist.kt Outdated
@tiagocandido
tiagocandido force-pushed the 07-15-feat_incoming_mesage_origin_validation_for_web branch from 44efc78 to 6c5a9ad Compare July 31, 2026 11:43
@tiagocandido
tiagocandido force-pushed the 07-15-feat_incoming_message_origin_validation_for_android branch from 57afe11 to 825a6b0 Compare July 31, 2026 11:43
@tiagocandido
tiagocandido marked this pull request as ready for review July 31, 2026 11:57
@tiagocandido
tiagocandido requested a review from a team as a code owner July 31, 2026 11:57
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

Package Size

Platform Artifact Base Head Delta
Android release AAR 255.4 KiB 270.6 KiB +15.2 KiB
Android file breakdown
File Base Head Delta
classes.jar 270.1 KiB 286.1 KiB +16.0 KiB
res/layout/checkout_view_content.xml 2.2 KiB 2.2 KiB 0 B
res/layout/checkout_sheet_content.xml 2.0 KiB 2.0 KiB 0 B
res/values/values.xml 1.2 KiB 1.2 KiB 0 B
R.txt 1.1 KiB 1.1 KiB 0 B
proguard.txt 798 B 798 B 0 B
AndroidManifest.xml 578 B 578 B 0 B
res/drawable/close.xml 431 B 431 B 0 B
res/menu/checkout_menu.xml 354 B 354 B 0 B
META-INF/com/android/build/gradle/aar-metadata.properties 157 B 157 B 0 B

Measured from the PR base SHA and PR head SHA. The file breakdown shows uncompressed sizes within each package artifact, so individual files do not sum to the compressed artifact total. This comment reports package artifact sizes only; it is not a final app binary-size report.

@bitrise

bitrise Bot commented Jul 31, 2026

Copy link
Copy Markdown

Install this build

Open Tophat, select your target device, then click Install. Links open on the Mac running Tophat.

SDK Install
Kotlin Install with Tophat

Checkout Kit E2E results

Status Suite Target Platform OS version tag Device
tests/shared/launch-smoke.yaml kotlin android latest Google Pixel 9
Android 17.0

@tiagocandido
tiagocandido force-pushed the 07-15-feat_incoming_message_origin_validation_for_android branch from 1b210de to 2a954f9 Compare August 3, 2026 11:55
@tiagocandido
tiagocandido force-pushed the 07-15-feat_incoming_mesage_origin_validation_for_web branch from 6d7f99f to 73497e5 Compare August 3, 2026 12:12
@tiagocandido
tiagocandido force-pushed the 07-15-feat_incoming_message_origin_validation_for_android branch 3 times, most recently from d05a9dd to 6a1430d Compare August 3, 2026 15:40
@tiagocandido
tiagocandido force-pushed the 07-15-feat_incoming_mesage_origin_validation_for_web branch from 081459d to 1c51e83 Compare August 3, 2026 15:40
@tiagocandido
tiagocandido force-pushed the 07-15-feat_incoming_message_origin_validation_for_android branch from 6a1430d to 0470e12 Compare August 3, 2026 15:43
OriginPattern.Wildcard(
scheme = normalizedScheme,
suffix = suffix.lowercase(),
port = normalizedPort(normalizedScheme, port.toIntOrNull()),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pretty minor thing.. But toIntOrNull() returns null when :

  • no port was specified
  • the specified port overflows Int

Which would mean an invalid value like https://*.example.com:999999999999

would basically drop the port part, and match on the default HTTP port, accepting messages from essentially a different origin.

Should we do something like this

   val parsedPort: Int? = when {
       port.isEmpty() -> null
       else -> port.toIntOrNull() ?: return null
   }

   OriginPattern.Wildcard(
       scheme = normalizedScheme,
       suffix = suffix.lowercase(),
       port = normalizedPort(normalizedScheme, parsedPort),
   )

With results

1. https://*.example.com
- parsedPort = null
- valid wildcard, default HTTPS port

https://*.example.com:8443
- parsedPort = 8443
- valid wildcard, port 8443

https://*.example.com:999999999999
- toIntOrNull() = null
- return null from parsePattern()
- invalid wildcard is ignored

@tiagocandido tiagocandido Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch. Overflowing wildcard ports are now rejected, tests added.

Base automatically changed from 07-15-feat_incoming_mesage_origin_validation_for_web to main August 3, 2026 16:17
@tiagocandido
tiagocandido force-pushed the 07-15-feat_incoming_message_origin_validation_for_android branch from 0470e12 to bf89479 Compare August 4, 2026 11:45
@tiagocandido
tiagocandido requested a review from kiftio August 4, 2026 11:54
@tiagocandido
tiagocandido merged commit b1e3654 into main Aug 5, 2026
33 checks passed
@tiagocandido
tiagocandido deleted the 07-15-feat_incoming_message_origin_validation_for_android branch August 5, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd:50662 Rebase Checkout Kit on UCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants