fix: add error handling in message receive loop (#9)#18
Open
Conversation
- Treat decryption errors as fatal - close session immediately on ratchet decrypt failures - Emit decryption_error event with user-visible error message when decryption fails - Log decryption attempt context (counter value) in debug builds for troubleshooting - Improve error messages to include ratchet counter information for debugging - Close session and emit session_closed event when decryption errors occur This fixes issue #9 where decryption errors in the receive loop were silently ignored, allowing the session to continue in an inconsistent state. Now decryption failures are treated as fatal security events that immediately terminate the session.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Add error handling in message receive loop
Closes #9
Problem
When the double ratchet decrypt operation fails (invalid MAC, wrong key, replay, etc.), the error is silently ignored in the receive loop. The loop continues processing subsequent messages despite being in an inconsistent state. This is a critical security and reliability gap because:
Solution
Treat decryption errors as fatal session-terminating events:
Immediate session closure: When
handle_incoming_messagereturns an error, the receive loop now:decryption_errorevent with a user-visible messagesession_closedeventEnhanced error context:
Security-first approach:
Security considerations
Implementation details
#[cfg(debug_assertions)]logging for decryption attemptsclose_sessioncommand