bamlab / react-native-app-security

Easily implement usual security measures in React Native Expo apps. Made by BAM ❤️💙💛
66 stars 2 forks source link

Pinning of subdomains not working on iOS #9

Closed leabaertschi closed 3 months ago

leabaertschi commented 3 months ago

Hi, me again :). I have the following pins in the app config:

'*.domain.com': [
    'TbowFsbeuRDpkGtjvPicSfV1Yygjcc/LD7N37kUxw+I=',
    '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
],

This works fine on android. But on iOS despite the hashes being wrong (for testing if it works) all requests go through and I get the following logs:

[App] === TrustKit: Checking includeSubdomains configuration for *.domain.com
[App] === TrustKit: Domain sub.domain.com is not pinned

What am I missing? Is there a config to include subdomains?

matthieugicquel commented 3 months ago

Hi,

Pinning of subdomains is done by default, so you should just specify 'domain.com' and subdomains should be pinned. The package configures TrustKit with kTSKIncludeSubdomains set to true

Thanks for the feedback, I'll look into updating the README or throwing an error for "unrecognized domains" at prebuild time.

leabaertschi commented 3 months ago

Hi,

if I remove *. from the hostnames it stops working on Android though, that's why I added it in the first place. I tested in an emulator running Android 14.0.

matthieugicquel commented 3 months ago

Ok, in this case you should consider pinning all subdomains not supported for now 😬

I'll implement it next week, probably with this API for both platforms:

leabaertschi commented 3 months ago

Thanks a lot for taking care of this!

matthieugicquel commented 3 months ago

This has been released in 0.5.0.

You should now be able to use a wildcard to pin a domain and all its subdomains on both iOS and Android

leabaertschi commented 3 months ago

Thanks, it works great now!