Security Advisories (5)
CPANSA-Mojolicious-2022-03 (2022-12-10)

Mojo::DOM did not correctly parse <script> tags.

CPANSA-Mojolicious-2021-02 (2021-06-01)

Small sessions could be used as part of a brute-force attack to decode the session secret.

CVE-2021-47208 (2021-03-16)

A bug in format detection can potentially be exploited for a DoS attack.

CVE-2024-58134 (2025-05-03)

Mojolicious versions from 0.999922 for Perl uses a hard coded string, or the application's class name, as a HMAC session secret by default. These predictable default secrets can be exploited to forge session cookies. An attacker who knows or guesses the secret could compute valid HMAC signatures for the session cookie, allowing them to tamper with or hijack another user's session.

CVE-2024-58135 (2025-05-03)

Mojolicious versions from 7.28 for Perl may generate weak HMAC session secrets. When creating a default app with the "mojo generate app" tool, a weak secret is written to the application's configuration file using the insecure rand() function, and used for authenticating and protecting the integrity of the application's sessions. This may allow an attacker to brute force the application's session keys.

NAME

Mojo::DynamicMethods - Fast dynamic method dispatch

SYNOPSIS

package MyClass;
use Mojo::Base -base, -signatures;

use Mojo::DynamicMethods -dispatch;

sub BUILD_DYNAMIC ($class, $method, $dyn_methods) {
  return sub {...};
}

sub add_helper ($self, $name, $cb) {
  Mojo::DynamicMethods::register 'MyClass', $self, $name, $cb;
}

package main;

# Generate methods dynamically (and hide them from "$obj->can(...)")
my $obj = MyClass->new;
$obj->add_helper(foo => sub { warn 'Hello Helper!' });
$obj->foo;

DESCRIPTION

Mojo::DynamicMethods provides dynamic method dispatch for per-object helper methods without requiring use of AUTOLOAD.

To opt your class into dynamic dispatch simply pass the -dispatch flag.

use Mojo::DynamicMethods -dispatch;

And then implement a BUILD_DYNAMIC method in your class, making sure that the key you use to lookup methods in $dyn_methods is the same thing you pass as $ref to "register".

sub BUILD_DYNAMIC ($class, $method, $dyn_methods) {
  return sub ($self, @args) {
    my $dynamic = $dyn_methods->{$self}{$method};
    return $self->$dynamic(@args) if $dynamic;
    my $package = ref $self;
    croak qq{Can't locate object method "$method" via package "$package"};
  };
}

Note that this module will summon Cthulhu, use it at your own risk!

FUNCTIONS

Mojo::DynamicMethods implements the following functions.

register

Mojo::DynamicMethods::register $class, $ref, $name, $cb;

Registers the method $name as eligible for dynamic dispatch for $class, and sets $cb to be looked up for $name by reference $ref in a dynamic method constructed by BUILD_DYNAMIC.

SEE ALSO

Mojolicious, Mojolicious::Guides, https://mojolicious.org.