Skip to content

fix(security): add Twilio webhook signature validation [HIGH]#4688

Closed
Joshua-Medvinsky wants to merge 1 commit into
NousResearch:mainfrom
Joshua-Medvinsky:fix/twilio-webhook-signature
Closed

fix(security): add Twilio webhook signature validation [HIGH]#4688
Joshua-Medvinsky wants to merge 1 commit into
NousResearch:mainfrom
Joshua-Medvinsky:fix/twilio-webhook-signature

Conversation

@Joshua-Medvinsky

Copy link
Copy Markdown

Security Finding: Twilio Webhook Authentication Bypass

Severity: HIGH
Reported by: FailSafe Security Researcher
Component: gateway/platforms/sms.py_handle_webhook()

Description

The Twilio webhook endpoint at /webhooks/twilio does not validate the X-Twilio-Signature header. The TWILIO_AUTH_TOKEN is used for outbound API auth but never for inbound webhook verification. Any network-reachable attacker who discovers the webhook URL can forge requests with arbitrary From numbers, bypassing SMS_ALLOWED_USERS and impersonating authorized users.

The webhook binds to 0.0.0.0 with no signature validation or IP-based restriction. Twilio's RequestValidator is not imported or referenced anywhere in the file.

Fix

  • Add _verify_twilio_signature() using Twilio's official RequestValidator to validate every inbound request
  • Requests with invalid or missing signatures are rejected with 403
  • Validation can be disabled via TWILIO_VALIDATE_SIGNATURES=false for local development
  • Graceful fallback if twilio package is not installed (logs warning, allows request)

Test plan

  • Verify legitimate Twilio webhooks are accepted (valid signature)
  • Verify forged requests without signature are rejected (403)
  • Verify TWILIO_VALIDATE_SIGNATURES=false disables validation for dev

The Twilio webhook handler at /webhooks/twilio accepted inbound POST
requests without verifying the X-Twilio-Signature header. An attacker
who discovers the webhook URL can forge requests with arbitrary From
numbers, bypassing the SMS_ALLOWED_USERS allowlist and impersonating
authorized users.

Add _verify_twilio_signature() using Twilio's RequestValidator to
validate every inbound request against the auth token. Requests with
invalid or missing signatures are rejected with 403. Validation can
be disabled via TWILIO_VALIDATE_SIGNATURES=false for local development.

Reported-by: FailSafe Security Researcher
Co-Authored-By: Joshua Medvinsky <joshua-medvinsky@users.noreply.github.com>
@Joshua-Medvinsky

Copy link
Copy Markdown
Author

Hey @erosika @teknium1 — flagging for review. This is a security fix for missing Twilio webhook signature validation. Happy to discuss if you have questions.

@teknium1

Copy link
Copy Markdown
Contributor

This vulnerability has been fixed in PR #7933 (merged). Thanks for identifying and reporting the issue, @Joshua-Medvinsky — your PR was one of the first to flag this.

@teknium1 teknium1 closed this Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants