-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Request blocked or forbidden #60
Comments
If anyone has any corrections, additional information, or suggestions, please comment here. I've been communicating with Troy Hunt of haveibeenpwned.com in an attempt to determine a way forward, but I've gotten nowhere. |
Any more updates on this? I think we're just going to have to move away from the library all together as it seems absolutely fine if I use Fetch/Axios with a custom UA. |
Can you provide more details around exactly what you're doing that works? Are you running in Node.js or a browser? I can add an option to allow setting your own UA, but that is only temporarily side-stepping the problem (you may get blocked again, requiring you to change the UA, which is actually against Troy's acceptable use policy) and would only currently work in Node.js environments (as stated multiple times). |
I wish I could provide more information other than the fact all I'm doing is setting a custom UA. The UA is specific to our product and Troy is aware as we've been in contact with him before regarding this issue and before we integrated it into our platform. If we set the UA, it works, if we don't or use the default in your library, it doesn't work. I think the option to add your own UA is a useful feature as it's explained on his website that the UA should describe the service using it. I wish I could on the browser side of things but I have no ideas other than discussing that with Troy? |
OK, so you're in Node.js. Which version of As for the browser, what do we do? As I see it, there are only 2 options: Troy relaxes the new rules to allow browser UA's again, or we drop browser support from the library - which would be a bummer. 🙁 |
I just emailed Troy one more time in hopes of getting an answer with regards to the browser. We need to establish if browser UAs are intentionally and permanently blocked for the |
Troy responded and confirmed browser UAs are intentionally blocked. This policy seems to be currently applied the
@kierxn If you can tell me which version of
|
I've exposed some additional options to help alleviate these problems (released in |
haveibeenpwned.com recently (mid-January, 2019) adjusted their API abuse prevention policies and now many API consumers are being blocked. The primary target appears to be the
User-Agent
string in the API request, but there is more to the story as multiple users with the same UA can receive different results for the same request (e.g. one blocked, one succeeds). IP address and/or region may also be playing a part. It also seems the rules are most strict surrounding thebreachedaccount
endpoint.The requirements in the haveibeenpwned API documentation state that a
User-Agent
must be included in all API requests to avoid being blocked.hibp
does this this outside of the browser (i.e. Node.js), but it is not currently possible forhibp
to set its ownUser-Agent
when running in the browser because haveibeenpwned.com does not include it in theAccess-Control-Allow-Headers
header field of a preflight response. (Try it out on test-cors.org and you will see it fail. See MDN's CORS page for more details.) Furthermore, some browsers (e.g. Chrome) will even block requests client-side that attempt to modify the UA as they consider it unsafe, so the problem would still exist for some users even if the CORS rules were adjusted to allow it.Currently, it seems like most/all browser UA strings are being blocked outright. The test link in the API documentation fails on every browser I've tested from various devices, locations, and networks.
I don't know if this is intentional and browser support needs to be dropped fromEdit (2019-01-25): Confirmed with Troy that this is intentional.hibp
or if the abuse prevention rules are too strict and need adjusted.In versions of
hibp
prior to 7.4.0, the error would appear as such:This is because the haveibeenpwned.com API documentation states a 403 Forbidden response would occur in the case of a missing
User-Agent
header field in the request. However, this is not the only case where they respond with 403 Forbidden now, so that error message is no longer accurate.hibp
version 7.4.0 includes a more specific error message, indicating if you are being blocked by haveibeenpwned.com when a Cloudflare Ray ID is present in the response header:If no Cloudflare Ray ID is present, you will get a more generalized error:
Related issues:
#38
wKovacs64/pwned#27
wKovacs64/pwned#30
The text was updated successfully, but these errors were encountered: