Skip to content

fix: return 401 on malformed signature headers - #1631

Draft
WilliamBergamin wants to merge 1 commit into
mainfrom
fix/malformed-signature-headers
Draft

WilliamBergamin wants to merge 1 commit into
mainfrom
fix/malformed-signature-headers

Conversation

@WilliamBergamin

Copy link
Copy Markdown
Contributor

Summary

This pull request makes RequestVerification and AsyncRequestVerification return 401 when the signature headers are malformed, instead of raising.

  • A non-numeric x-slack-request-timestamp made int(timestamp) raise ValueError, and a non-ASCII x-slack-signature made hmac.compare_digest raise TypeError. dispatch turned both into a 500.
  • Both now count as an invalid signature, so the request is rejected like any other unsigned one.
  • Split out of fix: parse request bodies after RequestVerification #1630, which it doesn't depend on.

Testing

Send a request with x-slack-request-timestamp: abc to a running app (for example curl -X POST localhost:3000/slack/events -H 'x-slack-request-timestamp: abc' -H 'x-slack-signature: v0=x' -d 'payload={}') and confirm it returns 401 instead of 500.

Category

  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Document pages under /docs
  • Others

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run ./scripts/install_all_and_run_tests.sh after making the changes.

🤖 Generated with Claude Code

A non-numeric timestamp or a non-ASCII signature made the verifier raise,
so the request ended as a 500 instead of being rejected.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.58%. Comparing base (16056a4) to head (668e1f9).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1631   +/-   ##
=======================================
  Coverage   91.57%   91.58%           
=======================================
  Files         228      228           
  Lines        7287     7293    +6     
=======================================
+ Hits         6673     6679    +6     
  Misses        614      614           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant