{"id":"GHSA-fgxv-gw55-r5fq","revision":"ce1ba0a4a9af4bb18cd59c34d827eff1","records":[{"revision":"ce1ba0a4a9af4bb18cd59c34d827eff1","observedAt":"2026-10-24T13:19:41.952+00:00","statement":{"source":"osv","id":"GHSA-fgxv-gw55-r5fq","aliases":["CVE-2024-27302","GO-2024-2604"],"title":"Authorization Bypass Through User-Controlled Key in go-zero","description":"### 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","state":0,"publishedAt":"2024-03-04T20:42:33+00:00","modifiedAt":"2026-09-10T03:50:10.5073805+00:00","affected":[{"ecosystem":"Go","name":"github.com/zeromicro/go-zero","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0"},{"kind":"fixed","version":"1.4.4"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[{"system":"CVSS_V3","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N","score":null,"severity":null},{"system":"Publisher rating","vector":null,"score":null,"severity":"CRITICAL"}],"references":["https://github.com/zeromicro/go-zero/security/advisories/GHSA-fgxv-gw55-r5fq","https://nvd.nist.gov/vuln/detail/CVE-2024-27302","https://github.com/zeromicro/go-zero/commit/d9d79e930dff6218a873f4f02115df61c38b15db","https://github.com/zeromicro/go-zero"],"sourceUrl":"https://github.com/advisories/GHSA-fgxv-gw55-r5fq","license":"GitHub Advisory Database · CC-BY-4.0","key":"osv:GHSA-fgxv-gw55-r5fq","identifiers":["GHSA-fgxv-gw55-r5fq","CVE-2024-27302","GO-2024-2604"]},"retained":false,"historicalAffected":[]}],"coverage":[]}