-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Securing FB Graph API Requests #1170
Securing FB Graph API Requests #1170
Conversation
…ret_proof parameter to every FB API call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job 💪 @ouadie-lahdioui,
I just have minor suggestions, all related to readability.
One more thing: Shouldn't be some tests there? At least for the new getAppSecretProof
method, and in case the app secret is required but not provided by the bot.
Keep on the good work 👍
docs/readme-facebook.md
Outdated
|
||
```javascript | ||
var controller = Botkit.facebookbot({ | ||
debug: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug
and log
are mandatory options.
Just for clarity purpose, I suggest not mentioning them in your example and just show required options (like tokens + app_secret) + the new app secret proof.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/Facebook.js
Outdated
@@ -851,6 +909,11 @@ function Facebookbot(configuration) { | |||
return 'sha1=' + hmac.digest('hex'); | |||
} | |||
|
|||
function getAppSecretProof(dataToHash, key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm probably missing the big picture, but is this method intended to be used somewhere else?
If not, I suggest to use more explicit parameter names, like:
function getAppSecretProof(access_token, app_secret) {
var hmac = crypto.createHmac('sha256', app_secret);
return hmac.update(access_token).digest('hex');
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally agree 👍
f38ac3f
to
e7de784
Compare
Remove package-lock.json generated by npm5+
e7de784
to
915d4f1
Compare
915d4f1
to
a566325
Compare
Thanks @htaidirt for the review.
|
Hello,
Almost every Graph API call requires an access token. Malicious developers can steal access tokens and use them to send spam from your bot with malicious software on a person's computer or a man in the middle attack.
To prevent that, Facebook recommend sending an app secret proof parameter to every API call.
This PR add a new configuration attribute
require_appsecret_proof
to enable sending the sha256 proof each call Botkit makes.Enjoy ✌️