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

High percentage of invalid assessments using App Check with reCAPTCHA Enterprise #7969

Open
harrisonlo opened this issue Jan 22, 2024 · 6 comments

Comments

@harrisonlo
Copy link

harrisonlo commented Jan 22, 2024

Operating System

Various

Browser Version

Various

Firebase SDK Version

10.7.0

Firebase SDK Product:

App Check

Describe your project's tooling

React app on desktop web and mobile web

Describe the problem

App Check

I'm observing a high percentage of invalid requests for App Check on the Firestore Database and the Realtime Database:
Screen Shot 2024-01-22 at 4 01 01 PM
Screen Shot 2024-01-22 at 4 01 32 PM
Additionally, the graph for Storage is showing 100% verified, but it only has a few hundred requests.

reCAPTCHA Enterprise

Below are screenshots from the GCP reCAPTCHA Enterprise dashboard, also for the past 30 days:
Screen Shot 2024-01-22 at 4 07 41 PM
Screen Shot 2024-01-22 at 4 08 20 PM
Screen Shot 2024-01-22 at 4 09 30 PM

Issue and thoughts

Given that requests are almost all marked as low risk on the GCP dashboard, I'm guessing there might be some bug on the App Check client that's not sending valid requests to reCAPTCHA. I could be wrong, but given the high false positive rates (as reported by users), I simply cannot enforce it across the databases. I'm grateful to the Firebase team for supporting this and hope I can enforce it one day. Let me know if there's any more information I can provide.

Steps and code to reproduce issue

This is hard to reproduce. I opened an issue a while back #7116 that was related. From my own usage in the past, app check starts to fail after having the app opened for a long period of time, potentially related to #6708. However, I've also had a (returning) user seeing it on app open, meaning assessment passed before but failed later on the same device.

In the app, I would initializeApp() then initializeAppCheck immediately. This happens when users open the app.

const app = initializeApp(options, name)

initializeAppCheck(app, {
  provider: new ReCaptchaEnterpriseProvider(key),
  isTokenAutoRefreshEnabled: true
})
@harrisonlo harrisonlo added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Jan 22, 2024
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@jbalidiong jbalidiong added needs-attention api: appcheck and removed needs-triage new A new issue that hasn't be categoirzed as question, bug or feature request labels Jan 22, 2024
@hsubox76
Copy link
Contributor

There are two ways we can dig further into this:

(1) On your end, you can create a test app that does not use Firebase and only performs a reCAPTCHA validation using reCAPTCHA tooling. Try this on the same devices and situations where you are getting a lot of failures and see if you get a similar failure rate. If so, that indicates that reCAPTCHA isn't playing nice with your devices/usage. This may be easy to do if you're familiar with using reCAPTCHA by itself, and may be a bit of a pain otherwise.

(2) On our end, if you can get the network request logs in your browser from one of the failed attempts, that would be great. We're looking for calls to https://www.google.com/recaptcha/enterprise.js and https://content-firebaseappcheck.googleapis.com/v1. If you can share the request and response data from each of those requests, that would help determine where the problem is. The first endpoint is getting the ReCAPTCHA token and the second is sending that token to the AppCheck endpoint to validate it, and exchange it for an AppCheck token. Also, if you have any errors or warnings logged in your browser's developer console (on the client that is running, not the backend console).

@harrisonlo
Copy link
Author

Thanks for providing a direction for debugging this. While I don't have access to the devices of my users, I just checked the network requests on my device (Chrome browser) and noticed some random failed firestore requests.

Screen Shot 2024-01-26 at 8 36 58 PM

Not sure if this is related. There are no response data in the failed requests. The recaptcha and appcheck requests were fine in this particular session. Note that there are 2 firebase instances running, which I'm guessing explain the two different gsessionIds.

Here's the successful request of the same gsessionId (starting with q7Kz...) that was 2 minutes before the failed one:

Screen Shot 2024-01-26 at 8 47 52 PM

Another request of the same type succeeded 1 second after the failed one, now with a different gsessionId. Note that I'm not doing anything on the page, it's just idle there with several query listeners open.

Screen Shot 2024-01-26 at 8 50 57 PM

I'm seeing the same failed firestore requests 10 minutes later. Pasting the console errors and warnings here:

Screen Shot 2024-01-26 at 9 07 18 PM Screen Shot 2024-01-26 at 9 07 25 PM

I don't know if these are relevant at all. Let me know if they're not, I'll remove them (or move them to another issue) so we can focus on the app check issue. I'll keep checking the recaptcha and app check requests in the future.

@hsubox76
Copy link
Contributor

I'll have to consult a firestore team member about if this is indicative of anything but I don't think it's related to the App Check issue, since Firestore (1) hits a different endpoint with a different protocol and (2) is downstream of App Check, so if anything, App Check errors would cause Firestore errors, but not be affected by them. It could indicate spotty network connections, which could affect both, though. Let me see if I can find someone from Firestore to confirm.

@hsubox76
Copy link
Contributor

So I talked to a Firestore team member and it's unlikely the Firestore errors are related to the App Check errors. I would suggest making another issue for the Firestore errors if you find they are impacting you a lot. From a glance, it looks like it could just be a spotty network connection that missed one request, but if it seems like a bigger or more serious problem than that, feel free to open a Firestore issue for it.

We'll keep this issue open to try and debug the App Check issues.

@sergio-dd
Copy link

Hello @harrisonlo how are you?
I also use recaptcha enterprise, I'm having a lot of access errors, real users who receive 403 forbidden when trying to access my site, funny thing is, the error occurs on Wi-Fi, but if I connect to 4G internet on my cell phone, it works normally, do you have any recommendations? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants