fix(webhooks): require v1 version prefix when verifying signatures
SH
2d ago+38+38+01234567890123456789-1-1-0123456789
Webhooks.verify split each signature entry on , and verified the digest without checking that the version prefix is v1, so headers such as v0,<hmac> or v2,<hmac> were accepted.
Changes:
- Require
parts[0] == "v1"alongsidelen(parts) == 2inresend/webhooks/_webhooks.py. - Add unit tests in
tests/webhooks_test.pyverifying non-v1signatures are rejected while mixed headers containing a validv1signature succeed.
Verification:
flake8 --max-line-length=130 ./resend/mypy --ignore-missing-imports resend/ examples/ tests/webhooks_test.py(160 files, 0 issues)pytest --doctest-modules tests(879 passed)
Summary by cubic
Fixes webhook signature verification so only v1-prefixed signatures are accepted. Previously, headers like v0,<hmac> or v2,<hmac> were treated as valid because the version prefix was never checked.
Bug Fixes
- Require the version prefix to be exactly
v1when parsing signature entries. - Add tests covering rejection of
v0/v2signatures and acceptance of mixed headers containing a validv1signature.