Skip to content
This repository was archived by the owner on Jul 23, 2019. It is now read-only.

Commit 1cb466a

Browse files
authored
Merge pull request #71 from billdybas/use-timing-safe-compare
Use Timing Safe Compare
2 parents ced8f2a + 3bbcb9b commit 1cb466a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"lodash.isplainobject": "^4.0.6",
3030
"lodash.isregexp": "^4.0.1",
3131
"lodash.isstring": "^4.0.1",
32-
"raw-body": "^2.3.3"
32+
"raw-body": "^2.3.3",
33+
"tsscmp": "^1.0.6"
3334
},
3435
"devDependencies": {
3536
"babel-cli": "^6.26.0",

src/http-handler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import debugFactory from 'debug';
22
import getRawBody from 'raw-body';
33
import querystring from 'querystring';
44
import crypto from 'crypto';
5+
import timingSafeCompare from 'tsscmp';
56
import { packageIdentifier } from './util';
67

78
const debug = debugFactory('@slack/interactive-messages:http-handler');
@@ -80,7 +81,7 @@ export function createHTTPHandler(adapter) {
8081
const [version, hash] = signature.split('=');
8182
hmac.update(`${version}:${ts}:${body}`);
8283

83-
if (hash !== hmac.digest('hex')) {
84+
if (!timingSafeCompare(hash, hmac.digest('hex'))) {
8485
debug('request signature is not valid');
8586
const error = new Error('Slack request signing verification failed');
8687
error.code = errorCodes.SIGNATURE_VERIFICATION_FAILURE;

0 commit comments

Comments
 (0)