-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Security Hardening: Command Injection & Path Traversal Opportunities in PAI/Tools (Findings from PAI-OpenCode Updating Process) #904
Description
Security Hardening: Command Injection & Path Traversal Opportunities in PAI/Tools (WP1 Findings from PAI-OpenCode Port)
Hi Daniel,
First of all, thank you for PAI - it's an incredible system that's fundamentally changed how I work with AI. The community around it (PAI-OpenCode) is growing, and during our v3.0 porting effort we identified several security hardening opportunities in PAI 4.0.3 that we wanted to share upstream for potential inclusion in v4.1.0.
Context
During the PAI-OpenCode v3.0 port (migrating to OpenCode platform while maintaining PAI's core philosophy), we performed a security audit of the PAI/Tools/ directory. We found 9 critical security patterns that could benefit from hardening.
Findings Summary
| Category | Tool | Issue | Risk Level |
|---|---|---|---|
| Command Injection | AddBg.ts | execAsync() interpolates user-controlled inputPath and hexColor directly into shell command | Critical |
| Command Injection | GetTranscript.ts | execSync() interpolates URL directly into fabric command without validation | Critical |
| Command Injection | RelationshipReflect.ts | execSync() interpolates message and NTFY_TOPIC into curl command | Critical |
| Path Traversal | FeatureRegistry.ts | project parameter used directly in filename without sanitization | High |
| Path Traversal | SessionProgress.ts | project parameter used directly in filename without sanitization | High |
| Path Traversal | PipelineOrchestrator.ts | Pipeline name used directly in file path construction | High |
| XSS | PipelineMonitor.ts | innerHTML injects user-controlled fields without sanitization | High |
| XSS | PreviewMarkdown.ts | marked.parse() result assigned to innerHTML without sanitization | High |
| Logic | BuildCLAUDE.ts / RebuildPAI.ts | Double .md.md extension when LATEST file contains .md | Medium |
Recommended Fixes
All fixes follow the same patterns we implemented in PAI-OpenCode:
- Command Injection → Use execFile/execFileSync with array arguments
- Path Traversal → Validate input against allowed character set
- XSS → HTML escape or sanitize before innerHTML
- .md.md Extension → Normalize version string
Our Implementation
We've implemented these fixes in PAI-OpenCode during the v3.0 port (see PR #33 Steffen025/pai-opencode#33) and can contribute them back as a PR to PAI if helpful.
Question for v4.1.0
Would you like us to:
- Create a PR with these security hardening fixes for v4.1.0?
- Wait and include these in a larger security audit for v4.1.0?
- Document these as "user responsibility" (since PAI is personal infrastructure)?
We wanted to share these findings upstream because we believe security hardening benefits the entire PAI ecosystem. Happy to collaborate however is most helpful for your v4.1.0 roadmap.
Best regards,
Steffen Zellmer
PAI-OpenCode
PS: We'll continue monitoring for security patterns in upcoming Work Packages (WP2-WP7) and will add findings as comments to this issue if new categories emerge.