Sync conflicts resolved with clear user-facing strategy
Why it matters
When a user edits data offline while the server receives a concurrent update from another session, a Last-Write-Wins strategy without field-level timestamps will silently discard one of the changes. CWE-362 (Race Condition) and CWE-694 are both implicated. ISO 25010:2011 reliability.recoverability requires that the system resolves conflicts without data loss. The failure mode is particularly damaging in collaborative tools or multi-device workflows: users believe their changes were saved, but the data they see after sync reflects a different device's state. Silent data loss is harder to detect than visible errors and more damaging to user trust.
Severity rationale
High because unresolved sync conflicts cause silent data loss or overwrites, which users discover only after the damage is done and may not be recoverable.
Remediation
Implement field-level timestamps on every mutable field and a deterministic merge function. Apply the merge during sync rather than overwriting the local or remote record wholesale.
interface Record {
id: string;
title: string; titleAt: number;
description: string; descriptionAt: number;
}
function merge(local: Record, remote: Record): Record {
return {
id: local.id,
title: local.titleAt > remote.titleAt ? local.title : remote.title,
titleAt: Math.max(local.titleAt, remote.titleAt),
description: local.descriptionAt > remote.descriptionAt ? local.description : remote.description,
descriptionAt: Math.max(local.descriptionAt, remote.descriptionAt),
};
}
async function syncRecord(id: string) {
const [local, remote] = await Promise.all([getLocal(id), fetchRemote(id)]);
if (local && remote) {
const merged = merge(local, remote);
await saveLocal(merged);
await pushRemote(merged);
}
}
For fields that cannot be field-merged (e.g., binary blobs), surface a conflict prompt to the user rather than silently picking a winner.
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 Mobile Offline & Storage Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-362 — Concurrent Execution Using Shared Resource with Improper Synchronization (Race Condition)
- iso-25010:2011 · reliability.recoverability — Recoverability
- cwe · CWE-694 — Use of Multiple Resources with Duplicate Identifier
Taxons
History
- 2026-04-18·v1.0.0·Initial import from mobile-offline-storage·automated