This repository was archived by the owner on Jul 23, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed
Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import debugFactory from 'debug';
22import getRawBody from 'raw-body' ;
33import querystring from 'querystring' ;
44import crypto from 'crypto' ;
5+ import timingSafeCompare from 'tsscmp' ;
56import { packageIdentifier } from './util' ;
67
78const 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 ;
You can’t perform that action at this time.
0 commit comments