Skip to content

NoMethodError: undefined method `zero?' for nil:NilClass if JWT has no 'alg' field #410

@bouk

Description

@bouk

For example:

 JWT.decode('e30K.e30K.e30K')
=> NoMethodError: undefined method `zero?' for nil:NilClass

I'd expect this to throw a JWT::IncorrectAlgorithm, but casecmp here:

allowed_algorithms.any? { |alg| alg.casecmp(header['alg']).zero? }
returns nil if alg is not set, so we get an unexpected NoMethodError.

Metadata

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