coolify/app/Livewire/Project
Andras Bacsai cb1f571eb4 fix: prevent command injection in Docker Compose parsing - add pre-save validation
This commit addresses a critical security issue where malicious Docker Compose
data was being saved to the database before validation occurred.

Problem:
- Service models were saved to database first
- Validation ran afterwards during parse()
- Malicious data persisted even when validation failed
- User saw error but damage was already done

Solution:
1. Created validateDockerComposeForInjection() to validate YAML before save
2. Added pre-save validation to all Service creation/update points:
   - Livewire: DockerCompose.php, StackForm.php
   - API: ServicesController.php (create, update, one-click)
3. Validates service names and volume paths (string + array formats)
4. Blocks shell metacharacters: backticks, $(), |, ;, &, >, <, newlines

Security fixes:
- Volume source paths (string format) - validated before save
- Volume source paths (array format) - validated before save
- Service names - validated before save
- Environment variable patterns - safe ${VAR} allowed, ${VAR:-$(cmd)} blocked

Testing:
- 60 security tests pass (176 assertions)
- PreSaveValidationTest.php: 15 tests for pre-save validation
- ValidateShellSafePathTest.php: 15 tests for core validation
- VolumeSecurityTest.php: 15 tests for volume parsing
- ServiceNameSecurityTest.php: 15 tests for service names

Related commits:
- Previous: Added validation during parse() phase
- This commit: Moves validation before database save

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-16 09:51:37 +02:00
..
Application fix validation on a few views 2025-10-06 21:25:24 +02:00
Database fix: add authorization checks to database Livewire components 2025-10-14 17:33:42 +02:00
New fix: prevent command injection in Docker Compose parsing - add pre-save validation 2025-10-16 09:51:37 +02:00
Resource fix: enable docker network connection for pgadmin service 2025-10-13 14:13:40 +02:00
Service fix: prevent command injection in Docker Compose parsing - add pre-save validation 2025-10-16 09:51:37 +02:00
Shared fix(environment): clear computed property cache after adding environment variables 2025-10-07 13:57:59 +02:00
AddEmpty.php fix(project): update redirect logic after resource creation to include environment UUID 2025-10-07 20:46:32 +02:00
CloneMe.php fix(clone): update destinations method call to ensure correct retrieval of selected destination 2025-09-18 13:44:56 +02:00
DeleteEnvironment.php feat(auth): enhance authorization checks in Livewire components for resource management 2025-08-26 10:27:38 +02:00
DeleteProject.php feat(auth): enhance authorization checks in Livewire components for resource management 2025-08-26 10:27:38 +02:00
Edit.php feat(validation): centralize validation patterns for names and descriptions 2025-08-19 12:14:48 +02:00
EnvironmentEdit.php feat(validation): centralize validation patterns for names and descriptions 2025-08-19 12:14:48 +02:00
Index.php feat(project): enhance project index with resource creation capabilities 2025-10-07 17:17:31 +02:00
Show.php feat(validation): centralize validation patterns for names and descriptions 2025-08-19 12:14:48 +02:00