Skip to content

Route::_check_options interpolates the option name into a regex #1813

Description

@bigpresh

Status: reasoned from code

lib/Dancer2/Core/Route.pm:63:

croak "Not a valid option for route matching: `$opt'"
  if not( grep {/^$opt$/} @supported_options );

$opt is a hash key interpolated straight into a pattern.

Impact

  • An option named . matches every supported option and defeats the validation entirely.
  • An option containing regex metacharacters dies with a regex compile error instead of the intended message.
  • It recompiles a pattern per option per route.

Developer-supplied rather than request-supplied, so this is correctness rather than security.

Suggested fix

if ( not grep { $_ eq $opt } @supported_options ) {

Strictly better and faster.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions