CVE-2024-50340
Description
symfony/runtime is a module for the Symphony PHP framework which enables decoupling PHP applications from global state. When the register_argv_argc php directive is set to on , and users call any URL with a special crafted query string, they are able to change the environment or debug mode used by the kernel when handling the request. As of versions 5.4.46, 6.4.14, and 7.1.7 the SymfonyRuntime now ignores the argv values for non-SAPI PHP runtimes. All users are advised to upgrade. There are no known workarounds for this vulnerability.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
symfony/runtimePackagist | >= 5.3.0, < 5.4.46 | 5.4.46 |
symfony/runtimePackagist | >= 6.0.0, < 6.4.14 | 6.4.14 |
symfony/runtimePackagist | >= 7.0.0, < 7.1.7 | 7.1.7 |
symfony/symfonyPackagist | >= 5.3.0, < 5.4.46 | 5.4.46 |
symfony/symfonyPackagist | >= 6.0.0, < 6.4.14 | 6.4.14 |
symfony/symfonyPackagist | >= 7.0.0, < 7.1.7 | 7.1.7 |
Affected products
1- Range: v2.0.0, v2.0.0-RC1, v2.0.0-RC2, …
Patches
4057d88bef2d1d1797e5b5b545001143568bca77b308c3f17Do not read from argv on non-CLI SAPIs
4 files changed · +29 −5
src/Symfony/Component/Runtime/SymfonyRuntime.php+5 −1 modified@@ -95,7 +95,7 @@ public function __construct(array $options = []) if (isset($options['env'])) { $_SERVER[$envKey] = $options['env']; - } elseif (isset($_SERVER['argv']) && class_exists(ArgvInput::class)) { + } elseif (empty($_GET) && isset($_SERVER['argv']) && class_exists(ArgvInput::class)) { $this->options = $options; $this->getInput(); } @@ -216,6 +216,10 @@ protected static function register(GenericRuntime $runtime): GenericRuntime private function getInput(): ArgvInput { + if (!empty($_GET) && filter_var(ini_get('register_argc_argv'), \FILTER_VALIDATE_BOOL)) { + throw new \Exception('CLI applications cannot be run safely on non-CLI SAPIs with register_argc_argv=On.'); + } + if (null !== $this->input) { return $this->input; }
src/Symfony/Component/Runtime/Tests/phpt/kernel.php+5 −3 modified@@ -17,19 +17,21 @@ class TestKernel implements HttpKernelInterface { + private $env; private $var; - public function __construct(string $var) + public function __construct(string $env, string $var) { + $this->env = $env; $this->var = $var; } public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true): Response { - return new Response('OK Kernel '.$this->var); + return new Response('OK Kernel (env='.$this->env.') '.$this->var); } } return function (array $context) { - return new TestKernel($context['SOME_VAR']); + return new TestKernel($context['APP_ENV'], $context['SOME_VAR']); };
src/Symfony/Component/Runtime/Tests/phpt/kernel.phpt+1 −1 modified@@ -9,4 +9,4 @@ require $_SERVER['SCRIPT_FILENAME'] = __DIR__.'/kernel.php'; ?> --EXPECTF-- -OK Kernel foo_bar +OK Kernel (env=dev) foo_bar
src/Symfony/Component/Runtime/Tests/phpt/kernel_register_argc_argv.phpt+18 −0 added@@ -0,0 +1,18 @@ +--TEST-- +Test HttpKernelInterface with register_argc_argv=1 +--INI-- +display_errors=1 +register_argc_argv=1 +--FILE-- +<?php + +// emulating PHP behavior with register_argc_argv=1 +$_GET['-e_test'] = ''; +$_SERVER['argc'] = 1; +$_SERVER['argv'] = [' ', '-e', 'test']; + +require $_SERVER['SCRIPT_FILENAME'] = __DIR__.'/kernel.php'; + +?> +--EXPECTF-- +OK Kernel (env=dev) foo_bar
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
7- github.com/advisories/GHSA-x8vp-gf4q-mw5jghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2024-50340ghsaADVISORY
- github.com/FriendsOfPHP/security-advisories/blob/master/symfony/runtime/CVE-2024-50340.yamlghsaWEB
- github.com/FriendsOfPHP/security-advisories/blob/master/symfony/symfony/CVE-2024-50340.yamlghsaWEB
- github.com/symfony/symfony/commit/a77b308c3f179ed7c8a8bc295f82b2d6ee3493fanvdWEB
- github.com/symfony/symfony/security/advisories/GHSA-x8vp-gf4q-mw5jnvdWEB
- symfony.com/cve-2024-50340ghsaWEB
News mentions
0No linked articles in our index yet.