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

未关闭
#2,067 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@AmyScript 已经在做这个了。

开始于 2026年11月20日。

  • #2075 来自 @tony1233200 —— 已关闭,未合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
57/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

Start with SignatureVerifier.is_valid() and its existing tests, including test_is_valid_none; the issue names the malformed timestamp, signature, and body cases. Confirm each currently raises, then make sure the tests expect False for all three while preserving the missing-value behavior.

由索引模型根据 Issue 内容生成。

描述

bug security semver:patch

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.

主要语言
Python
星标
4k
派生
874
平均合并
13 小时 22 分钟
30 天内合并 PR
64

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

slackapi/python-slack-sdk 的其他 Issue

查看 slackapi/python-slack-sdk 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。