feat: incoming message origin validation for android - #475
Conversation
44efc78 to
6c5a9ad
Compare
57afe11 to
825a6b0
Compare
Package Size
Android file breakdown
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. |
Install this buildOpen Tophat, select your target device, then click Install. Links open on the Mac running Tophat.
Checkout Kit E2E results
|
1b210de to
2a954f9
Compare
6d7f99f to
73497e5
Compare
d05a9dd to
6a1430d
Compare
081459d to
1c51e83
Compare
6a1430d to
0470e12
Compare
| OriginPattern.Wildcard( | ||
| scheme = normalizedScheme, | ||
| suffix = suffix.lowercase(), | ||
| port = normalizedPort(normalizedScheme, port.toIntOrNull()), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Good catch. Overflowing wildcard ports are now rejected, tests added.
0470e12 to
bf89479
Compare

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.appremain 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: