Skip to content

feat(plugins): key plugin store hashes with a secret #565

Closed

Description

@uniqueg

Problem

PluginStore.key_for() (foca/plugins/store.py) derives keys for parts that may be personal data (e.g. ctx.store.key_for("budget", subject_type, subject)) as an unkeyed SHA-256 of the namespace and the parts. Anyone with access to the database or a backup who knows a user's identifier (e.g. an LS Login sub, which appears in tokens, logs and other services) can hash it again and find that user's entries. The design of the store asked for a keyed hash; the docs currently say the hash "pseudonymizes, doesn't anonymize". Found in the v0.19.0 pre-release review.

Decision (maintainer, 2026-10-31)

Optional HMAC secret, in v0.20.0:

  • New setting for the secret (e.g. plugins.defaults.store.key_secret), meant to be set from an environment variable or a mounted secret, never committed.
  • With a secret, key_for() returns HMAC-SHA256 keys with their own prefix (e.g. hk:), so they never collide with the plain h: keys.
  • Without a secret, keys stay plain SHA-256 (h:), and FOCA logs a warning once at startup when a database-backed store is used.
  • Changing or adding the secret makes existing entries unreachable until they expire (bounded by max_ttl); document this.
  • All replicas of a deployment must share the secret; the Helm library chart gets a value for it (secret reference, not a plain value).

Acceptance criteria

  • Setting, HMAC keys with their own prefix, plain fallback with a one-time warning
  • The secret never appears in logs, the plugin listing or error messages
  • Tests for both modes, the prefix, the warning and secret rotation
  • Docs: configuration reference, plugin author guide (key_for()), operator guide (secret handling, rotation, replicas), upgrade notes
  • Helm library chart value and docs

Activity

  1. added this to the v0.20.0 milestone on Oct 31, 2026
  2. added
    priority: medium
    status: triage
    type: feature
    type: security
    workload: days
    status: in progress
    and removed
    status: triage
    on Oct 31, 2026
  3. added a commit that references this issue on Nov 2, 2026
    b64f250
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumstatus: in progresstype: featuretype: securityworkload: days

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions