简体   繁体   中英

Can't authenticate Twilio Authy webhook callbacks

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!

Twilio developer evangelist here.

It looks to me as though you've found the Authy webhooks session that you can subscribe to in order to get updated about various parts of your users' usage of the Authy APIs.

In order to get webhooks for OneTouch push notifications, you should set your webhook URL in the Twilio console under the push notifications settings for the Authy application.

导航到 Twilio 控制台,然后转到 Authy 部分,选择您的 Authy 应用程序,然后打开 Push Authentication 设置。在那里你会找到 webhook Endpoint/URL 的输入,这是你设置 webhook URL 的地方。

Once you have set the webhook URL, you will find webhook events coming through to your application for push authentication approvals and denials. Those requests will also come with the X-Authy-Signature-Nonce and X-Authy-Signature headers and you will be able to re-create the signature using the method explained here .

Sorry that got confusing, hopefully this clears it up for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM