Google's Recaptcha has hostname
validation "baked-in". When a user submits a Recpatcha response, the domain from which the response was acquired is validated against the whitelist of domains you provided when you setup the Recaptcha.
However, if you're using Recaptcha with multiple domains you have the option of disabling Google's default hostname
validation and handling it yourself (https://developers.google.com/recaptcha/docs/domain_validation).
Google accompanies this with a prominent warning that not validating the hostname
for any given response opens you up to a security vulnerability. But considering how easy it is to spoof the hostname
, I don't see how this ever provided any degree of security enhancement.
A simple test proved to me just how easy it is to spoof the hostname
value that Google uses to validate the origin of the Recaptcha response:
$ sudo nano /etc/hosts
127.0.0.1 spoofedhostname.com
And then when I sent a test Recaptcha response the result I got back was as follows:
{
"success": true,
"challenge_ts": "2016-12-24T14:15:22Z",
"hostname": "spoofedhostname.com"
}
So Why Bother With Hostname Validation At All?
- Hostname validation is largely known to be useless considering how easy it is to spoof.
- This seems to have something to do with preventing an attacker from stealing your Recaptcha public key and then generating a bunch of valid Recaptcha responses, which they could store and then use when automating an attack on sensitive endpoints (
/login
,/reset-password
). Theoretically, this could be used in some sort of brute force attack, but it doesn't really make sense considering the response tokens expire after 1 min. And you would still need to manually solve all the Recaptchas, which you could simply do on the actual domain. And, again, they could easily just spoof your domain even if you are doinghostname
validation.
It just doesn't make any sense to me, but considering it's a Google product, I have to think that their security engineers know something that I don't.
What am I missing?