node-slack-sdk icon indicating copy to clipboard operation
node-slack-sdk copied to clipboard

Error when Events API try to verify

Open TeoDiaz opened this issue 6 years ago • 12 comments

Description

I'm having an issue when I try to verify with the Request URL in Events API.

Error: Slack request signing verification failed
    at verifyRequestSignature (./node_modules/@slack/events-api/dist/http-handler.js:47:29)
    at ./node_modules/@slack/events-api/dist/http-handler.js:170:17
    at processTicksAndRejections (internal/process/task_queues.js:94:5) {
  code: 'SLACKHTTPHANDLER_REQUEST_SIGNATURE_VERIFICATION_FAILURE'
}

Finally, debuggin the code I found that fails in

    if (!tsscmp_1.default(hash, hmac.digest('hex'))) {
        debug('request signature is not valid');
        throw errorWithCode(new Error('Slack request signing verification failed'), ErrorCode.SignatureVerificationFailure);
    }

I tried to change port, re-build the app, change the Signing Secret, but nothing happen. So I comment this lines, and the verification was succeed.

I think something is wrong with this lines.

There's no related issues with the verify request.

What type of issue is this? (place an x in one of the [ ])

  • [X] bug
  • [ ] enhancement (feature request)
  • [ ] question
  • [ ] documentation related
  • [ ] testing related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Packages:

Select all that apply:

  • [ ] @slack/web-api
  • [x] @slack/events-api
  • [ ] @slack/interactive-messages
  • [ ] @slack/rtm-api
  • [ ] @slack/webhooks
  • [ ] I don't know

Reproducible in:

package version: 2.3.2

node version: v12.15.0

OS version(s): macOS catalina 10.15.3

Steps to reproduce:

  1. Open a ngrok port
  2. Use ./node_modules/.bin/slack-verify --secret <Signing Secret>
  3. Use ngrok url to verify

Expected result:

Work the verification as expected, not removing those lines

Actual result:

Error: Slack request signing verification failed
    at verifyRequestSignature (./node_modules/@slack/events-api/dist/http-handler.js:47:29)
    at ./node_modules/@slack/events-api/dist/http-handler.js:170:17
    at processTicksAndRejections (internal/process/task_queues.js:94:5) {
  code: 'SLACKHTTPHANDLER_REQUEST_SIGNATURE_VERIFICATION_FAILURE'
}

Attachments:

Alt Text

TeoDiaz avatar Mar 11 '20 00:03 TeoDiaz

@TeoDiaz I'm sorry for our late reply here. I tried to reproduce your issue but I haven't managed to see the same situation yet. It works without any issues for me. Are you still seeing the same issue?

seratch avatar Mar 26 '20 08:03 seratch

I'm seeing this exact same error in the same location.

package version: 2.3.2 node version: v12.13.1 OS: Windows 10 Home 10.0.18363

GlitchedMythos avatar Apr 02 '20 01:04 GlitchedMythos

Seeing same issue here. Some events seem to pass, and some fail.

michaeldever avatar Jun 19 '20 16:06 michaeldever

{
  token: 'TOKEN',
  team_id: 'ID',
  api_app_id: 'ID',
  event: {
    type: 'app_home_opened',
    user: 'ID',
    channel: 'ID',
    tab: 'messages',
    event_ts: '1592584479.197334'
  },
  type: 'event_callback',
  event_id: 'ID,
  event_time: 1592584479
}

Passes

{
  token: 'TOKEN',
  team_id: 'ID',
  api_app_id: 'ID',
  event: {
    type: 'app_home_opened',
    user: 'ID',
    channel: 'ID',
    tab: 'home',
    view: {
      id: 'ID',
      team_id: 'ID',
      type: 'home',
      blocks: [Array],
      private_metadata: '',
      callback_id: '',
      state: [Object],
      hash: 'hash,
      title: [Object],
      clear_on_close: false,
      notify_on_close: false,
      close: null,
      submit: null,
      previous_view_id: null,
      root_view_id: 'ID',
      app_id: 'ID',
      external_id: '',
      app_installed_team_id: 'ID',
      bot_id: 'ID'
    },
    event_ts: '1592584487.599565'
  },
  type: 'event_callback',
  event_id: 'ID',
  event_time: 1592584487
}

Fails

michaeldever avatar Jun 19 '20 16:06 michaeldever

I'm facing the exact issue. Every time I mention the app by copy-paste (without typing @bot-name manually from keyboard) the validation fails at slack side. I;ve tried with all combinations of removing CR, LF, NBSP from body, adding it, removing etc and all of it fails validation. I've been on email with slack representative for almost a week and person hasn't been able to replicate the issue.

Image attachment clearly shows how it passes when I type the @app-name whereas fails while I copy-paste it. Image 2

abhishekumesh avatar Jul 08 '20 06:07 abhishekumesh

@abhishekumesh what is your environment? Node version, operating system, package version.

stevengill avatar Jul 08 '20 16:07 stevengill

I am having the same issue when using the 'validate-slack-request' npm package. Works when I want to validate Slash Commands and Interactive Components, but fails for my Events API (message events)

Node v 12.16.3 hosted on Heroku

chumbalayaa avatar Nov 10 '20 19:11 chumbalayaa

I'm having the exact same issue. However I don't use any external librairy, I wrote my own code to validate slack event following the documentation. The code is working fine for slack commands, tokens revoked events, app uninstalled events, and first "app_openned" events. But not working for any "app_openned" events that contains a "view" objet, as mentionned by @michaeldever Any help will be truly appreciated :(

GeraudWilling avatar Nov 18 '20 22:11 GeraudWilling

Hey folks, the only way I can think of for this error to occur on some events and not others is if Slack is sending an invalid request signature in the HTTP headers on some subset of events. Unfortunately, that means this isn't an issue in this library, but really an issue in the Slack Platform.

I'd be happy to investigate this issue with the rest of the Platform engineering team, but we cannot gather any specific request logs nor share that info over GitHub. The best way to get this issue resolved would be to send an email to [email protected] with your App ID, your Team ID, and any other relevant info. Our support team will pick up the ticket quickly. Feel free to mention this issue URL to save yourself some typing. If the support agent finds it helpful to work with the maintainers of this library, they know how to reach the maintainers of this project and give us access to some logs 😄 .

aoberoi avatar Nov 21 '20 01:11 aoberoi

Given that we don't think this is an issue in the SDK, I'm going to close. Feel free to comment here if you do find something in the SDK that seems wrong, and we will respond and reopen as necessary.

aoberoi avatar Nov 21 '20 01:11 aoberoi

resolved this issue on my end just now. I was getting this exact error when I created a new separate slack app for testing. I did change the signing secret but had forgotten to change the client id and client secret for the new app. updating those resolved the issue.

ahmad-wzk avatar Dec 24 '22 22:12 ahmad-wzk

I'm still facing this issue, failing to verify the file_share message event, while being able to verify every other event I need. Is there any additional information about this? Did someone figure it out (besides the reason being using the wrong ID and secret)?

ynaftali-island avatar Aug 05 '25 13:08 ynaftali-island