coolify/app/Livewire/Project/New
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
..
DockerCompose.php fix: prevent command injection in Docker Compose parsing - add pre-save validation 2025-10-16 09:51:37 +02:00
DockerImage.php Merge pull request #6879 from coollabsio/fix-docker-image-digest-cleanup 2025-10-15 10:49:30 +02:00
EmptyProject.php Revert "rector: arrrrr" 2025-01-07 15:31:43 +01:00
GithubPrivateRepository.php fix(core): set default base_directory and include in submit method 2025-10-07 14:12:07 +02:00
GithubPrivateRepositoryDeployKey.php fix(github): update repository URL to point to the v4.x branch for development 2025-09-25 17:31:16 +02:00
PublicGitRepository.php fix(git): handle additional repository URL cases for 'tangled' and improve branch assignment logic 2025-09-30 12:22:57 +02:00
Select.php fix(select-component): handle exceptions during parameter retrieval and environment selection in the mount method 2025-06-02 13:02:01 +02:00
SimpleDockerfile.php refactor(urls): replace generateFqdn with generateUrl for consistent URL generation across applications 2025-08-28 09:49:58 +02:00