return / branca

Authenticated and encrypted API tokens written in Rust. A secure JWT alternative.

Home Page:https://branca.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Security issue: Panic on invalid base62-encoded tokens

brycx opened this issue · comments

Documentation for decode(), which also implicitly covers Branca::decode(), states that:

If the input is not in Base62 format, it returns a BrancaError::InvalidBase62Token Result.

Prior to v0.10.0 this was not the case, instead a panic would occur:

let decoded_data = b62_decode(BASE62, &data).expect("Base62 token is invalid.");

This could leave any validating instance vulnerable to potential DoS, when parsing untrusted data and unexpected panics could occur.

This behavior was corrected in 7da3274:

let decoded_data = match b62_decode(BASE62, data) {

I will file an advisory with RustSec for this issue, but will leave the decision of yanking affected versions up to @return.