8000 HeaderAccessTokenExtractor b64token regex not compatible with RFC · Issue #54660 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
HeaderAccessTokenExtractor b64token regex not compatible with RFC #54660
Closed
@jpoliak-invia

Description

@jpoliak-invia

Symfony version(s) affected

6.4.*

Description

In Symfony\Component\Security\Http\AccessToken\HeaderAccessTokenExtractor constructor is regex to check Authorization: Bearer b64token, but this regex is not fully compatible with RFC definition https://datatracker.ietf.org/doc/html/rfc6750#section-2.1

How to reproduce

setup in security.yaml
firewalls: main: access_token: token_extractors: 'headers'

Generate Base64 token with equal mark at the end (e.g. $token = base64_encode('wrong_regexp_exmaple') )

Make a request with header Authorization: Bearer d3JvbmdfcmVnZXhwX2V4bWFwbGU=

Possible Solution

Change regex in /symfony/security-http/AccessToken/HeaderAccessTokenExtractor.php:32
'/^%s([a-zA-Z0-9\-_\+~\/\.]+)$/'
to
'/^%s([a-zA-Z0-9\-_\+~\/\.]+=*)$/'

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0