Summary
A path traversal vulnerability in MetaGPT's SPO extension allows attacker-controlled file names to escape the intended settings directory.
If an attacker can influence the FILE_NAME value, the application may open and disclose arbitrary files accessible to its runtime account.
Affected context
The vulnerability occurs in the SPO extension's file-loading logic, specifically where the FILE_NAME value is combined with a configured settings directory before being opened. It becomes risky when this value can be influenced by an untrusted party and the resulting path is not canonicalized and checked against the permitted directory.
Exploit preconditions
- Attack surface: The SPO extension's file-loading functionality
- Required access: The ability to supply or influence the FILE_NAME value
- Trigger point: Calls to
set_file_name()andload_meta_data()that construct and open the target path - Why exploitation is possible: The application joins attacker-controlled path content with a trusted directory without verifying that the resolved path remains within that directory
Why this happens
The underlying bug is insufficient validation of a user-controlled filesystem path. Joining a trusted directory with untrusted path content does not prevent traversal when the input can contain path components that resolve outside the intended location. This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because the application opens the resolved path without enforcing the intended directory boundary.
Potential impact
- Sensitive configuration, credentials, or source files may be disclosed
- Application secrets or environment-specific data could be exposed
- Information gathered from local files may support follow-on attacks
- The runtime account's readable data could be accessed beyond the intended settings directory
General mitigation guidance
Mitigation generally focuses on reducing trust in file-name inputs and enforcing filesystem boundaries before opening files.
Common defensive patterns include:
- Accepting only allowlisted file identifiers or constrained base names where possible
- Canonicalizing the candidate path before access and verifying that it remains beneath the permitted directory
- Rejecting absolute paths, traversal components, and unexpected separators
- Using filesystem APIs or sandboxed storage abstractions that expose only approved resources
- Running the application with the least filesystem permissions necessary
- Avoiding storage of credentials and other sensitive data in directories readable by the application
How teams detect issues like this
Organizations can detect path traversal risks through:
- Static analysis rules for filesystem APIs receiving request-derived or configuration-derived path values
- Code review checks for string concatenation or path joining without canonical boundary validation
- Tests that verify rejected paths cannot resolve outside approved directories
- Runtime monitoring for unusual file access by the SPO process
- Policy enforcement requiring allowlisted resource identifiers and least-privilege filesystem access
Automated code review and security scanning tools may help identify missing path normalization and containment checks.

