Skip to content
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

default jwt secret key can forge any user identity, such as gaining administrator privileges (默认 jwt 密钥可以伪造任意用户身份,例如获取管理员权限) #703

Closed
Rvn0xsy opened this issue Sep 22, 2022 · 0 comments

Comments

@Rvn0xsy
Copy link

Rvn0xsy commented Sep 22, 2022

trojan/web/auth.go

Lines 24 to 39 in c5fafe2

func jwtInit(timeout int) {
authMiddleware, err = jwt.New(&jwt.GinJWTMiddleware{
Realm: "k8s-manager",
Key: []byte("secret key"),
Timeout: time.Minute * time.Duration(timeout),
MaxRefresh: time.Minute * time.Duration(timeout),
IdentityKey: identityKey,
SendCookie: true,
PayloadFunc: func(data interface{}) jwt.MapClaims {
if v, ok := data.(*Login); ok {
return jwt.MapClaims{
identityKey: v.Username,
}
}
return jwt.MapClaims{}
},

代码中硬编码了secret key,可以伪造任意用户身份,包括管理员。

The key is hardcoded in the code, using jwt.io can forge any user identity, including administrators

image

image

@Jrohy Jrohy closed this as completed in e64931b Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant