coze-dev / coze-dev/cozeloop-go

jwt-go allows excessive memory allocation during header parsing

Open
#32 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
58
Forks
20
PR merge metrics
No merged PRs in 30d

Description

Transitive dependency github.com/golang-jwt/jwt v3.2.2+incompatible is introduced via
github.com/cloudwego/eino-ext/callbacks/cozeloop v0.1.7 ... github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/cloudwego/eino-ext/callbacks/cozeloop v0.1.7 github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/coze-dev/cozeloop-go v0.1.17 github.com/golang-jwt/jwt v3.2.2+incompatible
Package
Affected versions
Patched version
github.com/golang-jwt/jwt
(Go)
>= 3.2.0, <= 3.2.2
None
Summary
Function [parse.ParseUnverified](https://github.com/golang-jwt/jwt/blob/c035977d9e11c351f4c05dfeae193923cbab49ee/parser.go#L138-L139) currently splits (via a call to [strings.Split](https://pkg.go.dev/strings#Split)) its argument (which is untrusted data) on periods.

As a result, in the face of a malicious request whose Authorization header consists of followed by many period characters, a call to that function incurs allocations to the tune of O(n) bytes (where n stands for the length of the function's argument), with a constant factor of about 16. Relevant weakness: [CWE-405: Asymmetric Resource Consumption (Amplification)](https://cwe.mitre.org/data/definitions/405.html)Bearer

Details
See [parse.ParseUnverified](https://github.com/golang-jwt/jwt/blob/c035977d9e11c351f4c05dfeae193923cbab49ee/parser.go#L138-L139)

Impact
Excessive memory allocation

建议升级golang-jwt/jwt 3.2到最新的https://pkg.go.dev/github.com/golang-jwt/jwt/v5

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.