Skip to content

SignatureVerifier.is_valid raises instead of returning False for a malformed timestamp, signature or body #2067

Open

Description

@ratomirjovanovic

SignatureVerifier.is_valid() (and is_valid_request()) returns False for missing values, but three kinds of malformed input from the request raise instead:

from slack_sdk.signature import SignatureVerifier

v = SignatureVerifier("secret")
v.is_valid("body", "abc", "v0=aa")              # ValueError: invalid literal for int() with base 10: 'abc'
v.is_valid("body", "1531420618", "v0=é")   # TypeError: comparing strings with non-ASCII characters is not supported
v.is_valid(b"\xff\xfe", "1531420618", "v0=aa")  # UnicodeDecodeError (body is decoded before the signature is compared)

(For the last two, use a timestamp inside the 5 minute window.)

The timestamp and signature come straight from the X-Slack-Request-Timestamp and X-Slack-Signature headers, so anyone can send them. In bolt-python, RequestVerification.process calls is_valid directly, so such a request does not get the 401 invalid request response; the exception goes through the generic error path in App.dispatch and ends as a 500.

It is not a way around the check, the request is still rejected. But the method is documented as "Verifies if the given signature is valid" and test_is_valid_none already expects False for missing values, so returning False for these seems to be the intended contract.

I have a small fix with tests (catch the three cases in is_valid and return False). Happy to open a PR if that works for you.

Checked on main at b935494.

Activity

  1. added
    bug
    on Nov 20, 2026
  2. added this to the 3.48.1 milestone on Nov 20, 2026
  3. self-assigned this
    on Nov 20, 2026
  4. AmyScript commented on Nov 20, 2026

    @AmyScript

    Hi @ratomirjovanovic, thanks for the clear write-up and reproduction steps! 🙌

    Confirmed: all three cases raise instead of returning False. Agreed that returning False is the intended contract, especially since test_is_valid_none already sets that expectation and bolt-python should respond with a 401 rather than a 500 here.

    While reproducing, I found a few more header values that hit the same paths:

    • Empty timestamp: "" → ValueError
    • Non-integer timestamp: "1531420618.5" → ValueError
    • Timestamp over 4300 digits → ValueError (Python's int string conversion limit)
    • Signature passed as bytes → TypeError

    There's already an open PR for this in #2075, so to avoid two competing fixes, let's consolidate there. It takes the approach we'd want: targeted handling in is_valid for each failure point, with generate_signature left unchanged, and tests using the existing mock clock, including a case through is_valid_request. You're very welcome to review it there.

    We're targeting this for the 3.48.1 patch release. Thanks again!

  5. ratomirjovanovic commented on Nov 28, 2026

    @ratomirjovanovic
    Author

    If #2075 isn't coming back, I can open a small PR for the non-ASCII signature and non-UTF-8 body cases. #1968 already handles the non-integer timestamp.

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

Metadata

Metadata

Assignees

Labels

bugsecuritysemver:patch

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions