Skip to content

Example unsigned token that bypasses verification #364

Closed
@brianlow

Description

you need to specify the algorithm in the options hash whenever you call JWT.decode to ensure that an attacker cannot bypass the algorithm verification step

Does anyone have an example of such a token?

I thought our system was exposed but I've been unable to write a failing unit test. For example:

malicious_token = JWT.encode({hi: 1}, nil, 'none')
# => "eyJhbGciOiJub25lIn0.eyJoaSI6MX0."

JWT.decode malicious_token, 'secret'
# => JWT::DecodeError: Not enough or too many segments

I cannot get JWT.decode(t, secret) to accept an unsigned token.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions