I am trying to set up webhooks for Authy OneTouch push authentication. I manage to successfully register to one_touch_request_responded
events, save the webhook signing key from the subscription call, but I have still not managed to verify the requests: any attacker could forge fake requests and easily bypass the 2FA check.
The API documentation is quite confusing to me, given the callback requests don't match the format mentioned (especially they don't have the X-Authy-Signature
header), and only have the following headers:
{
host: 'XXX.ngrok.io',
'user-agent': 'Authy-api-webhooks/1.0',
'content-length': '2211',
'accept-encoding': 'gzip',
'content-type': 'application/json',
'x-forwarded-for': '3.89.35.175',
'x-forwarded-proto': 'http'
}
I have also tried to verify the signature of the JWT token, still to no avail (incoming POST
request: {"body":"a_jwt_token"}
): I alway get an invalid signature (same using https://jwt.io/).
const jwt = require("jsonwebtoken");
jwt.verify(req.body.body, Buffer.from(MY_SECRET_KEY, "base64"), { algorithm: ["HS256"] });
What is the proper way of checking the authenticity of the webhook POST callbacks?
Thanks!