GitHub Advisoryadvisory · Go

GHSA-hpc8-7wpm-889w Dragonfly2 has hard coded cyptographic key

CRITICAL Published 2024-09-19 Modified 2025-04-23 Official page ↗
Aliases
CVE-2023-27584
Ecosystem
Go
Packages
d7y.io/dragonfly/v2
Severity
Critical
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Weaknesses
CWE-321, CWE-798
Reviewed
2024-09-19

Affected packages

• Go d7y.io/dragonfly/v2: >= 2.1.0-alpha.0, < 2.1.0-beta.1 → fixed in 2.1.0-beta.1 • Go d7y.io/dragonfly/v2: < 2.0.9-rc.2 → fixed in 2.0.9-rc.2

Description

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 ```go 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 ```go package main import ( "errors" "fmt" "time" "github.com/golang-jwt/jwt/v4" ) func (stc *DragonflyTokenClaims) Valid() error { // Verify expiry. if stc.ExpiresAt Impact An attacker can perform any action as a user with admin privileges.

Related

Alias · CVE (1)

  • CVE-2023-27584 Dragonfly is an open source P2P-based file distribution and image acceleration system. vulnerability

Weakness · CWE (2)

  • CWE-321 Use of Hard-coded Cryptographic Key weakness
  • CWE-798 Use of Hard-coded Credentials weakness

References