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

Ouverte
#2,067 2 commentaires 0 réactions 1 personne assignée Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@AmyScript y travaille déjà.

Depuis le 20/11/2026.

  • #2075 par @tony1233200 — fermée sans fusion

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
57/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Python
Étoiles
4k
Forks
874
Merge moyen
13 h 22 min
PR mergées (30 j)
64

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de slackapi/python-slack-sdk

Toutes les issues de slackapi/python-slack-sdk

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.