Skip to content

fix: desembrulhar mensagens temporárias, parar retry vazio do getMessage e mascarar token no fetchInstances - #2

Closed
Faelst wants to merge 2 commits into
mainfrom
fix/radar-ss-inbound-security
Closed

Faelst wants to merge 2 commits into
mainfrom
fix/radar-ss-inbound-security

Conversation

@Faelst

@Faelst Faelst commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Três correções contidas e verificadas no código deste fork, no caminho ao vivo messages.upsert / fetch, que afetam o Radar de Ingressos (leitura de entrada) e o SafetySwap (entrega de envio).

O que entra (3 issues confirmadas)

1. evolution-foundation#2773 — mensagens temporárias (disappearing) somem para o consumidor · Radar

O Baileys entrega mensagens temporárias / view-once com o conteúdo real aninhado em ephemeralMessage.message; ele só desembrulha sob demanda via normalizeMessageContent, que o Evolution nunca chama no caminho ao vivo. Resultado: getContentType() reporta ephemeralMessage, o achatamento extendedTextMessage → conversation e os checks de isMedia não disparam, e a mensagem chega ao webhook/banco com o texto/mídia enterrados. Toda oferta postada num grupo com mensagens temporárias ligadas era invisível ao radar.
Fix: desembrulhar ephemeralMessage / viewOnce* logo após o guard de editedMessage (que continua tratado à parte), antes de qualquer manuseio de conteúdo.

2. evolution-foundation#2705 — getMessage vazio no miss trava a entrega em "Waiting for this message" · SafetySwap

getMessage() devolvia { conversation: '' } quando a linha não existia no banco. O Baileys trata qualquer retorno truthy como "mensagem encontrada" e retransmite o envelope vazio para satisfazer o pedido de retry — queima uma das tentativas e deixa o destinatário preso para sempre em "Waiting for this message".
Fix: retornar undefined no miss, para o Baileys cair no caminho de reenvio/placeholder. (O caminho full=true já retornava undefined; mudança só no caminho usado no callback do Baileys.)

3. evolution-foundation#2677 — fetchInstances vaza o token da instância · Segurança

fetchInstances devolvia o token (hash de auth = apikey) incondicionalmente. A flag AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES só era aplicada ao campo apiKey do webhook, nunca a esta resposta HTTP. Exposição real num servidor que hospeda várias instâncias.
Fix: mascarar o token (→ null) quando a flag é false (default seguro).

O que NÃO entra (e por quê)

Validação

Arquivos

🤖 Generated with Claude Code

Faelst and others added 2 commits December 2, 2026 17:53
The runtime config var NODE_OPTIONS=--max-old-space-size=384 (set to
contain R14 on the 512MB dyno) leaks into the Heroku Node buildpack
build phase, capping tsc+tsup at 384MB and causing a JS heap OOM.
Override NODE_OPTIONS inline in the build script so the build gets
2048MB; start:prod keeps the inherited 384MB ceiling at runtime.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…k fetchInstances token

Three contained, verified fixes for open upstream issues that affect the
Radar de Ingressos (inbound reading) and SafetySwap (outbound delivery),
all on the live messages.upsert / fetch path, with src diverging from
upstream.

- evolution-foundation#2773: unwrap ephemeralMessage / viewOnce envelopes before content
  handling. Baileys delivers disappearing/view-once messages with the real
  content nested; Evolution never called normalizeMessageContent on the
  live path, so getContentType() reported `ephemeralMessage`, the
  text->conversation flattening and isMedia checks never fired, and the
  message was stored/webhooked with its text buried. Any offer sent in a
  chat with disappearing messages on was invisible to the radar.

- evolution-foundation#2705: getMessage() returned { conversation: '' } on a DB miss. Baileys
  treats any truthy return as "found" and relays the empty envelope to
  satisfy a retry, burning one attempt and leaving the recipient stuck on
  "Waiting for this message" forever. Return undefined instead so Baileys
  falls through to its resend path. (full=true already returned undefined.)

- evolution-foundation#2677: fetchInstances returned the instance `token` (auth hash)
  unconditionally; AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES was only ever
  applied to the webhook apiKey field, never this HTTP response. Mask the
  token when the flag is false. Real exposure on a shared multi-instance
  server.

Validated with tsc --noEmit, eslint and npm run build. Baileys-coupled
paths (evolution-foundation#2773, evolution-foundation#2705) still want a live smoke test on a real instance.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Faelst

Faelst commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

Conteúdo (os 3 fixes: evolution-foundation#2773, evolution-foundation#2705, evolution-foundation#2677) já incorporado na main via PR #3 (cherry-pick, arquivos byte-a-byte idênticos). Fechando como superseded para evitar merge duplicado/vazio.

@Faelst Faelst closed this Dec 3, 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.

1 participant