Skip to content

Daily user-ID salt is derived from BETTER_AUTH_SECRET, so past days stay reversible. Option for a random, discarded salt? #1380

Open

Description

@johannesdb

With "salt user IDs" enabled, the daily salt is sha256(BETTER_AUTH_SECRET + utcDay) (getDailySalt in server/src/services/userId/userIdService.ts; same code in v2.9.3 and on master today). Because it is derived from a long-lived secret, anyone holding that secret can recompute the salt for any past day and test IP + user-agent candidates against stored user_id values. The full IPv4 address is hashed, so the search space is small.

Plausible's model avoids this: a random salt per day, kept only in memory or short-lived storage and deleted after rotation, so that not even the operator can link old IDs back to an IP.

Would you consider an option (env var or site setting) for a random daily salt that is never derived from a persistent secret? For example crypto.randomBytes(32) per UTC day, stored in Redis with a TTL of about 48 hours so all workers agree within a day and a restart on the same day keeps the same salt.

It would let self-hosters state that visit IDs cannot be traced back to an IP address after 24 hours, also by the operator. Related: #714.

Happy to send a PR if the approach is acceptable.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions