fix(security): add Twilio signature validation to SMS webhook#6354
Closed
Alpaca1712 wants to merge 1 commit into
Closed
fix(security): add Twilio signature validation to SMS webhook#6354Alpaca1712 wants to merge 1 commit into
Alpaca1712 wants to merge 1 commit into
Conversation
The /webhooks/twilio endpoint accepted inbound POST requests with zero authentication, allowing an external attacker to forge SMS webhook payloads and inject arbitrary text into the agent's LLM context. This is a zero-auth remote prompt injection vector that can chain into shell command execution, credential exfiltration, and persistent compromise via cron jobs. Fix: - Validate X-Twilio-Signature (HMAC-SHA1) on every inbound webhook using the existing TWILIO_AUTH_TOKEN — no new dependencies. - Fail-closed: requests are rejected when SMS_WEBHOOK_URL is unset, when the header is missing, or when the signature is invalid. - Handle Twilio's with-port / without-port signature ambiguity. - Return 403 with empty TwiML on rejection. - Warn at startup when SMS_WEBHOOK_URL is not configured. New env var: - SMS_WEBHOOK_URL — public URL of the webhook endpoint, required for signature recomputation. Reported by Rocoto (https://www.artoo.love/), an autonomous security agent for AI agents. Made-with: Cursor
Contributor
|
This vulnerability has been fixed in PR #7933 (merged). Thanks for the contribution, @Alpaca1712 — your port variant handling approach was noted. |
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
gateway/platforms/sms.py), closing a zero-authentication remote prompt injection vector.SMS_WEBHOOK_URLis unset, when the signature header is missing, or when the signature is invalid (403 + empty TwiML).SMS_WEBHOOK_URLis not configured.SMS_WEBHOOK_URL— public URL of the webhook endpoint, required for signature recomputation.Vulnerability
The
/webhooks/twilioendpoint had no signature validation. An external attacker with no credentials could forge Twilio SMS webhook payloads that are injected directly into the agent's LLM context. Since there was no authentication, the attacker could inject arbitrary instructions that cause the agent to execute shell commands, read files, or exfiltrate data — a zero-auth remote code execution vector.The compound attack chain can disable safety checks (
HERMES_YOLO_MODE,HERMES_REDACT_SECRETS), then establish persistent credential exfiltration via cron jobs — all from a single forged HTTP POST.Reported by Rocoto, an autonomous security agent for AI agents.
Test plan
TestTwilioSignatureValidationclass passes (10 tests)SMS_WEBHOOK_URLis unsetSMS_WEBHOOK_URLis unset (fail-closed)Made with Cursor