-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
The session id is too long or contains illegal characters #45755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Silencing |
Silencing ? Could you explain your answer ? |
I was thinking about replacing if (!session_start()) {
throw new \RuntimeException('Failed to start the session.');
} with if (!@session_start()) {
throw new \RuntimeException('Failed to start the session.');
} |
I'll try, thank you.But it will not avoid the error, only silence it ? sid_bits_per_character: 5 Maybe somebody tried to hack service and manually change session_id to call error and get information from it, so your decision will be helpful |
Unfortunately error continues to appear in log:
in NativeSessionStorage.php: // ok to try and start the session
if (!@session_start()) {
throw new \RuntimeException('Failed to start the session.');
} |
Silencing But how can we catch that exception efficiently? There are a lot of places which can lead to this exception being thrown: for instance, in my application, it is triggered by a Twig file: I don't see how I can avoid a Any idea? Can something be done in Symfony? For instance a configuration parameter to tell Symfony to ignore invalid sessions and/or PHPSESSID? Thanks in advance. Best regards |
NB: this problem seems to exist even on official Symfony websites, for instance:
I don't think there is any security issue here, but I find it quite annoying that someone can easily produce a 500 error on an application... |
…peter17) This PR was merged into the 4.4 branch. Discussion ---------- [HttpFoundation] [Session] Regenerate invalid session id | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #45755 | License | MIT | Doc PR | no Currently, having a PHPSESSID which does not match `/^[a-zA-Z0-9,\-]{1,123}$/` (see https://www.php.net/manual/fr/function.session-start.php) will produce a php.WARNING and then a RuntimeException (please read #45755). I don't think there is a nice way to handle this so I propose to simply ignore invalid values. With this PR, a value for PHPSESSID that does not match the regex will be ignored and a new session id will be generated. Then, the behavior will be the same as if no session existed, so a new session will be started and a new PHPSESSID will be defined. It looks like Session storage is currently untested so I don't know how to test this... Best regards Commits ------- d8f84c7 [HttpFoundation] [Session] Overwrite invalid session id
Symfony version(s) affected
5.4.6
Description
Hi, have a problem in my project. Sometimes in log i see such messages:
Framework config:
How can i fix it ? I
ve read that it
s bug of php, but maybe you know about fixing this problem in symfony ?How to reproduce
I can`t reproduce this error, but i think, could manually set session_id and get error
Possible Solution
I think about writing a simple wrapper around
NativeSessionStorage
that will check the validity of the session ID before calling the handler.Additional Context
No response
The text was updated successfully, but these errors were encountered: