Skip to content

fix(sms): normalize Twilio RCS addresses - #102373

Merged
steipete merged 1 commit into
openclaw:mainfrom
clawSean:fix/sms-rcs-address-normalization
Jul 11, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
clawSean:fix/sms-rcs-address-normalization

Conversation

@clawSean

@clawSean clawSean commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Twilio RCS inbound messages can identify the consumer with an rcs:+E164 channel address. The SMS plugin treated that prefix as part of the phone number, which broke allowlist matching, canonical direct-session routing, and reply targeting.

Why This Change Was Made

Normalization now happens once at the Twilio webhook ingress boundary, after signature validation. The parser accepts bare E.164 SMS addresses and case-insensitive rcs: consumer addresses, rejects unrelated channel prefixes, and leaves the raw form values unchanged for Twilio's signature check.

The shared outbound/config phone normalizer is intentionally unchanged. Twilio uses rcs: to select channel semantics on outbound requests, so stripping it globally would alter fallback and sender behavior outside this inbound bug.

User Impact

Signed Twilio RCS webhooks now route the consumer to the same canonical SMS-owned direct session and sender match as the equivalent E.164 address, while SMS/MMS and outbound RCS behavior remain unchanged.

Evidence

  • Focused parser coverage: bare E.164, mixed-case rcs:, WhatsApp/unknown-prefix rejection.
  • Signed webhook regression: validation sees the original URL-encoded form; normalization occurs only after the signature succeeds.
  • Inbound routing assertions cover the canonical sender/session values.
  • Exact-head CI run 29133142322: success.
  • Workflow Sanity run 29133142302: success.
  • Fresh Codex autoreview: no accepted or actionable findings.
  • A contributor live replay independently demonstrated the observed signed RCS webhook and delivered reply behavior: fix(sms): normalize Twilio RCS addresses #102373 (comment)

No deployed exact-head Twilio webhook was used; the exact-head signed-handler integration test covers the security and routing boundary changed here.

AI-assisted.

@openclaw-barnacle openclaw-barnacle Bot added channel: sms Channel integration: sms size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 9, 2026
@clawsweeper

clawsweeper Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 10, 2026, 8:35 PM ET / July 11, 2026, 00:35 UTC.

Summary
The PR canonicalizes plain and rcs:+E164 Twilio inbound senders after signature validation and adds regression coverage for authorization, session routing, and reply targeting.

PR surface: Source +22, Tests +65. Total +87 across 4 files.

Reproducibility: yes. Current main deterministically mangles the observed rcs:+E164 sender into an invalid double-plus identity, and the supplied signed replay demonstrates the failing path and corrected outcome.

Review metrics: 1 noteworthy metric.

  • Accepted Twilio sender prefixes: 1 added (rcs:). The recognized form becomes the canonical identity used by allowlist authorization, direct-session routing, and reply delivery.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Next step before merge

  • [P2] No repair is needed; the exact current head is ready for ordinary maintainer landing review.

Security
Cleared: The exact-head diff preserves validation of the untouched signed webhook form and adds no dependency, workflow, credential, permission, package-resolution, or downloaded-code surface.

Review details

Best possible solution:

Merge the current narrow Twilio ingress fix with its focused tests, keeping generic SMS normalization, configuration, plugin APIs, and global channel-prefix ownership unchanged.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main deterministically mangles the observed rcs:+E164 sender into an invalid double-plus identity, and the supplied signed replay demonstrates the failing path and corrected outcome.

Is this the best way to solve the issue?

Yes. Twilio-specific parsing after raw signature verification is the narrowest maintainable fix and avoids creating a global RCS channel or broadening generic SMS target semantics.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b7d6291bfd6e.

Label changes

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is a focused, strongly reproduced SMS/Twilio bug fix with limited channel blast radius and complete exact-head proof.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The contributor demonstrated the after-fix behavior through the real signed webhook handler, live authorization configuration, canonical routing, and an actual delivered Twilio reply with private values redacted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The contributor demonstrated the after-fix behavior through the real signed webhook handler, live authorization configuration, canonical routing, and an actual delivered Twilio reply with private values redacted.
Evidence reviewed

PR surface:

Source +22, Tests +65. Total +87 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 23 1 +22
Tests 3 67 2 +65
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 90 3 +87

What I checked:

  • Current-main bug path: The SMS normalizer strips only sms: and twilio-sms:; an rcs:+E164 sender retains its prefix, gains an extra leading plus, and fails canonical E.164 validation. (extensions/sms/src/phone.ts:2, b7d6291bfd6e)
  • Correct owner boundary: The patch adds Twilio-specific parsing that accepts unprefixed phone values or case-insensitive rcs: values, rejects unrelated channel prefixes, and returns only validated canonical E.164. (extensions/sms/src/twilio.ts:225, 492cbce7109e)
  • Signature boundary preserved: The webhook verifies Twilio's untouched parsed form before building and canonicalizing the inbound message, so normalization cannot change signed input. (extensions/sms/src/webhook.ts:145, 492cbce7109e)
  • Canonical identity propagation: Inbound dispatch uses one normalized sender value for authorization, the direct peer, session routing, context identity, reply target, and durable outbound send. (extensions/sms/src/inbound.ts:94, b7d6291bfd6e)
  • Focused regression coverage: The exact head tests accepted and rejected Twilio sender forms, raw-form signature validation before canonicalization, and canonical route, context, and reply identities. (extensions/sms/src/twilio.test.ts:103, 492cbce7109e)
  • Real behavior proof: The contributor replayed a signed RCS webhook through the real handler with live allowlist configuration and delivered an actual Twilio reply to the canonical E.164 target; sensitive values were redacted. (extensions/sms/src/webhook.ts:120, 492cbce7109e)

Likely related people:

  • steipete: Current-main blame attributes the integrated SMS phone, Twilio webhook, and inbound routing paths to commit 92f3c35; the live PR is also assigned to this account and its head was refreshed after review. (role: recent SMS feature contributor and current reviewer; confidence: high; commits: 92f3c35ee94e; files: extensions/sms/src/phone.ts, extensions/sms/src/twilio.ts, extensions/sms/src/inbound.ts)
  • vincentkoc: Reachable release history shows commit e085fa1 introducing the complete SMS plugin tree into the latest shipped snapshot, making this account a secondary routing candidate for the bundled surface. (role: release integrator for the bundled SMS plugin; confidence: medium; commits: e085fa1a3ffd; files: extensions/sms/src/twilio.ts, extensions/sms/src/webhook.ts, extensions/sms/src/inbound.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (5 earlier review cycles)
  • reviewed 2026-07-09T03:05:50.938Z sha 07bcb0698bf7ec65d4375563516a6f755a5bb311 :: needs real behavior proof before merge. :: [P2] Fix the test return type before using delivery | [P3] Document the accepted RCS prefix
  • reviewed 2026-07-09T03:13:29.522Z sha 07bcb0698bf7ec65d4375563516a6f755a5bb311 :: needs real behavior proof before merge. :: [P2] Fix the test helper type before calling delivery | [P3] Document the accepted RCS prefix
  • reviewed 2026-07-09T04:11:21.654Z sha f22eb05d48a850646b64887d2c20c1625bae4f1c :: needs real behavior proof before merge. :: [P3] Document the accepted RCS prefix
  • reviewed 2026-07-10T16:09:33.675Z sha f22eb05d48a850646b64887d2c20c1625bae4f1c :: needs changes before merge. :: [P3] Document the accepted RCS prefix
  • reviewed 2026-07-11T00:08:16.215Z sha 36ada9972b7a45cfb210f64ac455fff533aae765 :: needs changes before merge. :: [P3] Remove the PR-owned changelog entry

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 9, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 9, 2026
@clawSean
clawSean force-pushed the fix/sms-rcs-address-normalization branch from 07bcb06 to f22eb05 Compare July 9, 2026 04:02
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. label Jul 9, 2026
@clawSean

Copy link
Copy Markdown
Contributor Author

Live proof: signed RCS webhook replay through the real handler + real Twilio reply delivery (2026-07-10)

Contributor proof for the status: 📣 needs proof label. Run on the exact PR head f22eb05d48, with the only working-tree addition being an untracked local harness spec (not part of this PR).

What the harness does

A local vitest spec boots the PR branch's real createSmsWebhookHandler on a real node:http server and POSTs a Twilio-shaped inbound RCS webhook that mirrors a real captured event: on 2026-06-07 a live Twilio RCS test-device reply (From=rcs:+E164, To=<RCS sender agent>) reached our production gateway webhook and was rejected as unauthorized by the pre-PR normalizer. The replay uses:

  • the live production SMS account config (real allowFrom allowlist, dmPolicy: "allowlist", real publicWebhookUrl) — not test fixtures
  • a genuine X-Twilio-Signature computed with the real auth token, so full signature validation runs (dangerouslyDisableSignatureValidation: false)
  • the real dispatchSmsInboundEvent pipeline, including the real resolveStableChannelMessageIngress authorization path; only the agent-dispatch runtime boundary is stubbed to observe routing/reply values
  • in live mode, the PR's actual reply delivery path (turn.delivery.deliver → sendSmsTextChunks → Twilio API), performing a real outbound send

Redacted transcript

[proof] OLD code normalized rcs:+1206•••••72 -> ++1206•••••72   (fails ^\+[1-9]\d{6,14}$ — the live 2026-06-07 rejection)
[proof] PR  code normalized rcs:+1206•••••72 -> +1206•••••72
[proof] POSTing signed RCS webhook (X-Twilio-Signature: UaT16y…)
[proof] webhook HTTP status: 200
[proof] route peer: {"kind":"direct","id":"+1206•••••72"}
[proof] context from: sms:+1206•••••72
[proof] context reply: {"to":"sms:+1206•••••72"}
[proof] durable reply target: +1206•••••72

Assertions verified: signature accepted; allowlist authorization allowed (pairing path unreached); direct-session peer, context from/reply, and durable delivery target all canonical E.164 with no ++ mangling.

Live outbound leg

With the live-send flag enabled, the same replay drove the PR's reply path end-to-end through the real Twilio API: message SM4a4cb7… was created at 2026-07-10 15:34:12 UTC to the normalized E.164 target and reached status delivered (verified via the Twilio Messages API; received on the recipient's handset).

SM4a4cb7… 2026-07-10 15:34:12 UTC outbound-api delivered from=+1858•…  to=+1206•…
🦞 Sean live proof for openclaw#102373: your RCS message shape (rcs:+E164) was normalized,
allowlist-authorized, and this reply targeted the canonical E.164 through the PR branch's
real reply path.

Scope note

The one thing this does not cover is a fully live inbound webhook hitting a deployed PR build (our production gateway runs the released OpenClaw, whose pre-PR normalizer produced the original documented rejection — which is the bug this PR fixes). Repointing the production Twilio webhook at a branch deployment is deliberately out of scope for proof; happy to add that after merge/release, or earlier if a maintainer wants it.

Redactions: phone numbers masked, RCS sender agent address, account SIDs, and tokens withheld.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 10, 2026
@steipete steipete self-assigned this Jul 10, 2026
@steipete
steipete force-pushed the fix/sms-rcs-address-normalization branch 3 times, most recently from 7ce594f to 492cbce Compare July 11, 2026 00:25
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 11, 2026
@steipete

steipete commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Land-ready proof for 9fb08dfc831cb786c2f245cb502dc4365fa51209.

What changed:

  • Twilio inbound parsing accepts bare E.164 and case-insensitive rcs: consumer addresses only after the webhook signature succeeds.
  • Raw form values remain intact for signature validation.
  • The shared outbound/config normalizer is unchanged, preserving Twilio's outbound RCS and fallback semantics.

Validation:

Known gap: no deployed exact-head webhook was used. The exact-head signed-handler integration test exercises the security and routing boundary changed here.

@steipete
steipete force-pushed the fix/sms-rcs-address-normalization branch from 492cbce to c77430a Compare July 11, 2026 00:40
@steipete
steipete force-pushed the fix/sms-rcs-address-normalization branch from c77430a to 9fb08df Compare July 11, 2026 00:41
@steipete
steipete merged commit e44f04c into openclaw:main Jul 11, 2026
95 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 11, 2026
* origin/main:
  fix(tui): preserve UTF-16 pairs in long tokens (#104024)
  fix(release): raise Telegram attestor buffer (#104025)
  fix(slack): apply sender policy to group DMs (#104007)
  feat(ui): add a background tasks pane to chat panes (#104010)
  docs(changelog): credit landed fixes
  fix(installer): clean temporary files on failure (#103725)
  fix(clickclack): sanitize outbound assistant text (#103142)
  fix(sms): normalize Twilio RCS webhook senders (#102373)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
* origin/main:
  fix(tui): preserve UTF-16 pairs in long tokens (openclaw#104024)
  fix(release): raise Telegram attestor buffer (openclaw#104025)
  fix(slack): apply sender policy to group DMs (openclaw#104007)
  feat(ui): add a background tasks pane to chat panes (openclaw#104010)
  docs(changelog): credit landed fixes
  fix(installer): clean temporary files on failure (openclaw#103725)
  fix(clickclack): sanitize outbound assistant text (openclaw#103142)
  fix(sms): normalize Twilio RCS webhook senders (openclaw#102373)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: sms Channel integration: sms P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants