-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Billion hashes attack against Decode function #31
Comments
Hi @mschwager thanks for reaching out. I've never used github private reporting before. Wouldn't it be easier just to reach out by email: [email protected] ? Also feel free to find me on LinkedIn - can use it as well. |
@mschwager forgot to mention in email, strict alg validation (aka https://github.com/dvsekhvalnov/jose2go#two-phase-validation may be need more docs on it with some library provided helpers. |
Fixed as part of v1.6 release. |
For context, here was the initial report: There were some new attacks against JWT presented at BlackHat this year: Three New Attacks Against JSON Web Tokens. The issue in jose2go is the same as the "billion hashes attack" described in this presentation. Specifically, an attacker can provide a PBES2 encrypted JWE blob with a very large p2c value that, when decoded, produces a DoS in the server. Here's a minimal code example: package main
import (
"flag"
"fmt"
"github.com/dvsekhvalnov/jose2go"
)
func main() {
var jwe, key string
flag.StringVar(&jwe, "jwe", "", "JWE value")
flag.StringVar(&key, "key", "", "JWE key")
flag.Parse()
fmt.Println("Decrypting...")
payload, headers, err := jose.Decode(jwe, key)
if err != nil {
panic(err)
}
fmt.Println("Decrypted:", string(payload))
fmt.Println("Headers:", headers)
} We can then run this script with a specially crafted JWE with a PBES2 alg and large p2c value:
So, if a server is performing JOSE decoding, and even if it's not intentionally supporting PBES2, it will be vulnerable to DoS. I would consider this a medium severity bug. This type of bug resulted in CVE-2022-36083 in a similar library in the JavaScript ecosystem, and this commit provided the fix. I see two good options for remediation:
Option (2) is a bit more challenging to implement, but also more robust. It would be a backwards incompatible change to the API, but it removes any problems (and future problems) with attacker-specified "alg" values. In fact, this suggestion was made back in 2015 when dealing with the infamous "alg: none" issue that plagues JWT implementations. This was the approach another Golang JOSE library took. |
Hey @dvsekhvalnov, could you please create a tag for |
@burningalchemist sure thing, added :) |
Hi there,
I'd like to report a potential security vulnerability in this repository. Using GitHub's private reporting would be easiest:
If that doesn't work, would you mind suggesting an alternative?
The text was updated successfully, but these errors were encountered: