-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Vault 1.20.3 introduced JSON configurable limits to HTTP handling for JSON payloads: max_json_depth
, max_json_string_value_length
, max_json_object_entry_count
, max_json_array_element_count
(#31069)
The max_json_string_value_length
defaults to 1024 * 1024
. We configured it to 1024 * 1024 * 32
in our listener
configuration. However, despite this, encrypt
and decrypt
payloads on transit secret engine with JSON strings bigger than 1 MB (but smaller than 32 MB) return error 500: JSON string value exceeds allowed length.
- We tried to pass the parameter both as a string and as a number.
- We left the
max_request_size
to its default (32 MB)
To Reproduce
Steps to reproduce the behavior:
- Run
cat big_file.txt | base64 | jq -Rs '{plaintext: .}' | vault write transit/encrypt/my-key -
(wherebig_file.txt
is a 1.2 MB text file) - See error
JSON string value exceeds allowed length
Expected behavior
We expect the error to be returned with JSON payloads bigger than the value provided in the config (32 MB), not the default value (1 MB)
Environment:
- Vault Server Version: 1.20.3
- Vault CLI Version (retrieve with
vault version
): 1.20.3 - Server Operating System/Architecture: cos-117 / X86_64
Vault server configuration file:
ui = true
cluster_addr = "https://**********"
api_addr = "https://***********"
listener "tcp" {
telemetry {
unauthenticated_metrics_access = true
}
address = "0.0.0.0:8200"
cluster_address = "0.0.0.0:8201"
tls_cert_file = "/vault/ssl/vault.crt"
tls_key_file = "/vault/ssl/vault.key"
max_json_string_value_length = 33554432 # also "33554432" doesn't work
max_request_duration = "52s"
x_forwarded_for_authorized_addrs = "*******************"
x_forwarded_for_hop_skips = "1"
x_forwarded_for_reject_not_authorized = "true"
x_forwarded_for_reject_not_present = "false"
}
telemetry {
disable_hostname = true
prometheus_retention_time = "24h"
}
plugin_directory = "/vault/plugins"
storage "postgresql" {
connection_url = "***************"
ha_enabled = "true"
}
seal "gcpckms" {
project = "***********"
region = "global"
key_ring = "**********"
crypto_key = "*************"
}
Additional context
- We did not explicitly configure the transit cache
- The listener documentation page does not mention these new parameters.
- For the moment, we are rolling back to version 1.20.2 to mitigate this.