Skip to content

Commit 2443c80

Browse files
committed
fix(openbao): quote the Secret names and constrain them to DNS-1123 subdomains
seal.secretName landed in the render as name: {{ $seal.secretName }} under server.extraVolumes, and both Secret names are also part of the current_key and previous_key HCL strings. A value carrying a quote, a colon or a newline became structure there instead of a string, and nothing above the chart stopped it, because the generated schema had no pattern and the apps API only defaults against that schema. The YAML site now quotes the value, and both fields carry the DNS-1123 subdomain pattern and the 253 character limit that a Secret name has to satisfy anyway. The pattern allows the empty string, which is the default for the Shamir seal. The suite renders a dotted name through the volume and the key path and rejects a name with a quote. Assisted-by: LLM Signed-off-by: Yan Bondarenko <[email protected]>
1 parent 5ac585d commit 2443c80

6 files changed

Lines changed: 50 additions & 5 deletions

File tree

‎api/apps/v1alpha1/openbao/types.go‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/apps/openbao/templates/openbao.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ spec:
9393
# The upstream chart mounts each Secret at /openbao/userconfig/<name>/.
9494
extraVolumes:
9595
- type: secret
96-
name: {{ $seal.secretName }}
96+
name: {{ $seal.secretName | quote }}
9797
{{- with $seal.previousSecretName }}
9898
- type: secret
99-
name: {{ . }}
99+
name: {{ . | quote }}
100100
{{- end }}
101101
{{- end }}
102102
{{- if gt (int .Values.replicas) 1 }}

‎packages/apps/openbao/tests/seal_test.yaml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,36 @@ tests:
324324
- matchRegex:
325325
path: spec.values.openbao.server.ha.raft.config
326326
pattern: 'seal "static"'
327+
328+
- it: "renders a dotted Secret name as a plain string in the volume and in the key path"
329+
set:
330+
seal:
331+
type: static
332+
secretName: openbao.unseal
333+
keyId: key-1
334+
previousSecretName: openbao.unseal.old
335+
previousKeyId: key-0
336+
documentSelector:
337+
path: kind
338+
value: HelmRelease
339+
asserts:
340+
- equal:
341+
path: spec.values.openbao.server.extraVolumes
342+
value:
343+
- type: secret
344+
name: openbao.unseal
345+
- type: secret
346+
name: openbao.unseal.old
347+
- matchRegex:
348+
path: spec.values.openbao.server.standalone.config
349+
pattern: 'current_key = "file:///openbao/userconfig/openbao\.unseal/key"\n\s+previous_key_id = "key-0"\n\s+previous_key = "file:///openbao/userconfig/openbao\.unseal\.old/key"'
350+
351+
- it: "rejects a Secret name that is not a DNS-1123 subdomain"
352+
set:
353+
seal:
354+
type: static
355+
secretName: 'openbao"unseal'
356+
keyId: key-1
357+
asserts:
358+
- failedTemplate:
359+
errorPattern: 'secretName'

‎packages/apps/openbao/values.schema.json‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,16 @@
160160
"previousSecretName": {
161161
"description": "Secret holding the previous key during an n-1 key rotation. Keep it until the pods have been replaced and the active node has logged `upgrading stored keys`; see the README.",
162162
"type": "string",
163-
"default": ""
163+
"default": "",
164+
"maxLength": 253,
165+
"pattern": "^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)?$"
164166
},
165167
"secretName": {
166168
"description": "Existing Secret in the tenant namespace whose key `key` holds the base64 text of 32 random bytes (for example `openssl rand -base64 32`). A cluster administrator creates it, because tenant roles cannot create Secrets. Required when `type` is `static`.",
167169
"type": "string",
168-
"default": ""
170+
"default": "",
171+
"maxLength": 253,
172+
"pattern": "^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)?$"
169173
},
170174
"type": {
171175
"description": "Seal type. `shamir` keeps the current behaviour; `static` enables auto-unseal from `secretName`.",

‎packages/apps/openbao/values.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ ui: true
9393
## @typedef {struct} Seal - Seal configuration. With `static`, the key is read from a Secret that a cluster administrator creates in the tenant namespace. The chart never generates or rotates it.
9494
## @field {SealType} type - Seal type. `shamir` keeps the current behaviour; `static` enables auto-unseal from `secretName`.
9595
## @field {string} secretName - Existing Secret in the tenant namespace whose key `key` holds the base64 text of 32 random bytes (for example `openssl rand -base64 32`). A cluster administrator creates it, because tenant roles cannot create Secrets. Required when `type` is `static`.
96+
## @maxLength 253
97+
## @pattern ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)?$
9698
## @field {string} keyId - Permanent identifier of the current key. Change it whenever the key material changes; OpenBAO refuses a key whose identifier it has already seen with different material. Required when `type` is `static`.
9799
## @field {string} [previousSecretName] - Secret holding the previous key during an n-1 key rotation. Keep it until the pods have been replaced and the active node has logged `upgrading stored keys`; see the README.
100+
## @maxLength 253
101+
## @pattern ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)?$
98102
## @field {string} [previousKeyId] - Identifier of the previous key. Required when `previousSecretName` is set.
99103
## @field {bool} [allowMigration] - Acknowledge a seal migration. The chart refuses to change `type` on an existing instance unless this is `true`; set it only while running `bao operator unseal -migrate`, then remove it.
100104

‎packages/system/openbao-rd/cozyrds/openbao.yaml‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)