Skip to content

fix(sms): redact reflected credentials from Twilio API error text - #120170

Closed
Monkey-wusky wants to merge 2 commits into
openclaw:mainfrom
Monkey-wusky:fix/sms-twilio-redact-credentials
Closed

Monkey-wusky wants to merge 2 commits into
openclaw:mainfrom
Monkey-wusky:fix/sms-twilio-redact-credentials

Conversation

@Monkey-wusky

@Monkey-wusky Monkey-wusky commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where SMS/Twilio users could have Basic Auth credentials exposed in surfaced API errors when an upstream service or proxy reflected the request's Authorization: Basic header in its response body.

The SMS extension sends Authorization: Basic base64(accountSid:authToken) on every Twilio API request (send, lookup, list, messaging-service retrieval). The error response reader (readTwilioApiResponseText) returned the raw body text without redaction, which then entered TwilioSmsApiError.message (for non-JSON errors) and TwilioSmsApiError.responseText (for all errors).

Why This Change Was Made

The shared readTwilioApiResponseText error path now applies redactToolPayloadText before returning remote text to the TwilioSmsApiError boundary. This protects every send, lookup, and list request that uses the shared response path without changing status handling, retries, or error types.

The pattern mirrors:

  • #119965 (googlechat) — same one-line redactToolPayloadText call in the error response reader
  • #119536 (discord) — same redact boundary
  • #117304 (voice-call) — fixed Twilio/Telnyx/Plivo credential leaks in a different extension; SMS was not covered by that PR

User Impact

Twilio SMS API failures retain useful status, error codes, and provider details without returning reflected request credentials to users, agents, logs, or downstream error consumers.

Evidence

Real behavior proof

$ node --import tsx scripts/proofs/sms-twilio-redact-proof.ts
=== RAW TEXT (as returned by proxy) ===
<html>
<h1>502 Bad Gateway</h1>
<p>upstream proxy error</p>
<!-- reflected: Authorization: Basic QUMwMTIzNDU2Nzg5YWJjZGVm... -->
</html>

=== REDACTED TEXT (after redactToolPayloadText) ===
<html>
<h1>502 Bad Gateway</h1>
<p>upstream proxy error</p>
<!-- reflected: Authorization: Basic *** -->
</html>

=== VERDICT ===
Token leaked:         PASS
Auth header label ok: PASS
Error detail kept:    PASS
Overall:              PASS

The proof script is at scripts/proofs/sms-twilio-redact-proof.ts (to be removed before merge).

Test coverage

Added 3 tests to extensions/sms/src/twilio.test.ts:

  • Non-JSON error body with reflected Authorization: Basic <token> — verifies token is absent from Error.message while provider detail and header label survive
  • JSON error body with reflected token — verifies token is absent from responseText while Twilio error code survives
  • Clean JSON error without credential material — verifies structured error parsing (twilioCode, httpStatus, detail message) is preserved unchanged

All 28 tests pass (25 existing + 3 new):

  • npx vitest run extensions/sms/src/twilio.test.ts — 28 passed, 0 failed
  • git diff --check passed
  • No pnpm-lock.yaml changes

AI-assisted: developed with Claude; the author reviewed the complete change and its shared error-response behavior.

The Twilio SMS error response reader now applies redactToolPayloadText
before returning error body text to the TwilioSmsApiError boundary.
This protects against upstream proxies that may reflect the request's
Authorization: Basic header in error response bodies.

The shared readTwilioApiResponseText path covers every send, lookup,
and list request the SMS extension makes to the Twilio API.
@openclaw-barnacle openclaw-barnacle Bot added channel: sms Channel integration: sms size: S triage: blank-template Candidate: PR template appears mostly untouched. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 7, 2026
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 7, 2026
@vincentkoc vincentkoc added the close:superseded PR close reason label Aug 7, 2026
@vincentkoc vincentkoc self-assigned this Aug 7, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Thanks @Monkey-wusky. This independently identifies a real Twilio error-body credential exposure, but #119963 is the canonical fix. It predates this PR, protects the same surfaced message and responseText fields, and has stronger exact-head proof through a real loopback transport that reflects the production-built Basic Authorization header. Its exact head is fully green and ClawSweeper found no actionable issue.

This PR reaches the same user-visible outcome, while still carrying a temporary proof script marked for removal and duplicating the canonical regression coverage. Closing as superseded so we keep one landing path. Thank you for independently validating the bug and fix direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: sms Channel integration: sms close:superseded PR close reason scripts Repository scripts size: S triage: blank-template Candidate: PR template appears mostly untouched.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants