Problem/Motivation

The RFC https://wiki.php.net/rfc/deprecations_php_8_4#sessionsid_length_and_sess...

Symfony https://github.com/symfony/symfony/pull/57805

In other words changing the default values will either generate session IDs that raise eyebrows (4 bits per character with less than 32 characters or 5 bpc for less than 26 characters) or generate session IDs that are needlessly strong, increasing CPU costs, due to the additional randomness required, and increasing the chance for interoperability problems, such as the mod_security example.

For this reason we propose to deprecate the two INI settings in favor of the opinionated choice of the current defaults of a 32 character hexadecimal session ID.

The hexadecimal character set is not expected to cause any interoperability issues, as it is the most limited one of the currently available ones and hexadecimal identifiers are likely the most commonly used. While this would increase the length of the session ID from the previous minimum of 22 characters (which is a secure choice when combined with 6 bits per character) to 32, we do not expect this to be an issue in practice. The difference in traffic is minimal and a hexadecimal session ID is trivially packed into a 16 Byte binary string using hex2bin(), should storage requirements of the session backend be a concern.

Steps to reproduce

core$ git grep sid_length
core/assets/scaffold/files/default.services.yml:57:    sid_length: 48
core/core.services.yml:18:    sid_length: 48
core/lib/Drupal/Core/Session/SessionConfiguration.php:28:    // Provide sensible defaults for sid_length, sid_bits_per_character and
core/lib/Drupal/Core/Session/SessionConfiguration.php:32:      'sid_length' => 48,
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:269:  public function testConstructorDefaultSettings(array $options, int $expected_sid_length, int $expected_sid_bits_per_character, string $expected_name_suffix): void {
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:272:    $this->assertSame($expected_sid_length, $options['sid_length']);
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:286:      [['sid_length' => 100], 100, 6, ''],
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:289:      [['sid_length' => 100, 'sid_bits_per_character' => 5, 'name_suffix' => 'some-suffix'], 100, 5, 'some-suffix'],
sites/default/default.services.yml:57:    sid_length: 48

core$ git grep sid_bits_per_character
core/assets/scaffold/files/default.services.yml:66:    sid_bits_per_character: 6
core/core.services.yml:19:    sid_bits_per_character: 6
core/lib/Drupal/Core/Session/SessionConfiguration.php:28:    // Provide sensible defaults for sid_length, sid_bits_per_character and
core/lib/Drupal/Core/Session/SessionConfiguration.php:33:      'sid_bits_per_character' => 6,
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:269:  public function testConstructorDefaultSettings(array $options, int $expected_sid_length, int $expected_sid_bits_per_character, string $expected_name_suffix): void {
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:273:    $this->assertSame($expected_sid_bits_per_character, $options['sid_bits_per_character']);
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:287:      [['sid_bits_per_character' => 5], 48, 5, ''],
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:289:      [['sid_length' => 100, 'sid_bits_per_character' => 5, 'name_suffix' => 'some-suffix'], 100, 5, 'some-suffix'],
sites/default/default.services.yml:66:    sid_bits_per_character: 6

Proposed resolution

discuss how to prevent using deprecated code

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3465836

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

andypost created an issue. See original summary.

andypost’s picture

andypost’s picture

Status: Active » Needs review
Issue tags: +Needs change record
andypost’s picture

andypost’s picture

Additionally deprecated session.use_only_cookies, session.use_trans_sid and session.referer_check via https://wiki.php.net/rfc/deprecate-get-post-sessions

https://github.com/php/php-src/commit/c5bce0d8a2e6794cd6809e4047dd1f488f...

core/lib/Drupal/Core/DrupalKernel.php:997:      ini_set('session.use_only_cookies', '1');
core/lib/Drupal/Core/DrupalKernel.php:998:      ini_set('session.use_trans_sid', '0');
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thought about if we would need some kind of comment or deprecation message but since we probably don't know the php requirement for D12 figured when the time comes we would search for

\PHP_VERSION_ID >=

  • catch committed 213e9669 on 10.4.x
    Issue #3465836 by andypost: PHP 8.4 session.sid_length and session....

  • catch committed 123216e5 on 11.x
    Issue #3465836 by andypost: PHP 8.4 session.sid_length and session....
catch’s picture

Version: 11.x-dev » 10.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 10.4.x, thanks!

Looks fine to me for a quick fix for 8.4 compatibility, opened a follow-up for removing/deprecating these from services.default.yml #3471199: Remove sid_length and sid_bits_per_character deprecation from CoreServiceProvider.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.