Summary
A path traversal flaw in the LLaMA-Factory WebUI involves the config_path argument used by the save_args and load_args functions. If an attacker can reach the affected functionality remotely and influence this path, they may cause file operations to target locations outside the intended configuration directory.
Affected context
The issue is associated with the WebUI component in LLaMA-Factory and the save_args and load_args functions in src/llamafactory/webui/runner.py. It may arise when a remotely supplied or influenced config_path is used in file operations without adequate path validation and containment checks. The precise consequences depend on which operation is reached and the permissions of the application process.
Exploit preconditions
- Attack surface: The WebUI functionality that invokes
save_argsorload_args - Required access: Remote access to the relevant functionality; the description does not specify whether authentication is required
- Trigger point: Processing a
config_pathvalue during configuration loading or saving - Why exploitation is possible: If the path is not constrained to an approved directory, traversal may direct file operations outside the intended location
Why this happens
The underlying issue is insufficient validation or containment of a path derived from config_path. CWE-22 describes improper limitation of a pathname to a restricted directory. When a program uses an externally influenced path without verifying its resolved destination, file operations may escape the intended directory boundary.
Potential impact
- An attacker may access files beyond the intended configuration directory, depending on the operation and runtime permissions.
- An attacker could cause files to be created or modified in unintended locations if the affected operation permits writes.
- Application configuration or availability may be affected if sensitive or operational files are reachable.
General mitigation guidance
Mitigation generally focuses on treating externally influenced paths as untrusted and enforcing directory boundaries before file access.
- Prefer fixed, application-controlled configuration locations over caller-supplied paths.
- Resolve and canonicalize paths, then verify that the resolved destination remains within an explicitly allowed directory.
- Apply strict input validation and reject unexpected path forms.
- Run the application with least-privilege filesystem permissions to limit the impact of path handling errors.
- Avoid exposing file operations through remotely accessible functionality unless they are necessary and appropriately access-controlled.
How teams detect issues like this
- Use static analysis to identify file operations that receive paths from request data or other untrusted sources.
- Review code paths from
config_paththroughsave_argsandload_args, checking for canonicalization and directory-containment enforcement. - Add tests and policy checks that verify paths outside approved configuration directories are rejected.
- Monitor application logs for unusual configuration paths or unexpected file access, while avoiding logging sensitive file contents.

