Security Advisories (1)
CVE-2026-13577 (2026-07-20)

Dancer2 versions through 2.1.0 for Perl generate insecure session ids when CSPRNG modules are unavailable. Dancer2::Core::Role::SessionFactory::generate_id silently falls back to a built-in rand-derived session id when both Math::Random::ISAAC::XS and Crypt::URandom are unavailable. The fallback session id is generated from a SHA-1 hash of a call to the built-in rand function, the absolute path of the Dancer2::Core::Role::SessionFactory module, an internal counter, the process id, the module instance memory address, and a shuffled string of characters (using the List::Util::shuffle function, which also uses the built-in rand function). These are all low-entropy and easily guessed sources. The built-in rand() function is seeded with 32-bits and considered unsuitable for security applications. Predictable session ids could allow an attacker to gain access to systems.

NAME

Dancer2::Core::Session - class to represent any session object

VERSION

version 2.1.0

DESCRIPTION

A session object encapsulates anything related to a specific session: its ID, its data, and its expiration.

It is completely agnostic of how it will be stored, this is the role of a factory that consumes Dancer2::Core::Role::SessionFactory to know about that.

Generally, session objects should not be created directly. The correct way to get a new session object is to call the create() method on a session engine that implements the SessionFactory role. This is done automatically by the app object if a session engine is defined.

ATTRIBUTES

id

The identifier of the session object. Required. By default, Dancer2::Core::Role::SessionFactory sets this to a randomly-generated, guaranteed-unique string.

This attribute can be modified if your Session implementation requires this.

data

Contains the data of the session (Hash).

expires

Number of seconds for the expiry of the session cookie. Don't add the current timestamp to it, will be done automatically.

Default is no expiry (session cookie will leave for the whole browser's session).

For a lifetime of one hour:

expires => 3600

is_dirty

Boolean value for whether data in the session has been modified.

METHODS

read

Reader on the session data

my $value = $session->read('something');

Returns undef if the key does not exist in the session.

write

Writer on the session data

$session->write('something', $value);

Sets is_dirty to true. Returns $value.

delete

Deletes a key from session data

$session->delete('something');

Sets is_dirty to true. Returns the value deleted from the session.

AUTHOR

Dancer Core Developers

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Alexis Sukrieh.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.