ory / ory/docs

Kratos cookie secret length requirement unclear

Open
#2,333 1 comment 0 reactions 1 assignee View on GitHub

@unatasha8 is already working on this.

Since Nov 20, 2025.

bug
Dominant language
TypeScript
Stars
161
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Preflight checklist
Ory Network Project

No response

Describe the bug

From the docs:

  1. Secrets must be 32-character-long strings
  2. These secrets must have high entropy (>= 256 bit)

So let's play the password game!
Assuming 1 character = 1 byte, this suggest yaml-escaping 32 raw bytes. More than 256 bit entropy would be impossible, unless unicode characters are allowed, but I've never seen emojiis in (cookie) secrets.

To make it more sane, I'd expect kratos to hash the passed value before usage, regardless of the length of the value to extract full entropy, and exactly that seems to be done: https://github.com/ory/kratos/blob/50f1b8f0df8636cea94d1100c1dc68dd8f6bdfc5/driver/registry_default.go#L530-L534

IMHO, the documentation should be updated to remove the secret length requirement.

Reproducing the bug

Open https://www.ory.com/docs/kratos/guides/select-cipher-algorithm#xchacha20-poly1305 and https://www.ory.com/docs/kratos/guides/secret-key-rotation and follow the guide rigorously.

Relevant log output
The bug is in the documentation.
Relevant configuration
The bug is in the documentation.
Version

The bug is in the documentation.

On which operating system are you observing this issue?

None

In which environment are you deploying?

None

Additional Context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.