-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
File Paths:
/engy/src/engy/produce_files.py
/engy/src/engy/app_builder.py
Risk Description:
The current implementation writes LLM-generated content directly to files without proper validation or sanitization. This introduces multiple risks:
- Path Traversal Attacks — Malicious filenames such as
../../malicious.pycould lead to unauthorized file access or overwrite. - Executable Code Injection — Malicious code could be injected into output files, leading to security breaches if executed.
- Overwriting Critical Files — Important system or project files could be unintentionally or maliciously overwritten.
Vulnerable Code Patterns:
- In
produce_files.py:
# No validation on filename or content
with open(filename, "w") as f:
f.write(block_content) - In
app_builder.py:
# Directly passes LLM output to produce_files()
produce_files(responses[0]) Suggested Fixes:
- Validate Filenames: Enforce a whitelist of allowed file extensions and prevent directory traversal (e.g., reject
../or absolute paths). - Scan File Content: Use regex or static analysis to detect and block potentially harmful content such as executable code.
- Restrict Write Locations: Limit all file writes to a controlled, sandboxed directory to contain potential damage.
- User Confirmation: Prompt the user for confirmation before creating or overwriting files, especially outside the default workspace.
Metadata
Metadata
Assignees
Labels
No labels