[ ] Checked the logs and uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.
I’m submitting a…
[x] Regression (a behavior that stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[ ] Documentation issue or request
Current behavior
Starting from yesterday, something has changed in webhook contents. Most noticeable thing is that the body JSON is coming in a formatted way and contain newlines. Because of this and maybe other changes, the request signature validation is broken.
Yes, we are doing the same logic for constructing the signature. Nothing has changed on our side there for more than 3 years.
Here is how we were always doing it in Nodejs:
let signature = crypto.createHash('sha256').update(JSON.stringify(req.body) + process.env.SQUIDEX_SECRET).digest('base64');
In fact, when trying to calculate the hash manually in a separate script it also does not match with the one coming with the request.
Is it possible that after generating the signature the actual response body is somehow altered before being sent?
Actually we tried to provide the JSON manually as it is seen in the Rule logs with the same formatting, so that there is no request body parser applied to it. Also tried with raw data, and still the string is not matching the signature. My guess is that webhook sends slightly different data in the body than it uses during signature calculation.
Turning off the validation right now, as no solution found.
Have you changed the order or are you still doing things in the same order? I will see, whether I can cover it in my integration tests, perhaps I will find an issue.
@mappr Sebastian is right, it would be more stable to use the response string directly. You can do so by using req.rawBody.toString() if you are using NodeJS. Usually, the bodyParser turns it into a buffer, therefore you need to use the toString() method. This makes the hash calculation working again.