Summary
A path traversal vulnerability in FreeCAD's FCStd archive restoration process may allow crafted document archives to write attacker-controlled content outside the intended transient directory. When a user opens a specially crafted archive, this could enable persistence, credential compromise, configuration replacement, or code execution depending on the user's permissions and system layout.
Affected context
The issue occurs in FreeCAD versions before 1.1.2 when the document restoration logic processes a FileIncluded attribute from Document.xml and uses it to locate a corresponding ZIP archive entry. Risk is present when a crafted .FCStd file is opened and the restoring process does not sufficiently constrain absolute paths, directory components, or parent-directory traversal.
Exploit preconditions
- Attack surface: FreeCAD document archive import and restoration
- Required access: Ability to provide or induce the user to open a crafted
.FCStddocument - Trigger point: Restoration of an included file referenced by the archive's
Document.xml - Why exploitation is possible: Attacker-controlled path data is combined with a transient directory without adequately rejecting absolute paths or traversal components, allowing writes beyond the intended location
Why this happens
The underlying bug is insufficient path validation during extraction of archive-contained files. PropertyFileIncluded::Restore() uses attacker-controlled file or data attributes to construct an output path, but does not reliably constrain the result to the intended transient directory. This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal.
Potential impact
- Attacker-controlled files may be written to arbitrary locations accessible to the FreeCAD user
- User or application configuration files could be replaced or modified
- Persistence mechanisms may be established in writable startup or configuration locations
- Credentials or other sensitive data may be compromised indirectly
- Code execution could occur if written content is later loaded or executed by the operating system or another application
General mitigation guidance
Mitigation generally focuses on enforcing a strict extraction boundary and treating archive metadata as untrusted input.
Common defensive patterns include:
- Canonicalizing candidate paths before writing and verifying that they remain within the designated extraction directory
- Rejecting absolute paths, parent-directory components, directory separators where inappropriate, and ambiguous path representations
- Resolving archive entry names independently from user-controlled destination paths
- Applying strict allowlists for supported file names and expected document structures
- Using least-privilege operating-system accounts and limiting writable locations available to the application
- Keeping document processing isolated from sensitive configuration and credential stores
- Handling archive extraction failures safely without partially writing unintended files
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules that identify archive extraction combined with untrusted path concatenation
- Code review checks for missing canonicalization and containment validation
- Tests using absolute paths, parent traversal components, encoded separators, and mixed path formats
- Runtime monitoring for unexpected file creation outside approved document or temporary directories
- Policy enforcement requiring archive extractors to use safe destination APIs and explicit path allowlists
- Automated security review tools that flag file-write operations influenced by archive metadata

