Skip to content

feat: implement Meta AI msmsg decryption#2592

Open
7ucg wants to merge 1 commit into
WhiskeySockets:masterfrom
7ucg:feat/meta-ai-msmsg-decryption
Open

feat: implement Meta AI msmsg decryption#2592
7ucg wants to merge 1 commit into
WhiskeySockets:masterfrom
7ucg:feat/meta-ai-msmsg-decryption

Conversation

@7ucg
Copy link
Copy Markdown

@7ucg 7ucg commented May 23, 2026

Port msmsg (MessageSecretMessage) decryption:

  • Add src/Utils/meta-ai-msmsg.ts with HKDF+AES-GCM decryption logic
  • Track outgoing bot message secrets (setBotMessageSecret) in decode-wa-message.ts
  • Handle msmsg enc type in decryptMessageNode with multi-candidate secret fallback
  • Auto-decode richResponseMessage.text from submessages or unifiedResponse JSON
  • Remove the msmsg early-return bail-out in messages-recv.ts

Summary by cubic

Adds decryption support for Meta AI msmsg so bot replies and edits are readable and processed end-to-end. Also auto-decodes rich response text and removes the old skip path.

  • New Features
    • Added src/Utils/meta-ai-msmsg.ts with HKDF+AES-GCM decryption, bounded strategies, and rich response decoders.
    • Handled enc type msmsg in decryptMessageNode with multi-candidate secret fallback (by id and recent per-chat).
    • Tracked and cached bot messageSecret via setBotMessageSecret to decrypt follow-ups and edits reliably.
    • Auto-decoded richResponseMessage.text from submessages or unifiedResponse JSON; removed the msmsg early-return in messages-recv.ts.

Written for commit 6394514. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Fixed rejection of Meta AI bot messages—they now proceed through normal decryption and acknowledgment flows instead of being blocked.
  • New Features

    • Added support for decrypting Meta AI bot messages using cached message secrets.
    • Meta AI bot messages are now properly decoded and processed.

Review Change Stack

Port msmsg (MessageSecretMessage) decryption:
- Add src/Utils/meta-ai-msmsg.ts with HKDF+AES-GCM decryption logic
- Track outgoing bot message secrets (setBotMessageSecret) in decode-wa-message.ts
- Handle msmsg enc type in decryptMessageNode with multi-candidate secret fallback
- Auto-decode richResponseMessage.text from submessages or unifiedResponse JSON
- Remove the msmsg early-return bail-out in messages-recv.ts
@whiskeysockets-bot
Copy link
Copy Markdown
Contributor

Thanks for opening this pull request and contributing to the project!

The next step is for the maintainers to review your changes. If everything looks good, it will be approved and merged into the main branch.

In the meantime, anyone in the community is encouraged to test this pull request and provide feedback.

✅ How to confirm it works

If you’ve tested this PR, please comment below with:

Tested and working ✅

This helps us speed up the review and merge process.

📦 To test this PR locally:

# NPM
npm install @whiskeysockets/baileys@7ucg/Baileys#feat/meta-ai-msmsg-decryption

# Yarn (v2+)
yarn add @whiskeysockets/baileys@7ucg/Baileys#feat/meta-ai-msmsg-decryption

# PNPM
pnpm add @whiskeysockets/baileys@7ucg/Baileys#feat/meta-ai-msmsg-decryption

If you encounter any issues or have feedback, feel free to comment as well.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

📝 Walkthrough

Walkthrough

The PR adds support for decrypting Meta AI MSMSG bot messages by introducing a cryptographic module for bounded strategy-based AES-GCM decryption, integrating secret caching and MSMSG handling into the main message decoder, and removing special-case rejection so MSMSG flows through normal processing with retry.

Changes

MSMSG bot message decryption support

Layer / File(s) Summary
MSMSG decryption primitives
src/Utils/meta-ai-msmsg.ts
Defines MsmsgMessageKey interface and exports functions for building bounded decryption strategies (combining message ID representations with JID candidates), deriving AES-GCM keys via HKDF, decoding decrypted protobuf messages with unpadding fallback, orchestrating decryption attempts with error collection, and extracting human-readable text from rich response structures.
Message handler MSMSG integration
src/Utils/decode-wa-message.ts
Introduces setBotMessageSecret to cache secrets by message ID and chat, pre-scans stanza metadata for MSMSG context (target IDs, sender JID, bot flags), extends the decryption switch with an MSMSG case that gathers candidate secrets and attempts decryption, auto-decodes richResponseMessage text for normal and edited responses, and caches newly observed secrets for future MSMSG decryptions.
Handler message flow enablement
src/Socket/messages-recv.ts
Imports setBotMessageSecret and removes the early-return branch that rejected MSMSG-type enc nodes with NACK_REASONS.MissingMessageSecret, allowing MSMSG stanzas to proceed through standard message decryption and retry logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A rabbit's whisper on the msmsg flow,
Strategies blend with secrets in crypto's glow,
No early rejection, just HKDF's dance,
Rich responses decode with delight in each glance,
Bot messages bloom where the caches now grow! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: implement Meta AI msmsg decryption' accurately and concisely describes the main change: adding Meta AI message secret message (msmsg) decryption support across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/Utils/decode-wa-message.ts (1)

416-416: ⚡ Quick win

Replace manual LID parsing with JID helper

meLid.split(':')[0] is a manual JID parse. Please use a JID helper (same reason as in the crypto helper file) to avoid malformed edge cases.

As per coding guidelines, "Always use JID helper functions (jidDecode, jidNormalizedUser, areJidsSameUser, isJidUser) instead of string operations like .split('@') or === comparisons."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Utils/decode-wa-message.ts` at line 416, Replace the manual parse
meLid.split(':')[0] with the JID helper: import and call jidDecode(meLid) and
use its user/local part (e.g., const { user } = jidDecode(meLid)) when building
meId (so meId becomes metaTargetSenderJid || `${user}`@lid``), avoiding
string-splitting and ensuring proper JID parsing; update any imports to pull
jidDecode from the JID helpers module.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Utils/decode-wa-message.ts`:
- Line 436: The catch blocks in decode-wa-message decryption paths use `any` and
unchecked casts which weaken type-safety: change `catch (e: any)` to `catch (e:
unknown)` and narrow `e` before accessing properties like `attemptedStrategies`
(use type guards or instanceof checks and rethrow if unknown), replace `as any`
enrichments for `richResponse` with a local structural type (e.g., `{ text?:
string }`) and cast/narrow the unknown value into that shape before mutating,
and likewise convert other `catch (err: any)` and the
`isSessionRecordError(error: any)` usage to accept `unknown` and perform
explicit narrowing inside `isSessionRecordError` (or add a type guard function)
so no `any` is introduced while preserving the same behavior in the decryption
and augmentation code paths.
- Around line 25-51: botMessageSecrets currently never evicts entries leading to
unbounded memory growth; modify setBotMessageSecret to enforce a fixed-cap
eviction policy (e.g., MAX_SECRETS_GLOBAL constant) and remove oldest entries
when the map exceeds that cap. Locate botMessageSecrets and the
setBotMessageSecret function and after inserting the new buf, check
botMessageSecrets.size and delete the oldest key(s) (use
botMessageSecrets.keys().next().value to find the oldest) until size <=
MAX_SECRETS_GLOBAL; keep pushRecentChatSecret and botRecentSecretsByChat logic
unchanged.

In `@src/Utils/meta-ai-msmsg.ts`:
- Around line 56-59: normalizeLidJid currently does manual string splitting;
replace that with JID helper usage: use jidDecode(jid) to parse the JID, check
the decoded server/domain equals 'lid' and that decoded user contains a ':'; if
so, take the portion before ':' from decoded.user and reassemble a normalized
JID using the jidNormalizedUser (or equivalent JID assembly helper) to return
e.g. "<userBeforeColon>`@lid`"; otherwise return the original jid or undefined as
before. Ensure you reference and import the helper(s) (jidDecode,
jidNormalizedUser) and update normalizeLidJid to use them instead of jid.split.
- Line 275: In decodeRichResponseMessage: remove the unnecessary any cast by
using richMsg.unifiedResponse?.data (typed as
IAIRichResponseUnifiedResponse.data | null) instead of (richMsg as
any).unifiedResponse?.data, and change the Buffer call to
Buffer.from(data).toString('utf8') (or, if data can be a base64 string, add a
small guard to detect string vs Uint8Array and decode accordingly) so that the
variable data and its decoding respect the declared types.

---

Nitpick comments:
In `@src/Utils/decode-wa-message.ts`:
- Line 416: Replace the manual parse meLid.split(':')[0] with the JID helper:
import and call jidDecode(meLid) and use its user/local part (e.g., const { user
} = jidDecode(meLid)) when building meId (so meId becomes metaTargetSenderJid ||
`${user}`@lid``), avoiding string-splitting and ensuring proper JID parsing;
update any imports to pull jidDecode from the JID helpers module.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2b99b022-7ca6-436f-a8cf-92cf191855b1

📥 Commits

Reviewing files that changed from the base of the PR and between 78e7e4e and 6394514.

📒 Files selected for processing (3)
  • src/Socket/messages-recv.ts
  • src/Utils/decode-wa-message.ts
  • src/Utils/meta-ai-msmsg.ts

Comment on lines +25 to +51
const botMessageSecrets = new Map<string, Buffer>()
const botRecentSecretsByChat = new Map<string, { id: string; secret: Buffer }[]>()

const pushRecentChatSecret = (chatJid: string, id: string, secretBuf: Buffer): void => {
if (!chatJid || !secretBuf) return
const existing = botRecentSecretsByChat.get(chatJid) || []
const filtered = existing.filter(item => item.id !== id && !item.secret.equals(secretBuf))
filtered.unshift({ id, secret: secretBuf })
if (filtered.length > MAX_SECRETS_PER_CHAT) filtered.length = MAX_SECRETS_PER_CHAT
botRecentSecretsByChat.set(chatJid, filtered)
}

export const setBotMessageSecret = (id: string, secret: Uint8Array | Buffer | string, chatJid?: string): void => {
if (!id || !secret) return
let buf: Buffer
if (Buffer.isBuffer(secret)) {
buf = secret
} else if (secret instanceof Uint8Array) {
buf = Buffer.from(secret.buffer, secret.byteOffset, secret.byteLength)
} else if (typeof secret === 'string') {
buf = Buffer.from(secret, 'base64')
} else {
return
}
botMessageSecrets.set(id, buf)
if (chatJid) pushRecentChatSecret(chatJid, id, buf)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Bound botMessageSecrets to prevent unbounded growth

botMessageSecrets never evicts entries. In long-lived sessions this can grow indefinitely and degrade memory usage over time.

Suggested change
 const MAX_SECRETS_PER_CHAT = 20
+const MAX_SECRETS_GLOBAL = 2000
 
 const botMessageSecrets = new Map<string, Buffer>()
+const botMessageSecretOrder: string[] = []
 const botRecentSecretsByChat = new Map<string, { id: string; secret: Buffer }[]>()
@@
 	botMessageSecrets.set(id, buf)
+	botMessageSecretOrder.push(id)
+	if (botMessageSecretOrder.length > MAX_SECRETS_GLOBAL) {
+		const evictId = botMessageSecretOrder.shift()
+		if (evictId) botMessageSecrets.delete(evictId)
+	}
 	if (chatJid) pushRecentChatSecret(chatJid, id, buf)
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Utils/decode-wa-message.ts` around lines 25 - 51, botMessageSecrets
currently never evicts entries leading to unbounded memory growth; modify
setBotMessageSecret to enforce a fixed-cap eviction policy (e.g.,
MAX_SECRETS_GLOBAL constant) and remove oldest entries when the map exceeds that
cap. Locate botMessageSecrets and the setBotMessageSecret function and after
inserting the new buf, check botMessageSecrets.size and delete the oldest key(s)
(use botMessageSecrets.keys().next().value to find the oldest) until size <=
MAX_SECRETS_GLOBAL; keep pushRecentChatSecret and botRecentSecretsByChat logic
unchanged.

msgBuffer = await decryptMsmsgBotMessage(candidate.secret, helperKey, msMsg)
logger.debug({ source: candidate.source }, 'msmsg: decrypted with candidate secret')
break
} catch (e: any) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify explicit any usage in this file
rg -nP "\bas\s+any\b|:\s*any\b" src/Utils/decode-wa-message.ts

Repository: WhiskeySockets/Baileys

Length of output: 365


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '400,560p' src/Utils/decode-wa-message.ts | nl -ba | sed -n '1,200p'

Repository: WhiskeySockets/Baileys

Length of output: 109


🏁 Script executed:

#!/bin/bash
set -euo pipefail

awk 'NR>=420 && NR<=540 {printf "%d:%s\n", NR, $0}' src/Utils/decode-wa-message.ts
echo "----"
awk 'NR>=540 && NR<=575 {printf "%d:%s\n", NR, $0}' src/Utils/decode-wa-message.ts

Repository: WhiskeySockets/Baileys

Length of output: 5196


Remove new any usage in msmsg/rich-response decryption paths

  • Replace catch (e: any) (line 436) with catch (e: unknown) and narrow before reading attemptedStrategies / rethrowing.
  • Replace as any richResponse augmentation (lines 493 and 498) with a local structural type (e.g., { text?: string }) and cast/narrow from unknown instead of weakening types.
  • If this block was added in the same change, also avoid catch (err: any) (line 512) / isSessionRecordError(error: any) (line 542) by switching to unknown + narrowing.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Utils/decode-wa-message.ts` at line 436, The catch blocks in
decode-wa-message decryption paths use `any` and unchecked casts which weaken
type-safety: change `catch (e: any)` to `catch (e: unknown)` and narrow `e`
before accessing properties like `attemptedStrategies` (use type guards or
instanceof checks and rethrow if unknown), replace `as any` enrichments for
`richResponse` with a local structural type (e.g., `{ text?: string }`) and
cast/narrow the unknown value into that shape before mutating, and likewise
convert other `catch (err: any)` and the `isSessionRecordError(error: any)`
usage to accept `unknown` and perform explicit narrowing inside
`isSessionRecordError` (or add a type guard function) so no `any` is introduced
while preserving the same behavior in the decryption and augmentation code
paths.

Comment on lines +56 to +59
const normalizeLidJid = (jid: string | undefined): string | undefined => {
if (!jid || !jid.endsWith('@lid') || !jid.includes(':')) return jid
return `${jid.split(':')[0]}@lid`
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use JID helpers instead of manual string splitting

normalizeLidJid currently uses jid.split(':')[0]. Please switch to JID helper parsing so non-standard forms don’t produce wrong normalization.

Suggested change
+import { jidDecode } from '../WABinary'
+
 const normalizeLidJid = (jid: string | undefined): string | undefined => {
-	if (!jid || !jid.endsWith('`@lid`') || !jid.includes(':')) return jid
-	return `${jid.split(':')[0]}`@lid``
+	if (!jid) return jid
+	const decoded = jidDecode(jid)
+	if (!decoded || decoded.server !== 'lid') return jid
+	return `${decoded.user}`@lid``
 }

As per coding guidelines, "Always use JID helper functions (jidDecode, jidNormalizedUser, areJidsSameUser, isJidUser) instead of string operations like .split('@') or === comparisons."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const normalizeLidJid = (jid: string | undefined): string | undefined => {
if (!jid || !jid.endsWith('@lid') || !jid.includes(':')) return jid
return `${jid.split(':')[0]}@lid`
}
import { jidDecode } from '../WABinary'
const normalizeLidJid = (jid: string | undefined): string | undefined => {
if (!jid) return jid
const decoded = jidDecode(jid)
if (!decoded || decoded.server !== 'lid') return jid
return `${decoded.user}`@lid``
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Utils/meta-ai-msmsg.ts` around lines 56 - 59, normalizeLidJid currently
does manual string splitting; replace that with JID helper usage: use
jidDecode(jid) to parse the JID, check the decoded server/domain equals 'lid'
and that decoded user contains a ':'; if so, take the portion before ':' from
decoded.user and reassemble a normalized JID using the jidNormalizedUser (or
equivalent JID assembly helper) to return e.g. "<userBeforeColon>`@lid`";
otherwise return the original jid or undefined as before. Ensure you reference
and import the helper(s) (jidDecode, jidNormalizedUser) and update
normalizeLidJid to use them instead of jid.split.

.join('\n')
if (sub) return sub
}
const data = (richMsg as any).unifiedResponse?.data
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify remaining explicit `any` usage in this file
rg -nP "\bas\s+any\b|:\s*any\b" src/Utils/meta-ai-msmsg.ts

Repository: WhiskeySockets/Baileys

Length of output: 124


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the exact context around the reported line
nl -ba src/Utils/meta-ai-msmsg.ts | sed -n '240,310p'

# Find where `richMsg` is declared/typed in this file
rg -n "richMsg" src/Utils/meta-ai-msmsg.ts

Repository: WhiskeySockets/Baileys

Length of output: 109


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Context around the reported line (use cat -n since nl is unavailable)
cat -n src/Utils/meta-ai-msmsg.ts | sed -n '240,310p'

# Locate the type/definition of `richMsg` usages in this file
rg -n "richMsg" src/Utils/meta-ai-msmsg.ts

Repository: WhiskeySockets/Baileys

Length of output: 2263


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find how IAIRichResponseMessage is typed and whether unifiedResponse is part of it
rg -n "interface IAIRichResponseMessage|type IAIRichResponseMessage|IAIRichResponseMessage" src | head -n 50
rg -n "unifiedResponse" src | head -n 50

Repository: WhiskeySockets/Baileys

Length of output: 295


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the definition of IAIRichResponseMessage in the repo
rg -n "IAIRichResponseMessage" . -S --hidden

# Also locate where proto is imported from in this file
rg -n "from ['\"][^'\"]+['\"]" src/Utils/meta-ai-msmsg.ts

Repository: WhiskeySockets/Baileys

Length of output: 1043


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect IAIRichResponseMessage definition around the reported lines
sed -n '520,580p' WAProto/index.d.ts

Repository: WhiskeySockets/Baileys

Length of output: 3703


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect IAIRichResponseUnifiedResponse to confirm the `data` field's type
rg -n "interface IAIRichResponseUnifiedResponse" -n WAProto/index.d.ts
sed -n '580,660p' WAProto/index.d.ts

Repository: WhiskeySockets/Baileys

Length of output: 4924


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find other references to unifiedResponse/data decoding
rg -n "unifiedResponse\\?\\.data|IAIRichResponseUnifiedResponse|unifiedResponse\\b" src WAProto -S

# Find how Buffer.from(...,'base64') is used with similar payloads
rg -n "Buffer\\.from\\([^\\)]*,'base64'\\)|Buffer\\.from\\([^\\)]*\"base64\"" src -S

Repository: WhiskeySockets/Baileys

Length of output: 2369


🏁 Script executed:

node - <<'NODE'
const u = new Uint8Array([1,2,3,4]);
try {
  const b = Buffer.from(u, 'base64');
  console.log('buf len', b.length, 'contents', b);
} catch (e) {
  console.error('error', e && e.message);
}
NODE

Repository: WhiskeySockets/Baileys

Length of output: 106


Remove any cast for unifiedResponse.data in decodeRichResponseMessage (src/Utils/meta-ai-msmsg.ts:275)

richMsg is already typed with unifiedResponse?: IAIRichResponseUnifiedResponse | null and IAIRichResponseUnifiedResponse.data?: Uint8Array | null, so replace const data = (richMsg as any).unifiedResponse?.data with const data = richMsg.unifiedResponse?.data, and update Buffer.from(data, 'base64') to Buffer.from(data).toString('utf8') (or add a guard only if data can be a base64 string).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Utils/meta-ai-msmsg.ts` at line 275, In decodeRichResponseMessage: remove
the unnecessary any cast by using richMsg.unifiedResponse?.data (typed as
IAIRichResponseUnifiedResponse.data | null) instead of (richMsg as
any).unifiedResponse?.data, and change the Buffer call to
Buffer.from(data).toString('utf8') (or, if data can be a base64 string, add a
small guard to detect string vs Uint8Array and decode accordingly) so that the
variable data and its decoding respect the declared types.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/Utils/decode-wa-message.ts">

<violation number="1" location="src/Utils/decode-wa-message.ts:25">
P1: Unbounded global message-secret cache risks memory growth and cross-session contamination</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic


const MAX_SECRETS_PER_CHAT = 20

const botMessageSecrets = new Map<string, Buffer>()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Unbounded global message-secret cache risks memory growth and cross-session contamination

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/Utils/decode-wa-message.ts, line 25:

<comment>Unbounded global message-secret cache risks memory growth and cross-session contamination</comment>

<file context>
@@ -18,6 +18,37 @@ import {
+
+const MAX_SECRETS_PER_CHAT = 20
+
+const botMessageSecrets = new Map<string, Buffer>()
+const botRecentSecretsByChat = new Map<string, { id: string; secret: Buffer }[]>()
+
</file context>

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants