Skip to main content

Protocol Security Analysis - MLS Implementation

Overviewโ€‹

Analysis of MLS protocol-level security including TreeKEM implementation, epoch management, commit handling, forward secrecy, and post-compromise security based on RFC 9420 requirements and 2024 security research findings.

Status: ๐ŸŸก MODERATE - Core protocol is correct but missing safeguards


TreeKEM Implementationโ€‹

Ratchet Tree Managementโ€‹

Status: โœ… RFC 9420 Compliant with operational concerns

Key Implementation:

// Line 32-38: Proper trailing null stripping
function stripTrailingNulls(tree: any[]): any[] {
let lastNonNull = tree.length - 1;
while (lastNonNull >= 0 && tree[lastNonNull] === null) {
lastNonNull--;
}
return tree.slice(0, lastNonNull + 1);
}

Analysis:

  • โœ… Implements RFC 9420 requirement to strip trailing nulls
  • โœ… Preserves interior nulls (unmerged positions)
  • โœ… Proper tree structure maintained
  • โš ๏ธ No size limits (could accept massive trees)
  • โš ๏ธ No node validation before processing

Tree Security Propertiesโ€‹

PropertyStatusAssessment
Binary tree structureโœ… Correctts-mls handles
Path secretsโœ… SecureProper HKDF derivation
Leaf node isolationโœ… CorrectPer-member encryption
Parent node updatesโœ… CorrectPath update mechanism
Tree consistencyโœ… MaintainedTree hash verification
Size limitsโŒ MissingVulnerability

Forward Secrecy Analysisโ€‹

Epoch-Based Ratchetingโ€‹

Implementation: MLSManager.tsx:450-480

async updateKey(groupId: string): Promise<any> {
const commitResult = await createCommit(
{ state: groupState, cipherSuite: this.cipherSuite! },
{ forcePathUpdate: true } // โœ… Forces key rotation
);
this.groups.set(groupId, commitResult.newState);
}

Forward Secrecy Properties:

  • โœ… Epoch progression: New epoch = new keys
  • โœ… Key ratcheting: Per-message key derivation
  • โœ… Path updates: Entire key schedule rotates
  • โœ… Old keys discarded: Previous epochs cannot decrypt new messages
  • โœ… Automatic on member changes: Add/remove triggers epoch++

Assessment: โœ… SECURE - Full forward secrecy implemented

Test Evidence:

// From mls-manager.test.js:286-327
test('should perform key rotation', async () => {
// After rotation, epoch increases
expect(afterRotation.epoch > beforeRotation.epoch).toBe(true);
// Messages after rotation use new keys
});

Post-Compromise Securityโ€‹

Key Rotation Recoveryโ€‹

Mechanism: Path update propagates new secrets through tree

Security Properties:

  • โœ… Future messages recover after compromise
  • โœ… Attacker must compromise EVERY epoch to maintain access
  • โœ… Path secret updates heal compromised nodes
  • โš ๏ธ Inactive user vulnerability: Offline members don't update keys

2024 Research: Inactive User Problemโ€‹

Finding: Post-compromise security requires ALL users to be active

  • Inactive users remain at old epoch
  • Don't update their encryption keys
  • Represent vulnerability for entire group

This Implementation:

  • โš ๏ธ No mechanism to detect inactive users
  • โš ๏ธ No mechanism to force key rotation for inactive members
  • โš ๏ธ Group can't heal if members stay offline

Mitigation: RFC 9420 Section 11.2 allows removing inactive members


Commit Distribution & Synchronizationโ€‹

RFC 9420 Section 11.2 Complianceโ€‹

Documentation: MLSManager.tsx:238-249

// RFC 9420 Section 11.2: Commit Distribution
// โš ๏ธ IMPORTANT: The returned commit MUST be sent to all existing group members
// so they can process it with processCommit() to stay synchronized.
//
// Distribution flow:
// 1. Alice adds Bob: addMembers() returns { welcome, commit }
// 2. Alice sends welcome to Bob (new member)
// 3. Alice sends commit to existing members (Charlie, David, etc.)
// 4. All existing members call processCommit(commit) to update their state

Analysis:

  • โœ… Documentation: Clear instructions for integrators
  • โœ… API Design: Returns both welcome and commit
  • โš ๏ธ No enforcement: Application must handle distribution
  • โš ๏ธ No failure handling: What if commit doesn't reach everyone?

Commit Processingโ€‹

Implementation: MLSManager.tsx:491-565

async processCommit(groupId: string, commit: any): Promise<void> {
if (commit.wireformat === 'mls_public_message') {
result = await processPublicMessage(...); // Add/remove
} else if (commit.wireformat === 'mls_private_message') {
result = await processPrivateMessage(...); // Update/rotation
}
}

Security Properties:

  • โœ… Correct routing based on wireformat
  • โœ… Handles both public and private commits
  • โœ… Updates group state atomically
  • โŒ No epoch validation (epoch rollback possible)
  • โŒ No sender validation (who created commit?)

Epoch Managementโ€‹

Current Implementationโ€‹

State:

export interface MLSGroupInfo {
groupId: Uint8Array;
members: string[];
epoch: bigint; // โœ… Uses BigInt for large epochs
}

Epoch Progression:

  • โœ… Increments on every group change
  • โœ… Tracked per-group correctly
  • โœ… Exposed via getGroupKeyInfo()
  • โŒ No validation of epoch sequence
  • โŒ No protection against epoch rollback

Epoch Rollback Attackโ€‹

Vulnerability: processCommit doesn't validate epoch++

Attack:

const rollback = {
wireformat: 'mls_public_message',
publicMessage: {
content: {
epoch: 0n // โš ๏ธ Rollback to epoch 0!
}
}
};
await victim.processCommit('group1', rollback);
// If accepted: group security compromised

Impact: Attacker forces group to old epoch with known/compromised keys

Fix Required:

// Validate epoch must be currentEpoch + 1
if (msg.content.epoch !== currentState.groupContext.epoch + 1n) {
throw new Error('Invalid epoch progression');
}

External Operations Securityโ€‹

2024 Research Findingโ€‹

ETK Research (2025): "External-Operations TreeKEM and the Security of MLS in RFC 9420"

  • External operations (external commits/proposals) were major RFC 9420 addition
  • Previous security analyses didn't cover external operations
  • This implementation delegates to ts-mls library

This Implementation:

  • โœ… Uses ts-mls which implements external operations
  • โš ๏ธ No additional validation at application layer
  • โš ๏ธ Trusts ts-mls security properties

Assessment: ACCEPTABLE - Proper delegation to audited library


Authentication & Integrityโ€‹

Signature Schemeโ€‹

Ed25519 (NOT ECDSA):

  • โœ… Critical: Avoids 2024 ECDSA vulnerability
  • โœ… Provides SUF-CMA security (stronger than EUF-CMA)
  • โœ… TreeKEM consistency guaranteed
  • โœ… No signature malleability

Message Authenticationโ€‹

MechanismImplementationStatus
Member signaturesEd25519 via ts-mlsโœ… Secure
AEAD tagsAES-128-GCMโœ… Secure
Membership tagsRFC 9420 ยง6.1โœ… Implemented
Sender authenticationts-mlsโœ… Delegated

Group State Managementโ€‹

State Storageโ€‹

private groups: Map<string, ClientState> = new Map();

Analysis:

  • โœ… In-memory storage (no persistence risks)
  • โœ… Per-group isolation
  • โœ… ClientState from ts-mls (proper structure)
  • โš ๏ธ No state backup/recovery
  • โš ๏ธ Application restart = state loss

State Synchronizationโ€‹

Mechanisms:

  1. Commit distribution (documented, not enforced)
  2. Welcome message processing (automated)
  3. Epoch tracking (per-group)

Issues:

  • โŒ No detection of desynchronized members
  • โŒ No automatic resynchronization
  • โŒ No state reconciliation protocol

Impact: If members miss commits โ†’ permanent desync


Security Properties Verificationโ€‹

RFC 9420 Required Propertiesโ€‹

PropertyRequirementStatusEvidence
ConfidentialityOnly members decryptโœ…AES-GCM + group keys
AuthenticationVerify sender identityโœ…Ed25519 signatures
Forward SecrecyPast messages safeโœ…Epoch ratcheting
Post-CompromiseFuture messages recover๐ŸŸกRequires active users
IntegrityDetect tamperingโœ…AEAD tags
Group AgreementSame view๐ŸŸกNo desync detection

Attack Scenariosโ€‹

1. Epoch Desynchronization Attackโ€‹

Scenario:

  1. Alice, Bob, Charlie in group at epoch 5
  2. Alice sends commit (epoch 5โ†’6) to Charlie only
  3. Bob never receives commit, stays at epoch 5
  4. Alice/Charlie at epoch 6, Bob at epoch 5
  5. Bob cannot decrypt messages from epoch 6

Current Protection: โŒ None

Mitigation: Implement epoch validation and sync detection


2. Commit Injection Attackโ€‹

Scenario:

  1. Attacker intercepts commit from Alice
  2. Modifies commit (changes epoch, proposals)
  3. Sends to Bob

Current Protection:

  • โœ… Ed25519 signature verification (via ts-mls)
  • โœ… Membership tag validation
  • โŒ No application-level sender validation

Assessment: PROTECTED by ts-mls signatures


3. Replay Attackโ€‹

Scenario:

  1. Attacker captures legitimate commit/message
  2. Replays to victim later

Current Protection: โŒ None

Impact:

  • Old messages re-accepted
  • Could cause state confusion
  • May bypass access controls

Mitigation: Implement timestamp validation (24-hour window)


Comparison with RFC 9420 Requirementsโ€‹

Section 16: Security Considerationsโ€‹

RFC 9420 ยง16 RequirementStatusNotes
Message confidentialityโœ…AES-128-GCM
Message authenticationโœ…Ed25519 + AEAD
Member authenticationโœ…Credentials in leaf nodes
Forward secrecyโœ…Epoch-based ratcheting
Post-compromise security๐ŸŸกRequires active users
DoS resistanceโŒNo size limits
Replay protectionโŒMissing
Privacy protection๐ŸŸกMetadata exposed

Recommendationsโ€‹

Critical (P0)โ€‹

  1. Implement epoch validation

    • Verify epoch = current + 1
    • Reject rollback attempts
    • Detect desynchronization
  2. Add replay protection

    • Timestamp validation (24-hour window)
    • Nonce tracking for commits
    • Sequence number validation
  3. Implement size limits

    • Max tree size (20,000 nodes)
    • Max members per group (1,000)
    • Max commit size

High (P1)โ€‹

  1. Add state synchronization detection

    • Track expected epoch per member
    • Detect desynchronized members
    • Implement resync protocol
  2. Add commit sender validation

    • Verify sender is current member
    • Verify sender has permission (admin check)
  3. Implement inactive user detection

    • Track last activity per member
    • Warning for inactive members
    • Consider Quarantined-TreeKEM (2024 research)

Conclusionโ€‹

Protocol Implementation: ๐ŸŸก MODERATE

Strengths:

  • โœ… Core RFC 9420 protocol correctly implemented
  • โœ… Forward secrecy via epoch ratcheting
  • โœ… Correct signature scheme (Ed25519 not ECDSA)
  • โœ… Proper TreeKEM structure maintenance
  • โœ… Authentication and integrity via signatures + AEAD

Critical Gaps:

  • โŒ No epoch validation (rollback possible)
  • โŒ No replay protection
  • โŒ No synchronization detection
  • โŒ No DoS protection (size limits)
  • โš ๏ธ Inactive user vulnerability

Recommendation: Implement P0 fixes before production deployment.