Vulnerabilities in pkg:golang/github.com/zeromicro/go-zero

PACKAGE
Advisory Identifier: GHSA-fgxv-gw55-r5fq
Advisory Summary

CVE-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.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:golang/github.com/zeromicro/go-zero

1 Known Advisory Record(s)

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

CVE Identifier CVE-2024-27302
GHSA Identifier GHSA-fgxv-gw55-r5fq
Severity CRITICAL
CVSS v3.1 Base Score 9.1
CWE Classification CWE-639: Authorization Bypass Through User-Controlled Key
Affected Product Github.com/zeromicro/go zero
Package Ecosystem Go
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (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.

github.com/zeromicro/go-zero fixed: 1.4.4
Upgrade github.com/zeromicro/go-zero to 1.4.4
Verify Direct and Transitive Dependencies

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

### Summary Hello go-zero maintainer team, I would like to report a security concerning your CORS Filter feature. ### Details Go-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. However, the `isOriginAllowed` uses `strings.HasSuffix` to check the origin, which leads to bypass via domain like `evil-victim.com` ```go func isOriginAllowed(allows []string, origin string) bool { for _, o := range allows { if o == allOrigins { return true } if strings.HasSuffix(origin, o) { return true } } return false } ``` ### PoC Use code below as a PoC. Only requests from `safe.com` should bypass the CORS Filter ```go package main import ( "errors" "net/http" "github.com/zeromicro/go-zero/rest" ) func main() { svr := rest.MustNewServer(rest.RestConf{Port: 8888}, rest.WithRouter(mockedRouter{}), rest.WithCors("safe.com")) svr.Start() } type mockedRouter struct{} // some sensitive path func (m mockedRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) { // check user's cookie // ... // return sensitive data w.Write([]byte("social_id: 420101198008292930")) } func (m mockedRouter) Handle(_, _ string, handler http.Handler) error { return errors.New("foo") } func (m mockedRouter) SetNotFoundHandler(_ http.Handler) { } func (m mockedRouter) SetNotAllowedHandler(_ http.Handler) { } ``` Send a request to localhost:8888 with `Origin:not-safe.com` You can see the origin reflected in response, which bypass the CORS Filter ![image](https://user-images.githubusercontent.com/70683161/221365842-9d76a3a4-a79d-413a-85b7-06b50b0a7807.png) ### Impact This vulnerability is capable of breaking CORS policy and thus allowing any page to make requests, retrieve data on behalf of other users.

CVE-2024-27302 Affected Github.com/zeromicro/go zero Versions

1 component(s)
Fixed Versions:
1.4.4
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?
CVE-2024-27302 is a security vulnerability in Github.com/zeromicro/go zero involving Authorization Bypass Through User-Controlled Key in go-zero under CWE-639: Authorization Bypass Through User-Controlled Key.
Which Github.com/zeromicro/go zero versions are affected?
Affected versions include releases prior to 1.4.4 across affected packages: github.com/zeromicro/go-zero.
What version fixes CVE-2024-27302?
Upgrading to 1.4.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/zeromicro/go-zero affected?
Yes, github.com/zeromicro/go-zero is affected in releases prior to 1.4.4. Upgrade your dependency to 1.4.4 or later.
What is the CVSS score of CVE-2024-27302?
CVE-2024-27302 has a CVSS v3.1 base score of 9.1 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2024-27302?
CVE-2024-27302 is classified under CWE-639: Authorization Bypass Through User-Controlled Key (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.).
How can I check Go dependencies for CVE-2024-27302?
Run the dependency tree command: 'inspect dependencies for github.com/zeromicro/go-zero'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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![image](https://user-images.githubusercontent.com/70683161/221365842-9d76a3a4-a79d-413a-85b7-06b50b0a7807.png)\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"
  }
}