Summary
The Butane YAML template in internal/ignition/ignition.go uses Go's text/template package, which performs zero escaping of interpolated values. User-supplied strings (hostnames, usernames, SSH keys, sysext names) are inserted directly into double-quoted YAML strings without any YAML-safe escaping.
While hostname and username validation prevents most dangerous characters, SSH key comments are not validated for content — only the key type prefix is checked. A crafted SSH key comment containing a double quote could break the YAML structure.
Example
An SSH public key with a crafted comment:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample user"
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEvil injected@key
This is a valid SSH key format (passes validate.SSHPublicKey() since it starts with a valid type and has 2+ fields). When templated:
ssh_authorized_keys:
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample user"
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEvil injected@key"
This could inject additional YAML content. While butane's --strict compilation may catch malformed YAML, the defense should be at the template layer, not relying on downstream validation.
Template Location
// internal/ignition/ignition.go line 74+
const butaneTemplate = `...
{{- range .SSHKeys}}
- "{{.}}" // ← raw interpolation, no escaping
{{- end}}
Suggested Fix
Either:
- Validate SSH key comments don't contain quotes/newlines in
validate.SSHPublicKey()
- Use a YAML library to generate the config instead of string templating
- At minimum, escape double quotes in interpolated values
Severity
Medium — Requires a specifically crafted SSH key. Butane --strict may catch the broken YAML, but this is defense-in-depth. The SSH key validation should reject keys with double quotes in comments regardless.
Summary
The Butane YAML template in
internal/ignition/ignition.gouses Go'stext/templatepackage, which performs zero escaping of interpolated values. User-supplied strings (hostnames, usernames, SSH keys, sysext names) are inserted directly into double-quoted YAML strings without any YAML-safe escaping.While hostname and username validation prevents most dangerous characters, SSH key comments are not validated for content — only the key type prefix is checked. A crafted SSH key comment containing a double quote could break the YAML structure.
Example
An SSH public key with a crafted comment:
This is a valid SSH key format (passes
validate.SSHPublicKey()since it starts with a valid type and has 2+ fields). When templated:This could inject additional YAML content. While butane's
--strictcompilation may catch malformed YAML, the defense should be at the template layer, not relying on downstream validation.Template Location
Suggested Fix
Either:
validate.SSHPublicKey()Severity
Medium — Requires a specifically crafted SSH key. Butane
--strictmay catch the broken YAML, but this is defense-in-depth. The SSH key validation should reject keys with double quotes in comments regardless.