fix(sms): validate inbound Twilio webhook signatures#6606
Closed
MestreY0d4-Uninter wants to merge 2 commits into
Closed
fix(sms): validate inbound Twilio webhook signatures#6606MestreY0d4-Uninter wants to merge 2 commits into
MestreY0d4-Uninter wants to merge 2 commits into
Conversation
Contributor
Author
|
Atualizei a branch com dois ajustes em cima da review:
Também adicionei cobertura para URL externa reconstruída / forwarded headers. Validação local:
Resultado: 32 passed |
Contributor
Author
|
Changes da review já aplicados na branch e revalidados localmente. Status atual: pronta para re-review. O que ficou coberto:
Observação: os checks vermelhos que restam continuam aparecendo em áreas amplas do repo fora do escopo deste diff; não estou tratando isso, isoladamente, como regressão desta PR. |
Contributor
|
This vulnerability has been fixed in PR #7933 (merged). Thanks for the contribution, @MestreY0d4-Uninter. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
X-Twilio-Signaturerequests with a fast 403 responseProblem
The SMS adapter accepted any POST to
/webhooks/twilioand immediately scheduledhandle_message()without verifying that the request actually came from Twilio.That meant anyone who knew the webhook URL could forge inbound SMS payloads and impersonate arbitrary phone numbers.
Investigation
Validated in a clean isolated worktree from current
origin/main:gateway/platforms/sms.py::_handle_webhook()parsed form data and queued work without checkingX-Twilio-SignatureRequestValidator.validate(url, post_vars, signature))Fix
_validate_twilio_signature()toSmsAdapterX-Twilio-Signatureimmediately after parsing the form bodyValidation
Ran locally in the isolated worktree:
pytest tests/gateway/test_sms.py -q -o addopts=python -m py_compile gateway/platforms/sms.py tests/gateway/test_sms.pyResult:
29 passedTests added