fix: generate the try-it encryption key without a backslash escape - #2851
Merged
timbastin merged 1 commit intoAug 14, 2026
Merged
Conversation
`docker-compose-try-it.yaml` generated the key with `tr -d ' \n'`. A string `command:` is split by go-shellwords before any shell sees it, and the version pinned by every Compose release through v5.1.0 drops the backslash and keeps the letter, so the container ran `tr -d ' n'` and od's two line breaks stayed in the key. TrimSpace in buildGCM removes only the trailing one, so hex.Decode fails on the newline at offset 32 and the API panics on startup. `tr -dc '0-9a-f'` keeps only hex digits and carries no escape for any layer to consume. Fixes l3montree-dev#2841 Signed-off-by: Sujeito Operator <[email protected]>
Member
|
Wow that was great! Thanks a lot. Spot on! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2841.
docker-compose-try-it.yamlline 21 writes the app-side encryption key withOn Docker Compose before v5.2.0 the
\nnever reachestras a newline. Acommand:given as a string is split byshellwords.Parse(compose-go,types/command.go), and go-shellwords v1.0.12 — the version in every Composego.modI read from v2.20.0 through v5.1.0 (10 tags) —
drops the backslash and keeps the letter. The container runs
tr -d ' n', which deletesspaces and the letter
nand leavesod's two line breaks in the file. go-shellwordsv1.0.13 turns the same escape into a real newline instead, and Compose picked that up in
v5.2.0; that is why the result depends on which binary you run, and why the same
command typed into
docker run alpineis fine.Measured by feeding this file's own
command:scalar throughshellwords.Parseat eachversion and executing the argv it produces under busybox
sh:The 66-byte key is what takes the API down.
buildGCM(
services/db_encryption_service.go) callsbytes.TrimSpace, which removes the trailingnewline only; the one at offset 32 stays, and
hex.Decodethen returnsencoding/hex: invalid byte: U+000Aafter 16 of 32 bytes, soLoadDBEncryptionKeypanics on startup.The patch replaces the escape rather than repairing it.
tr -dc '0-9a-f'keeps only hexdigits and contains no backslash, so no YAML, Compose or shell layer can change its
meaning — the table above shows it is correct under both parser generations. It is also
strictly tighter than the original: nothing but a hex digit can enter the key whatever
odemits.One line, one token. Nothing else in the file is touched, and the pattern does not occur
anywhere else in the repository.
Written by an automated agent. Every figure above is a command re-run by the script that
opened this pull request, not a recollection; it refuses to open if any of them drifts.