mirror of
https://github.com/kerberos-io/agent.git
synced 2026-11-23 23:10:50 +00:00
Recordings were encrypted in the OpenSSL/CryptoJS "Salted__" format, which derives the AES key from the configured symmetric key with a single MD5 round. A captured recording therefore allowed fast offline guessing of weak keys. New recordings use a versioned format: magic "KRBREC1\0", the PBKDF2 iteration count, a 16-byte salt and a 12-byte nonce, followed by AES-256-GCM ciphertext. The key is derived with PBKDF2-HMAC-SHA256 (600,000 iterations) once per process and cached, so cameras do not pay the derivation cost per recording; each recording still gets a fresh nonce. The header is authenticated, and decryption caps the iteration count so a crafted file cannot stall the agent. DecryptRecording still reads the legacy format, so existing recordings keep playing through /file and -action decrypt. The legacy decryption now validates length and padding instead of panicking on truncated input or a wrong key. MQTT messages exchanged with Kerberos Hub keep the legacy format, which Hub expects; their keys are random, so the weak key derivation does not make them guessable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>