Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8c4b72b

Browse filesBrowse files
committed
[HttpFoundation][Session] Ignore invalid session id.
1 parent ce4a1a9 commit 8c4b72b
Copy full SHA for 8c4b72b

File tree

1 file changed

+7
-0
lines changed
Filter options

1 file changed

+7
-0
lines changed

‎src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ public function start()
152152
throw new \RuntimeException(sprintf('Failed to start the session because headers have already been sent by "%s" at line %d.', $file, $line));
153153
}
154154

155+
$sessionName = session_name();
156+
$sessionId = $_COOKIE[$sessionName] ?? null;
157+
// validate according to https://www.php.net/manual/fr/function.session-start.php
158+
if ($sessionId && !preg_match('/^[a-zA-Z0-9,\-]{1,123}$/', $sessionId)) {
159+
unset($_COOKIE[$sessionName]);
160+
}
161+
155162
// ok to try and start the session
156163
if (!session_start()) {
157164
throw new \RuntimeException('Failed to start the session.');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.