diff --git a/lib/webhooks/webhooks.js b/lib/webhooks/webhooks.js index 7587a8a0bf..d95e96c62b 100644 --- a/lib/webhooks/webhooks.js +++ b/lib/webhooks/webhooks.js @@ -47,6 +47,7 @@ function getExpectedBodyHash(body) { @returns {boolean} - valid */ function validateRequest(authToken, twilioHeader, url, params) { + twilioHeader = twilioHeader || ''; var expectedSignature = getExpectedTwilioSignature(authToken, url, params); return scmp(Buffer.from(twilioHeader), Buffer.from(expectedSignature)); } diff --git a/spec/validation.spec.js b/spec/validation.spec.js index 0863190184..b1a63be2a6 100644 --- a/spec/validation.spec.js +++ b/spec/validation.spec.js @@ -69,6 +69,12 @@ describe('Request validation', () => { expect(isValid).toBeFalsy(); }); + + it('should fail when signature undefined', () => { + const isValid = validateRequest(token, undefined, requestUrl, defaultParams); + + expect(isValid).toBeFalsy(); + }); }); describe('Request validation middleware', () => {