Skip to content

Security: Drealise/keepassrpc-cli

Security

SECURITY.md

Technical Details

This document covers the internal protocol and cryptographic details of KeePassRPC CLI.

Authentication Flow

KeePassRPC uses a two-stage authentication process:

Stage 1a: SRP (first-time only)

  1. Client sends SRP identifyToServer with a random username and public ephemeral A
  2. Server responds with salt s and public ephemeral B
  3. Client computes SRP proof M and sends proofToServer
  4. Server verifies M and sends proof M2
  5. Both sides derive session key K = SHA-256(S) where S is the SRP shared secret
  6. Client saves the session key locally

Stage 1b: Key Challenge (reconnection)

After the initial SRP handshake, the client reconnects and uses the stored session key:

  1. Client sends stored username
  2. Server sends a random challenge sc
  3. Client generates a random challenge cc and computes response cr = SHA-256("1" + key + sc + cc)
  4. Server verifies cr and sends its response sr = SHA-256("0" + key + sc + cc)
  5. Client verifies sr

Stage 2: Encrypted RPC

All subsequent communication uses encrypted JSON-RPC:

  • Algorithm: AES-256-CBC
  • HMAC: SHA-1
  • Key: Session key derived from SRP (K = SHA-256(S))
  • IV: Random 16 bytes per message

Protocol Parameters

  • Prime (N): 512-bit safe prime
  • Generator (g): 2
  • Key derivation constant (k): 0xb7867f1299da8cc24ab93e08986ebc4d6a478ad0
  • Hash function: SHA-256

Message Format

All messages are JSON with the following envelope:

{
  "protocol": "setup|jsonrpc",
  "srp": { ... },
  "key": { ... },
  "error": { ... },
  "jsonrpc": { ... },
  "version": 131072
}

Security Notes

  • The WebSocket connection is unencrypted (runs over localhost only)
  • Session keys are stored locally in keepassrpc-cli.auth and should be protected
  • The connection password is randomly generated by KeePass and displayed in a pop-up during SRP negotiation

There aren't any published security advisories