Threat modeling the LAN sync in my wildlife app (as a beginner)
说明与用途
为 Wildlife Incident Handoff 设计了安全的 LAN 同步功能,使用 AES‑256‑GCM、ECDH 和 HKDF,防止窃听、冒充和重放攻击,但缺乏前向保密性,且依赖手动比较指纹。
问题
Designing a secure LAN sync feature for a wildlife incident recording app to prevent data leakage and impersonation.
结果
The LAN sync feature now encrypts data, authenticates devices, and protects against replay, impersonation, and eavesdropping, though it lacks forward secrecy and relies on manual fingerprint comparison.
工作流
- Pair devices by exchanging a pairing code and approving the request on the first device.
- Generate a per‑device ECDH keypair and exchange public keys during pairing.
- Derive a shared AES‑256‑GCM key using HKDF from the ECDH secret.
- Encrypt incident records with the derived key and send over the local network.
- Include a monotonically increasing counter in each message and reject messages with old counters.
- Reject any sync requests from unpaired devices and only respond to a lightweight ping endpoint for discovery.
- When sync is disabled, reject all pairing and sync requests while keeping the listener open for discovery pings.
证据
Data is encrypted (AES-256-GCM) with a key both devices agree on (P-256 ECDH + HKDF)
Each install has its own keypair and a fingerprint you can compare
The first device has to manually approve every request
Each message carries a counter, and old counters are rejected, even after a restart
The sync endpoint rejects untrusted devices
Pairing and sync requests are rejected when sync is disabled
- 记录日期: 2026-10-10T18:55:58.554Z