Each message carries a monotonic sequence number enabling gap detection
Why it matters
Without monotonic sequence numbers, clients have no way to detect that messages were dropped during a network disruption. A user rejoining after a brief outage will see the conversation with silent gaps — no indication that messages are missing. CWE-354 (Improper Validation of Integrity Check Value) covers this class of missing-integrity-signal failure. In a community app, undetected gaps corrupt conversation context, cause replies to appear to reference messages that were never received, and erode user trust in the platform's reliability.
Severity rationale
High because clients cannot detect dropped messages during network outages, silently corrupting conversation state and breaking reply threading.
Remediation
Attach a per-channel monotonic sequence counter to every outgoing message at the server. Clients compare consecutive sequence numbers to detect gaps and trigger a catch-up request.
const channelSeq = new Map<string, number>();
socket.on('send_message', (data: { channel: string; content: string }) => {
const seq = (channelSeq.get(data.channel) ?? 0) + 1;
channelSeq.set(data.channel, seq);
const message = {
id: nanoid(),
seq,
channel: data.channel,
content: data.content,
userId: socket.userId,
timestamp: Date.now(),
};
io.to(data.channel).emit('message', message);
});
For multi-instance deployments, store the counter in Redis (INCR channel:{id}:seq) rather than in process memory so the sequence is consistent across pods.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Real-Time Communication Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-354 — Improper Validation of Integrity Check Value
- iso-25010:2011 · security.integrity — Integrity — monotonic sequence numbers enable message-stream gap detection
Taxons
History
- 2026-04-18·v1.0.0·Initial import from community-realtime·automated