OpenClaw / wacli
Merged upstreamCorrectnessMerged Sep 12, 2026

Apply authenticated encrypted message edits

Decrypts `SecretEncryptedMessage{MESSAGE_EDIT}` envelopes before live and history reconciliation, updating the original row while preserving its timestamp, sender identity, edit state, and webhook semantics.

openclaw/wacli · #363

Messaging correctness and authorization fix

WACLI can now decrypt encrypted WhatsApp edit envelopes and safely reconcile valid edits with their original messages.

Problem

Encrypted edits were stored as opaque rows, leaving the original message unchanged and giving downstream consumers no corrected body or revision linkage. Decryption also needed a separate application-level authorization boundary before any mutation.

Approach

Routes valid decrypted protocol edits through the existing reconciliation path and binds each mutation to its authenticated sender, chat, and target. Sender mismatches, forged direction, redirected targets, nested mutations, missing keys, invalid ciphertext, and empty payloads are rejected before storage or webhooks.

Impact and scope

  • Restores corrected message state for encrypted edits in both live sync and newest-first history processing.
  • Separates successful decryption from authorization so a valid shared secret alone cannot permit another participant to edit a message.
  • Preserves canonical sender, direction, timestamp, storage, and webhook behavior across LID aliases and SDK wrappers.

Validation

  • Thirty-eight compiled-CLI runs covered two baseline reproductions and 36 fixed scenarios using real SDK SQL secret lookup, LID mapping, HKDF/AES-GCM, SQLite persistence, and an HTTP webhook receiver.
  • The complete repository gate, focused race tests, exact-head CI, Docker validation, and 34 live/history unit combinations passed.
  • The maintainer publicly credited Goutam for the implementation and retained contributor credit in the GitHub-verified squash commit. Transport was synthetic; no live WhatsApp account was accessed, and already-opaque rows require re-delivery to recover.