Skip to content

Commit f5804be

Browse files
Merge branch '6.4' into 7.4
* 6.4: [FrameworkBundle] Allow to pass `doctrine_open_transaction_logger`’s entity manager name positionally [Scheduler] Recover pending RecurringMessages after consumer stops midway [SecurityBundle] Fix Security::login() across firewalls [Routing][RateLimiter][Mime][Security] Harden __unserialize against __toString trampolines [Security] Initialize lazy users before serializing them in the session [Process] Stop leaking CGI/FastCGI request-context vars to subprocesses [Runtime] Trust argv on CLI-like SAPIs to fix subprocess args [Mailer] Harden default IP allowlist for Postmark and Brevo webhook parsers [Cache] Accept '_' and ':' in prefix passed to AbstractAdapter::clear() [HtmlSanitizer] Honor universal attribute sanitizers, apply maxInputLength to text contexts, document forceAttribute and allowAttribute caveats [Translation] Don’t check the error message to know if Lokalise keys are missing [AssetMapper] Rewrite relative paths in `export ... from` statements [Yaml] Allow trailing newlines after the end-of-document marker [HttpKernel][WebProfilerBundle] Check logs priority name for both `WARNING` and `warning` Update VERSION for 5.4.52 Update CHANGELOG for 5.4.52 Add additional exclude paths for tests # Conflicts: # src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php # src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php # src/Symfony/Bundle/SecurityBundle/Security.php # src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php # src/Symfony/Component/HtmlSanitizer/HtmlSanitizer.php # src/Symfony/Component/RateLimiter/Tests/Policy/SlidingWindowTest.php # src/Symfony/Component/Routing/Tests/RouteTest.php # src/Symfony/Component/Runtime/SymfonyRuntime.php # src/Symfony/Component/Scheduler/Tests/Generator/MessageGeneratorTest.php # src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php # src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderTest.php
2 parents d9593c9 + c8fc09b commit f5804be

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

Process.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1689,8 +1689,36 @@ private function getDefaultEnv(): array
16891689
{
16901690
$env = getenv();
16911691
$env = ('\\' === \DIRECTORY_SEPARATOR ? array_intersect_ukey($env, $_SERVER, 'strcasecmp') : array_intersect_key($env, $_SERVER)) ?: $env;
1692+
$env = $_ENV + ('\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($env, $_ENV, 'strcasecmp') : $env);
16921693

1693-
return $_ENV + ('\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($env, $_ENV, 'strcasecmp') : $env);
1694+
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
1695+
return $env;
1696+
}
1697+
1698+
// On non-CLI SAPIs (notably PHP-FPM and CGI), CGI/FastCGI request-context
1699+
// vars are exposed through $_SERVER, $_ENV and getenv(), and must not
1700+
// propagate to subprocesses.
1701+
foreach ($env as $k => $v) {
1702+
if (str_starts_with($k, 'HTTP_')
1703+
|| str_starts_with($k, 'ORIG_')
1704+
|| str_starts_with($k, 'REDIRECT_')
1705+
|| \in_array($k, [
1706+
'AUTH_TYPE', 'CONTENT_LENGTH', 'CONTENT_TYPE', 'DOCUMENT_ROOT',
1707+
'DOCUMENT_URI', 'GATEWAY_INTERFACE', 'HTTPS', 'PATH_INFO',
1708+
'PATH_TRANSLATED', 'PHP_AUTH_DIGEST', 'PHP_AUTH_PW', 'PHP_AUTH_USER',
1709+
'PHP_SELF', 'QUERY_STRING', 'REMOTE_ADDR', 'REMOTE_HOST',
1710+
'REMOTE_IDENT', 'REMOTE_PORT', 'REMOTE_USER', 'REQUEST_METHOD',
1711+
'REQUEST_SCHEME', 'REQUEST_TIME', 'REQUEST_TIME_FLOAT', 'REQUEST_URI',
1712+
'SCRIPT_FILENAME', 'SCRIPT_NAME', 'SCRIPT_URI', 'SCRIPT_URL',
1713+
'SERVER_ADDR', 'SERVER_ADMIN', 'SERVER_NAME', 'SERVER_PORT',
1714+
'SERVER_PROTOCOL', 'SERVER_SIGNATURE', 'SERVER_SOFTWARE',
1715+
], true)
1716+
) {
1717+
unset($env[$k]);
1718+
}
1719+
}
1720+
1721+
return $env;
16941722
}
16951723

16961724
private function validateWindowsEnvBlockSize(array $envPairs): void

0 commit comments

Comments
 (0)