Repository navigation
Description
Description
OpenMLS contains several debug_assert!(false, ...) calls inside .map_err() closures and error-handling branches. These cause panics in debug builds even though the surrounding code correctly converts errors to proper Result return types.
The most impactful instances for downstream consumers:
1. src/framing/private_message_in.rs:129 — AEAD decryption failure
.map_err(|_| {
log::error!(" Ciphertext decryption error");
debug_assert!(false, "Ciphertext decryption failed");
MessageDecryptionError::AeadError
})?;2. group/mls_group/creation.rs:429 — Welcome confirmation tag mismatch
debug_assert!(false, "Confirmation tag mismatch");
// ...
return Err(WelcomeError::ConfirmationTagMismatch);Both correctly return errors in release mode but panic in debug mode, causing test-mode divergence for any consumer that tests error handling with corrupted/tampered MLS messages.
Impact
- Downstream crates must gate decrypt-failure tests with
#[cfg(not(debug_assertions))], splitting test suites between debug and release modes - The panics contradict the functions'
Result<..., Error>return signatures - OpenMLS's own
test_valsem006expectsAeadError(not panic), suggesting these assertions are unintentional artifacts
Reproduction
Both panics can be triggered in a debug build (cargo test, not --release):
Decrypt panic (private_message_in.rs:129):
- Create group with two members (alice, bob)
- alice encrypts an application message
- XOR last byte of ciphertext
- bob calls
process_message()→ panics instead of Err
Welcome panic (creation.rs:429):
- alice creates a group and generates a Welcome for bob
- Modify any byte in the Welcome's encrypted group secrets region
- bob calls
MlsGroup::new_from_welcome()→ panics instead of Err
Suggested Fix (three options)
-
Remove the
debug_assert!calls — The error handling is already correct. Thelog::error!()calls provide sufficient diagnostic visibility. -
Replace with
log::warn!— If the intent was diagnostic logging rather than hard assertion, downgrade to a warning log that doesn't affect control flow. -
Gate behind a feature flag — Add a
strict-debug-assertsfeature (default off) for consumers who want panics during development:
#[cfg(feature = "strict-debug-asserts")]
debug_assert!(false, "Ciphertext decryption failed");Environment
- Verified in both
openmls0.6.0 and 0.8.1 (main branch at time of writing) - Rust: 1.94.1
- 6 instances of
debug_assert!(false)found in the codebase; 2 are in error-handling paths reachable by external input (listed above), 4 are internal invariant checks
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity