T09 · Insecure Skill Coding Practices
- Location
ppt_generator.py:88- Finding
User-Controlled Presentation Title Allows Output Path Traversal
- Content
View full analysis
Vulnerability Details
File Location:
ppt_generator.py, lines 88-91
Vulnerability Type: Path traversal and arbitrary file creation
Risk Level: Highpython output_directory = ensure_directory(output_dir) output_path = output_directory / f"{title.replace(' ', '_')}_{timestamp_str()}.pptx" prs.save(str(output_path)) logger.info("create_ppt completed output=%s", output_path)Technical Analysis
The public
create_ppt()interface accepts a caller-controlledtitle, which is incorporated into the output filename. The only transformation replaces spaces with underscores. It does not remove path separators, traversal components, absolute path prefixes, or platform-specific special characters.When
pathlib.Pathjoins a directory with an absolute right-hand path, the original directory is discarded. Therefore, a title such as/tmp/attacker/resultproduces an output path outside the intendedppt_skill/outputdirectory. Relative traversal components such as../may also escape the output directory when the resulting parent directories exist.The final
prs.save()operation writes to the resulting attacker-influenced path without resolving the destination or verifying that it remains inside the configured output directory.Attack Path
- An attacker supplies a path-shaped title to the agent-facing
create_ppt()API. main.create_ppt()forwards the title unchanged toppt_generator.create_ppt().- The implementation only replaces spaces and retains absolute-path or traversal syntax.
Pathconstructs a destination outside the intended output directory.prs.save()creates or replaces a.pptxfile at that unintended destination.
Impact Assessment
An attacker can cause arbitrary
.pptxfile creation or replacement at locations writable by the process account. The vulnerability does not directly grant additional operating-system privileges, but it crosses the intended ...[truncated 335 chars]- An attacker supplies a path-shaped title to the agent-facing
- Remediation
View remediation
Remediation Suggestions
- Do not derive filesystem paths directly from presentation titles. Generate the stored filename using a server-controlled UUID or cryptographically random identifier.
- If a human-readable component is required, reduce the title to a basename and allow only a strict character set such as letters, digits, underscores, and hyphens.
- Resolve both the output directory and candidate destination with
Path.resolve(), then verify that the destination is a child of the approved output directory before writing. - Reject absolute paths,
..components, directory separators, drive prefixes, and empty sanitized names. - Use exclusive file creation or another collision-resistant mechanism to prevent unintended replacement of an existing destination.
- Keep the original title only as presentation metadata rather than using it as a filesystem path.
