react-native-google-safetynet
react-native-google-safetynet copied to clipboard
[Bug] Application crashed while using sendAndVerifyAttestation method
Application crashed while using sendAndVerifyAttestation method. The logs were not very helpful. I will investigate when I have time. For now creating an issue.
My app details
"react": "16.8.3",
"react-native": "0.59.1",
"react-native-google-safetynet": "^0.3.3"
Code Block
RNGoogleSafetyNet.sendAndVerifyAttestation('asdas','API_KEY').then((res) => {
console.log('send&verify', res);
}).catch(err => {
console.error('send&ver', err);
})
Error Logs
E ReactNativeJS: 'send&ver', { [Error: 10: ]
E ReactNativeJS: framesToPop: 1,
E ReactNativeJS: nativeStackAndroid:
E ReactNativeJS: [ { methodName: 'fromStatus', lineNumber: 14, file: null },
E ReactNativeJS: { methodName: 'convert', lineNumber: 0, file: null },
E ReactNativeJS: { methodName: 'onComplete', lineNumber: 32, file: null },
E ReactNativeJS: { methodName: 'zza', lineNumber: 81, file: null },
E ReactNativeJS: { methodName: 'setResult', lineNumber: 41, file: null },
E ReactNativeJS: { methodName: 'zza', lineNumber: 7, file: null },
E ReactNativeJS: { methodName: 'dispatchTransaction',
E ReactNativeJS: lineNumber: 155,
E ReactNativeJS: file: null },
E ReactNativeJS: { methodName: 'onTransact', lineNumber: 22, file: null },
E ReactNativeJS: { methodName: 'execTransact',
E ReactNativeJS: lineNumber: 731,
E ReactNativeJS: file: 'Binder.java' } ],
E ReactNativeJS: userInfo: null,
E ReactNativeJS: code: 'EUNSPECIFIED',
E ReactNativeJS: line: 2108,
E ReactNativeJS: column: 26,
Hmm, that's weird. I'll look into this now
@karandpr I can't seem to reproduce this on the (newly added) example app in the repo. I noticed you're using RN 0.59 though, so that might be the cause. I haven't tested the module with that version of RN yet
I see. I will check if it's fixed in latest version.
@karandpr are you still seeing issues?
Ha. I never got around testing in new version. I will make a sample project with 0.63 ( After 5 June) and see if I can reproduce and troubleshoot. Looks like we have a duplicate ? https://github.com/rajivshah3/react-native-google-safetynet/issues/369
Ah yikes, didn't even notice that it was a duplicate. I need to be better about managing this repo 😅
It's alright. I will see if I can find why it's failing on newer react versions (or certain versions ?).
@karandpr you are passing the wrong nonce value. Either generate it with generateNonce function of the library or you can generate it with Math functions.
Math.round(Math.pow(36, 16 + 1) - Math.random() * Math.pow(36, 16))
.toString(36)
.slice(1)
@Miti063 Well you are right , but this is not why the error occurred.
I agree, it's no ideal nonce but this is demo code and that nonce works with Native Android SafetyNet , earlier version of react and my implementation in ionic. I have discussed nonce in a feature request earlier (https://github.com/rajivshah3/react-native-google-safetynet/issues/136) . As a plug I have covered SafetyNet and nonce generation in an article published last year (https://blog.jscrambler.com/extended-guide-to-safetynet/).
@karandpr Agreed that it's demo code, but because of that nonce, it's not able to convert into byte using Base64 which is mentioned in the RNGoogleSafetyNetModule.java file & causes the app to crash.
Hey @Miti063 . Interesting. Thanks to your observation I have some pointers towards the issue. @rajivshah3 Hey Rajiv ,so here is the weird thing. I have checked in version 0.62.2
let nonce = "asdas";
RNGoogleSafetyNet.sendAndVerifyAttestation(nonce,'API_KEY').then((res) => {
console.log('send&verify', res);
}).catch(err => {
console.error('send&ver', err);
})
The code doesn't work if nonce string length is
- 1
- 5 (asdas) My original issue.
- 9
- 17
- 33
- ~~2^n + 1~~/ 4n + 1
I will look into this later. Thanks again @Miti063 .
Sorry for the long delay. I think #399 might help figure out where this is coming from. My guess is that it's having trouble decoding nonces like asdas