Summary
A CRI-O input validation flaw allows newline characters in the HOME environment variable to be interpreted as additional entries when writing to system files.
An attacker who can control container environment variables may inject arbitrary lines into /etc/passwd, turning misconfiguration into a host-level account manipulation risk.
Affected context
This vulnerability appears in CRI-O setups where container environment variables are used to derive or write user-related configuration on the host or within shared system files.
It becomes relevant when:
- The container runtime trusts environment variables like HOME without sanitization
- Values from these variables are written or appended to files with account or identity metadata
- The environment can be influenced by a tenant, workload orchestrator, or compromised component
Exploit preconditions
- Attack surface: Container environment configuration interface (e.g., orchestrator, pod spec, or runtime hooks)
- Required access: Ability to define or modify environment variables for a container, specifically HOME
- Trigger point: Creation or initialization of a container where CRI-O processes HOME and interacts with /etc/passwd or related user data
- Why exploitation is possible: The runtime fails to sanitize control characters and delimiters in HOME, allowing newline injection that is interpreted as separate lines when written to /etc/passwd
Why this happens
The root cause is improper input validation of environment variables used in account-related file operations.
CRI-O logic relies on the HOME environment variable and concatenates or writes its value into sensitive files without removing or encoding newline characters and other control input.
This maps to CWE-116: Improper Encoding or Escaping of Output, where data derived from potentially untrusted sources is output to a structured file format without neutralizing special characters that change the file's structure and semantics.
Potential impact
- An attacker may inject crafted lines into /etc/passwd.
- Arbitrary user accounts could be created with attacker-controlled attributes.
- Existing account behavior may be altered or broken by malformed entries.
- Host authentication and authorization logic could be subverted or destabilized.
- Containers sharing the host's identity context can be impacted by manipulated account data.
General mitigation guidance
Mitigation generally centers on treating environment-derived values as untrusted and strictly sanitizing them before use in system files.
Useful patterns include:
- Normalizing and validating environment variables like HOME against a strict character whitelist and expected format.
- Encoding or stripping control characters (newline, carriage return, null bytes) before writing data to structured files such as /etc/passwd.
- Decoupling container environment configuration from direct writes to host-level account databases where possible.
- Applying defense-in-depth with least-privilege: ensure processes that handle environment values have minimal ability to modify system-critical files.
How teams detect issues like this
Detection typically involves reviewing how runtime and tooling transform environment variables into file content.
High-level approaches include:
- Static analysis or linters to flag code paths that write environment variable values into system files without sanitization or encoding.
- Code review checklists that require validation of special characters whenever data is written to /etc/passwd or other structured configuration files.
- Runtime monitoring for anomalous changes to /etc/passwd, combined with auditing of container creation requests and environment settings.
- Policy enforcement that restricts or scrutinizes use of dynamic environment data in account or identity management routines.

