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

Aperta
#2,067 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@AmyScript ci sta già lavorando.

Dal 20/11/2026.

  • #2075 di @tony1233200 — chiusa senza merge

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
4k
Fork
874
Merge medio
13h 22m
PR unite (30g)
64

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di slackapi/python-slack-sdk

Tutte le issue di slackapi/python-slack-sdk

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.