Skip to content

Vault 2.x billing fails with "lz4: bad magic number" #32013

Description

@danilobuerger

Describe the bug

The monthly "SSH duration-adjusted certificate count" (and the sibling SSH OTP count) is written to storage as plain, uncompressed JSON, but read back through a code path that treats the first stored byte as a compression canary. The LZ4 canary is the ASCII character '4' (0x34). Whenever the stored counter's decimal JSON representation begins with the digit 4 (e.g. 4, 4.1096, 42, 400, 4096), the reader misclassifies the plain number as LZ4-compressed data and fails:

error decoding current SSH duration adjusted cert count: failed to decompress JSON: lz4: bad magic number

To Reproduce

podman run --rm -p 8200:8200 docker.io/hashicorp/vault:2.0.3 server -dev -dev-tls -dev-root-token-id root -dev-listen-address 0.0.0.0:8200

and

export VAULT_ADDR=https://127.0.0.1:8200 VAULT_SKIP_VERIFY=true VAULT_TOKEN=root
vault secrets enable -path=ssh -max-lease-ttl=10000h ssh
vault write ssh/config/ca generate_signing_key=true
vault write ssh/roles/repro key_type=ca allow_user_certificates=true allowed_users='*' ttl=3000h max_ttl=4000h
ssh-keygen -t ed25519 -N '' -f ./id
vault write ssh/sign/repro public_key=@./id.pub ttl=3000h valid_principals=ubuntu
sleep 70
vault read sys/billing/overview

outputs:

Error reading sys/billing/overview: Error making API request.

URL: GET https://127.0.0.1:8200/v1/sys/billing/overview
Code: 500. Errors:

* 1 error occurred:
        * error building billing data for month 2026-06: error retrieving SSH duration-adjuested cert counts for current month: error decoding current SSH duration adjusted cert count: failed to decompress JSON: lz4: bad magic number

Expected behavior

Not fail with an error.

Environment:

  • Vault Server Version (retrieve with vault status): verified in 2.0.0 and 2.0.3
  • Vault CLI Version (retrieve with vault version): n/a
  • Server Operating System/Architecture: n/a

Vault server configuration file(s):

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUsed to indicate a potential bugcore/metric

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions