Summary
A symlink-handling vulnerability in Incus affects the record-output behavior of the instance execution endpoint. When an attacker can cause the exec-output directory to be a symlink, command output files may be written to an unintended location, potentially enabling arbitrary command execution.
Affected context
The issue occurs in Incus instance execution workflows that enable the record-output parameter on the /instances/$name/exec endpoint. Risk depends on the exec-output directory being controllable as a symlink and on the resulting output files being written with permissions or locations that affect executable code, configuration, or other security-sensitive resources.
Exploit preconditions
- Attack surface: The instance execution API and its output-recording path
- Required access: Sufficient access to invoke the endpoint and influence
the relevant instance filesystem or directory state
- Trigger point: Creation of stdout and stderr output files after an
executed command requests output recording
- Why exploitation is possible: The file-writing logic follows a
symlinked output directory instead of ensuring that the destination remains
within the intended path
Why this happens
The underlying bug is failure to treat a filesystem path component as untrusted when creating output files. File operations follow a symbolic link supplied or influenced through the instance environment, allowing a pathname intended for an internal output directory to resolve elsewhere. This maps to CWE-73, External Control of File Name or Path, because external influence over path resolution can redirect writes to security-sensitive locations.
Potential impact
- An attacker may overwrite files outside the intended exec-output directory.
- Arbitrary content could be placed in executable scripts, configuration
files, or other sensitive paths.
- The affected host or instance may execute attacker-controlled commands.
- Confidential data or service availability could be impacted.
- A compromised instance could provide a path toward broader infrastructure
compromise, depending on privileges and isolation controls.
General mitigation guidance
Mitigation generally focuses on preventing symlink-based path redirection and
reducing the consequences of unintended file writes.
Common defensive patterns include:
- Opening output files using symlink-resistant filesystem operations and
directory-relative handles where supported.
- Verifying that the resolved destination remains within the intended output
directory before writing.
- Using exclusive file creation and rejecting pre-existing symbolic links.
- Treating instance-controlled paths as untrusted input.
- Applying restrictive permissions and least-privilege identities to the
service and managed instances.
- Limiting which files and directories can be affected by command output.
- Using secure-by-default output locations and narrowly scoped API
authorization.
How teams detect issues like this
Detection approaches may include:
- Static analysis rules for file creation or open operations that follow
attacker-influenced paths without symlink protections.
- Code review checks for filesystem writes beneath instance-controlled
directories.
- Tests that exercise symbolic-link substitution and verify containment of
all generated output files.
- Runtime monitoring for output files appearing outside the approved
exec-output directory.
- Policy enforcement that restricts execution API access and records unusual
output-path behavior.
Automated security review tools can help identify path-resolution and
symlink-handling patterns during development.

