Summary
A directory traversal vulnerability in agentic-context-engine up to version 0.7.1 allows arbitrary file writes through the checkpoint_dir parameter in OfflineACE.run.
Because file paths are not normalized or validated in save_to_file (ace/skillbook.py), an attacker who can influence checkpoint paths may write outside the intended directory and overwrite arbitrary files accessible to the application process.
Affected context
This issue occurs in deployments using the OfflineACE.run workflow where checkpointing is enabled and the checkpoint_dir parameter is influenced by user-controlled or externally sourced input.
The vulnerability is present when save_to_file in ace/skillbook.py constructs file paths by concatenating user-provided segments with a base checkpoint directory without canonicalization, normalization, or confinement checks.
Any environment where the application runs with permissions to write to sensitive locations (e.g., configuration directories, scripts, or service files) is particularly exposed.
Exploit preconditions
- Attack surface: Interfaces (CLI, API, config files, orchestration layers) that pass
checkpoint_diror related path components intoOfflineACE.run. - Required access: Ability to supply or modify the checkpoint directory value or any upstream input that is used to construct it.
- Trigger point: Execution of
OfflineACE.runleading to a call tosave_to_file, which writes checkpoints based on the unvalidated path. - Why exploitation is possible: The code trusts the provided checkpoint path, performing no normalization, traversal filtering, or confinement to a designated root directory, allowing
../sequences to escape the intended folder and target arbitrary writable paths.
Why this happens
The underlying bug is a classic path traversal issue aligned with CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
Instead of treating path segments as untrusted and constraining them to a specific base directory, the implementation directly combines the checkpoint_dir value with filenames and passes the resulting path to filesystem write APIs.
Without normalization (e.g., resolving .. components) and explicit checks that the final resolved path still resides under the intended checkpoint root, attackers can craft traversal sequences that redirect writes to arbitrary locations.
This pattern reflects a broader anti-pattern: constructing filesystem paths from external input without applying canonicalization, allowlisting, or sandbox-style directory enforcement.
Potential impact
- Overwriting application configuration files, which may alter runtime behavior or disable security controls.
- Overwriting code files, scripts, or plugins loaded by the application, which could lead to arbitrary code execution on subsequent runs.
- Corruption of application state or model/checkpoint data, potentially causing denial of service or degraded functionality.
- Tampering with logs, cache files, or other local artifacts, which may affect observability or incident response.
- In environments with shared paths or elevated write permissions, potential privilege escalation via modification of startup scripts or service units.
General mitigation guidance
Effective mitigation focuses on treating all path input as untrusted and strictly confining file operations to controlled directories:
- Normalize and canonicalize paths before use (e.g., using standard library utilities) and verify that the resolved path remains under a designated checkpoint root directory.
- Avoid directly concatenating user-controlled strings with filesystem paths; instead, use join functions with pre-validated identifiers or generated filenames.
- Apply a strict allowlist for checkpoint locations (e.g., selecting from predefined directories) rather than accepting arbitrary paths from outside the trust boundary.
- Run the application with least-privilege filesystem permissions so that, even if a traversal occurs, sensitive system paths and executable locations are not writable.
- Where feasible, isolate checkpoint storage (e.g., via container volumes or chroot-like mechanisms) to limit the blast radius of any file write operations.
How teams detect issues like this
Organizations can detect and monitor for this class of vulnerability using a combination of code-centric and runtime approaches:
- Static analysis: Configure rules that flag direct use of user-influenced path strings in file write operations (e.g.,
open,write, or library wrappers) without preceding normalization and base-path checks. - Code review: During manual reviews, pay special attention to functions like
save_to_fileand any logic that combines external input with filesystem paths, ensuring there is explicit confinement to an expected directory. - Policy enforcement: Introduce development guidelines that require all file IO entry points to validate paths against a known-safe root and document this as a mandatory checklist item for features involving persistence.
- Runtime monitoring: Where possible, use audit logs or OS-level monitoring to detect unexpected write attempts outside designated data directories by the application process, which may reveal exploitation or misuse.
- Automated security scanning tools and SAST platforms can be configured or tuned to recognize path traversal patterns and highlight them during CI pipelines.

