Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Application crashed while using sendAndVerifyAttestation method #135

Open
karandpr opened this issue Mar 26, 2019 · 12 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@karandpr
Copy link
Contributor

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,
@rajivshah3
Copy link
Owner

Hmm, that's weird. I'll look into this now

@rajivshah3 rajivshah3 added the bug Something isn't working label Mar 30, 2019
@rajivshah3
Copy link
Owner

@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

@karandpr
Copy link
Contributor Author

karandpr commented Apr 8, 2019

I see. I will check if it's fixed in latest version.

@rajivshah3
Copy link
Owner

rajivshah3 commented May 27, 2020

@karandpr are you still seeing issues?

@karandpr
Copy link
Contributor Author

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 ?
#369

@rajivshah3
Copy link
Owner

Ah yikes, didn't even notice that it was a duplicate. I need to be better about managing this repo 😅

@karandpr
Copy link
Contributor Author

It's alright. I will see if I can find why it's failing on newer react versions (or certain versions ?).

@Miti063
Copy link

Miti063 commented May 28, 2020

@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)

@karandpr
Copy link
Contributor Author

@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 (#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/).

@Miti063
Copy link

Miti063 commented May 28, 2020

@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.

@karandpr
Copy link
Contributor Author

karandpr commented May 28, 2020

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 .

@rajivshah3
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants