Skip to content

--encryption-key and --old-encryption-key flags are interpreted as RAW bytes, limiting available entropy #1410

Closed

Description

@boazy

Bug Report

(I apologize ahead if this should be better classified as a feature request, since this would requiring breaking compatibility or adding a new feature)

When parsing --encryption-key and --old-encryption-key, the provided string is just converted to raw bytes, instead of being parsed as base64 or hex as is usually the case with encryption keys. This means that some byte values (e.g. the NUL byte) can't be easily supplied, and other byte values (1-31, 127-255) are hard to supply in a consistent way. With only 95 safe character values per byte, we lose 1.5 bits of entropy on the byte, so a nominally 128-bit key will only have 104 bits of entropy available and a 256-bit key would have 208 bits of entropy.

Parsing keys as hex-encoded or base64-encoded values will easily solve the issue, but is going to break down backward compatibility quite spectacularly, so Concourse will need to support a new set of arguments, e.g. --encryption-key-hex and --old-encryption-key-hex or --encryption-key-base64 and --old-encryption-key-base64.

Activity

  1. waweber commented on Jul 14, 2021

    @waweber

    Hello from 2021!

    Sometimes people like to use a file to store secrets in (e.g. docker secrets) and have an environment variable contain the path to the file instead of the secret itself, because environment variable values can end up being displayed in several places.

    Maybe an easy-ish solution here is to provide a --encryption-key-file arg and CONCOURSE_ENCRYPTION_KEY_FILE variable, which if set, reads raw bytes from the file and uses that for the key? Then we don't have to worry about encodings, and we also keep the key value out of env vars/cmdline.

  2. taylorsilva commented on Jan 6, 2025

    @taylorsilva
    Member

    I don't know enough about encryption to comment on this, but it sounds like a reasonable thing that should be done at some point. Anyone is free to make a PR addressing this.

  3. samuelBarreto commented on Apr 19, 2026

    @samuelBarreto
    Contributor

    Hi! I'd like to work on this issue. My plan is to add CipherHex and CipherBase64 types to the concourse/flag package, and then add --encryption-key-hex, --encryption-key-base64 (and their --old- variants) flags to the CLI. The existing --encryption-key flag would remain unchanged for backward compatibility. Does this approach sound good?

  4. samuelBarreto commented on Apr 20, 2026

    @samuelBarreto
    Contributor

    Step 1 (done): I opened a PR in the concourse/flag package adding CipherBase64 and CipherHex types:

    Changes in concourse/flag:

    • Added CipherBase64 type — decodes base64 before creating the AES-GCM cipher
    • Added CipherHex type — decodes hex before creating the AES-GCM cipher
    • Extracted shared unmarshalCipher helper to avoid duplication
    • Existing Cipher type remains unchanged (fully backward compatible)
    • Full test coverage (7 tests passing)

    Step 2 (waiting for flag PR merge): I'll open a follow-up PR in concourse/concourse to add the new CLI flags:

    • --encryption-key-base64 / --old-encryption-key-base64
    • --encryption-key-hex / --old-encryption-key-hex

    I've already validated locally that the new flags compile and appear in concourse web --help using docker-compose with a replace directive pointing to my fork.

    Image
  5. taylorsilva commented on Apr 20, 2026

    @taylorsilva
    Member

    Thanks Samuel! I'll check out the PR this week hopefully. Quickly skimmed your comments and I think your plan sounds good, leaving existing flags as-is and adding new ones for hex or base64 encodings. TY for picking this up!

  6. taylorsilva commented on Apr 20, 2026

    @taylorsilva
    Member

    I've merged the PR in concourse/flag. I'm going to merge that repo into the main repo here. We don't get any benefit from having flag as a separate repo and it'll be easier to manage directly in the main repo instead.

  7. taylorsilva commented on Apr 20, 2026

    @taylorsilva
    Member

    @samuelBarreto Once #9541 is merged, you can continue implementing your changes.

  8. added a commit that references this issue on Apr 20, 2026
    d8017be
  9. samuelBarreto commented on Apr 21, 2026

    @samuelBarreto
    Contributor

    Hi! I've opened a PR to resolve this issue: #9542

    Changes:

    • Added --encryption-key-base64, --encryption-key-hex and their --old- variants to the CLI
    • Updated atc/atccmd/command.go (RunCommand + Migration structs and key resolution logic)
    • Updated atc/scripts/db_decrypt.go to support the new key formats
    • The existing --encryption-key flag remains unchanged for backward compatibility
      @taylorsilva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions