The Validation takes a Vec of Algorithm but the validation code here incorrectly ensures that the JWT's algorithm is compatible with all the specified algorithms, instead of just ensuring it finds at least one that matches.
Put otherwise, this:
if validation.validate_signature {
for alg in &validation.algorithms {
if key.family != alg.family() {
return Err(new_error(ErrorKind::InvalidAlgorithm));
}
}
}
Should be more like:
if validation.validate_signature {
for alg in &validation.algorithms {
if key.family == alg.family() {
// Success: let's move on.
}
}
return Err(new_error(ErrorKind::InvalidAlgorithm));
}
As it stands, it is impossible to use more than one algorithm in a validation because of this bug.
The
Validationtakes aVecofAlgorithmbut the validation code here incorrectly ensures that the JWT's algorithm is compatible with all the specified algorithms, instead of just ensuring it finds at least one that matches.Put otherwise, this:
Should be more like:
As it stands, it is impossible to use more than one algorithm in a validation because of this bug.