Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autentication hash fails on long request bodys #1045

Open
vdiorio opened this issue Mar 18, 2022 · 2 comments
Open

Autentication hash fails on long request bodys #1045

vdiorio opened this issue Mar 18, 2022 · 2 comments

Comments

@vdiorio
Copy link

vdiorio commented Mar 18, 2022

What happened

I'm developing an app for a company that sends really long messages on channels. I'm generating autentication hashes following the step-by-step process in documentation. It works fine on small messages, but fails on long request bodys.

Expected behavior

Autentication tokens should work on any size of request.

Steps to reproduce

Just try to hash a long request.
Here's an exemple: https://pastebin.com/LXph5eD6

@brainexe
Copy link
Contributor

mhm, I tested a similar sized response and it worked quite good. As we don't have your signing key it's a bit hard to reproduce your example 🛡️

But could you post the code where you're validating the signature based the incoming request...maybe there is something odd.

@vdiorio
Copy link
Author

vdiorio commented Apr 4, 2022

    const signature = 'v0:' + timestamps + ':' + JSON.stringify(req.body);
    const key = 'v0=' + crypto.createHmac('sha256', process.env.SLACK_SECRET).update(signature).digest("hex");
    if (SLACK_SIGNATURE !== key) return res.status(401).json({key});

The key this code generates is different from the header signature slack sends.
It works fine on small comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants