Skip to content

[Hardening] Deprecate RandomSessionIdGenerator due to insufficient entropy (64-bit) #2758

@Allen-wick

Description

@Allen-wick

Search before asking

  • I had searched in the issues and found no similar issues.

Enhancement Request

The org.apache.shiro.session.mgt.eis.RandomSessionIdGenerator class generates session IDs using Long.toString(SecureRandom.nextLong()), which provides only 64 bits of entropy. This falls below the modern industry minimum of 128 bits recommended by OWASP ASVS and NIST SP 800-63B for session tokens.

While Shiro's default JavaUuidSessionIdGenerator (UUID v4, 122-bit entropy) is secure and used out-of-the-box, the existence of RandomSessionIdGenerator in the public API poses a risk of misuse by developers who might explicitly configure it for legacy or perceived performance reasons.

Describe the solution you'd like

To improve the security posture and guide developers toward secure defaults, I propose the following hardening steps:

  1. Mark RandomSessionIdGenerator as @Deprecated in the next minor release, with a Javadoc comment directing users to JavaUuidSessionIdGenerator.
  2. Add a startup WARN log if this class is explicitly instantiated or wired via shiro.ini / Spring configuration.
  3. Remove the class entirely in the next major release (e.g., Shiro 3.x).

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions