Vulnerabilities in pkg:golang/github.com/zeromicro/go-zero
PACKAGECVE-2024-27302 is a CRITICAL (CVSS 9.1) authorization bypass through user-controlled key vulnerability (CWE-639: Authorization Bypass Through User-Controlled Key) affecting Github.com/zeromicro/go zero libraries in the Go ecosystem. The issue involves authorization bypass through user-controlled key in go-zero. Remediation is available by upgrading affected packages to version 1.4.4.
pkg:golang/github.com/zeromicro/go-zero
Vulnerability advisories affecting package pkg:golang/github.com/zeromicro/go-zero. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-fgxv-gw55-r5fq | CVE-2024-27302 | CRITICAL | Authorization Bypass Through User-Controlled Key in go-zero |
CVE-2024-27302 at a Glance
Security Impact
CVSS: 9.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N).
How to Fix CVE-2024-27302
To remediate this vulnerability, upgrade all affected Github.com/zeromicro/go zero dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade github.com/zeromicro/go-zero to 1.4.4
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/zeromicro/go-zero
How to Check if You Are Affected
To determine whether your application is affected by CVE-2024-27302, inspect your project dependencies for Github.com/zeromicro/go zero:
inspect dependencies for github.com/zeromicro/go-zero
Analyze the terminal output to locate any version of Github.com/zeromicro/go zero in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.4.4), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-639: Authorization Bypass Through User-Controlled Key, where the system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data. In Github.com/zeromicro/go zero, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-27302 Affected Github.com/zeromicro/go zero Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/zeromicro/go-zero
|
Go |
< 1.4.4
|
1.4.4
|
References
Frequently Asked Questions
What is CVE-2024-27302?
Which Github.com/zeromicro/go zero versions are affected?
What version fixes CVE-2024-27302?
Is github.com/zeromicro/go-zero affected?
What is the CVSS score of CVE-2024-27302?
What CWE is associated with CVE-2024-27302?
How can I check Go dependencies for CVE-2024-27302?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-fgxv-gw55-r5fq",
"modified" : "2024-03-12T15:16:05Z",
"published" : "2024-03-04T20:42:33Z",
"aliases" : [ "CVE-2024-27302" ],
"summary" : "Authorization Bypass Through User-Controlled Key in go-zero",
"details" : "### Summary\nHello go-zero maintainer team, I would like to report a security concerning your CORS Filter feature. \n\n### Details\nGo-zero allows user to specify a [CORS Filter](https://github.com/zeromicro/go-zero/blob/master/rest/internal/cors/handlers.go) with a configurable allows param - which is an array of domains allowed in CORS policy.\n\nHowever, the `isOriginAllowed` uses `strings.HasSuffix` to check the origin, which leads to bypass via domain like `evil-victim.com`\n```go\nfunc isOriginAllowed(allows []string, origin string) bool {\n\tfor _, o := range allows {\n\t\tif o == allOrigins {\n\t\t\treturn true\n\t\t}\n\n\t\tif strings.HasSuffix(origin, o) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n```\n\n### PoC\nUse code below as a PoC. Only requests from `safe.com` should bypass the CORS Filter\n```go\npackage main\n\nimport (\n\t\"errors\"\n\t\"net/http\"\n\n\t\"github.com/zeromicro/go-zero/rest\"\n)\n\nfunc main() {\n\tsvr := rest.MustNewServer(rest.RestConf{Port: 8888}, rest.WithRouter(mockedRouter{}), rest.WithCors(\"safe.com\"))\n\tsvr.Start()\n}\n\ntype mockedRouter struct{}\n\n// some sensitive path\nfunc (m mockedRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\t// check user's cookie\n\t// ...\n\t// return sensitive data\n\tw.Write([]byte(\"social_id: 420101198008292930\"))\n}\n\nfunc (m mockedRouter) Handle(_, _ string, handler http.Handler) error {\n\treturn errors.New(\"foo\")\n}\n\nfunc (m mockedRouter) SetNotFoundHandler(_ http.Handler) {\n}\n\nfunc (m mockedRouter) SetNotAllowedHandler(_ http.Handler) {\n}\n```\nSend a request to localhost:8888 with `Origin:not-safe.com`\nYou can see the origin reflected in response, which bypass the CORS Filter\n\n\n### Impact\nThis vulnerability is capable of breaking CORS policy and thus allowing any page to make requests, retrieve data on behalf of other users.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/zeromicro/go-zero"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.4.4"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/zeromicro/go-zero/security/advisories/GHSA-fgxv-gw55-r5fq"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-27302"
}, {
"type" : "WEB",
"url" : "https://github.com/zeromicro/go-zero/commit/d9d79e930dff6218a873f4f02115df61c38b15db"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/zeromicro/go-zero"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-639" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2024-03-04T20:42:33Z",
"nvd_published_at" : "2024-03-06T19:15:08Z"
}
}