Describe the bug
When receiving a private message, a Bad MAC error occurs and the message cannot be decrypted.
The issue happens consistently across multiple attempts, even after resetting the session.
Error Logs:
Failed to decrypt message with any known session...
Session error: Error: Bad MAC
at Object.verifyMAC (/root/wa/node_modules/libsignal/src/crypto.js:87:15)
at SessionCipher.doDecryptWhisperMessage (/root/wa/node_modules/libsignal/src/session_cipher.js:250:16)
at async SessionCipher.decryptWithSessions (/root/wa/node_modules/libsignal/src/session_cipher.js:147:29)
at async 6957863858248.0 [as awaitable] (/root/wa/node_modules/libsignal/src/session_cipher.js:171:28)
at async _asyncQueueExecutor (/root/wa/node_modules/libsignal/src/queue_job.js:20:29)
Closing open session in favor of incoming prekey bundle
Session Details (Closed Sessions)
SessionEntry {
_chains: {
'Bb1tY0m5e2qpgJLbbts+wRP2dU+kE5MdUQXEA1Cgmhs0': { chainKey: [Object], chainType: 2, messageKeys: {} },
'BQ90/dMFGWtPZ4tCsQHRBTFfgLSNmZ0U/XQxXgKFYk9r': { chainKey: [Object], chainType: 1, messageKeys: {} }
},
registrationId: 1241753327,
currentRatchet: {
ephemeralKeyPair: { pubKey: <Buffer ...>, privKey: <Buffer ...> },
lastRemoteEphemeralKey: <Buffer ...>,
previousCounter: 0,
rootKey: <Buffer ...>
},
indexInfo: {
baseKey: <Buffer ...>,
baseKeyType: 2,
closed: -1,
used: 1756892690842,
created: 1756892690842,
remoteIdentityKey: <Buffer ...>
}
}
To Reproduce
Steps to reproduce the behavior:
- Receive a private message from another user.
- Let the session attempt to decrypt the incoming message.
- The Bad MAC error appears in the logs.
- Reset the session (delete old session state and reinitialize).
- Try again — the error still occurs.
Expected behavior
Incoming messages should be decrypted successfully without throwing a Bad MAC error.
Environment:
- "@whiskeysockets/baileys": "^6.7.19",
Additional context
- The error often occurs when the local session state is not synchronized with the sender’s prekey bundle.
- Possible cause: the prekey bundle does not match the remote identity key, even after resetting the session.
- Already tried resetting the session, but the error still persists.
Describe the bug
When receiving a private message, a Bad MAC error occurs and the message cannot be decrypted.
The issue happens consistently across multiple attempts, even after resetting the session.
Error Logs:
Session Details (Closed Sessions)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Incoming messages should be decrypted successfully without throwing a Bad MAC error.
Environment:
Additional context