{"id":"CVE-2024-27302","aliases":["CVE-2024-27302","GHSA-fgxv-gw55-r5fq","GO-2024-2604"],"related":[],"kind":"vulnerability","state":"published","title":"Authorization Bypass Through User-Controlled Key in go-zero","summary":"go-zero is a web and rpc framework. Go-zero allows user to specify a CORS Filter 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 a malicious domain. This vulnerability is capable of breaking CORS policy and thus allowing any page to make requests and/or retrieve data on behalf of other users. Version 1.4.4 fixes this issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"go-zero is a web and rpc framework. Go-zero allows user to specify a CORS Filter 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 a malicious domain. This vulnerability is capable of breaking CORS policy and thus allowing any page to make requests and/or retrieve data on behalf of other users. Version 1.4.4 fixes this issue.","source":"cvelist"},{"lang":"en","text":"### 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.","format":"markdown","source":"ghsa"},{"lang":"en","text":"The CORS Filter feature in go-zero allows users to specify an array of domains allowed in the CORS policy. However, the isOriginAllowed function uses strings.HasSuffix to check the origin, which can lead to a bypass via a domain like \"evil-victim.com\". This vulnerability is capable of breaking CORS policy and thus allowing any page to make requests and retrieve data on behalf of other users.","format":"markdown","source":"go"},{"lang":"es","text":"go-zero es un framework web y rpc. Go-zero permite al usuario especificar un filtro CORS con un parámetro de permisos configurable, que es una serie de dominios permitidos en la política CORS. Sin embargo, `isOriginAllowed` usa `strings.HasSuffix` para verificar el origen, lo que lleva a pasar por alto un dominio malicioso. Esta vulnerabilidad es capaz de romper la política CORS y así permitir que cualquier página realice solicitudes y/o recupere datos en nombre de otros usuarios. La versión 1.4.4 soluciona este problema.","source":"nvd"}],"published":"2024-03-04T20:42:33.000Z","modified":"2026-09-10T03:50:10.507Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N","score":9.1,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N","score":9.1,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N","score":9.1,"rating":"CRITICAL"}],"cwes":["CWE-639"],"affected":[{"ranges":[{"version":"< 1.4.4","status":"affected"}],"vendor":"zeromicro","product":"go-zero","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"0","fixed":"1.4.4","status":"affected"}],"vendor":"zeromicro","product":"go-zero","cpe":"cpe:2.3:a:zeromicro:go-zero:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.4.4"}],"ecosystem":"Go","package":"github.com/zeromicro/go-zero","purl":"pkg:golang/github.com/zeromicro/go-zero","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.4.4"}],"ecosystem":"Go","package":"github.com/zeromicro/go-zero","purl":"pkg:golang/github.com/zeromicro/go-zero","source":"go"},{"ranges":[{"status":"affected","fixed":"1.4.4"}],"vendor":"go-zero","product":"go-zero","cpe":"cpe:2.3:a:go-zero:go-zero:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/zeromicro/go-zero/security/advisories/GHSA-fgxv-gw55-r5fq","tags":["advisory","exploit","vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/zeromicro/go-zero/commit/d9d79e930dff6218a873f4f02115df61c38b15db","tags":["fix","patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-27302","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/zeromicro/go-zero","tags":["package"],"sources":["ghsa"]}],"credits":["cokeBeer"],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"total","date":"2024-08-05T20:08:07.431Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-27302","url":"https://www.cve.org/CVERecord?id=CVE-2024-27302","licence":"CVE Terms of Use","modified":"2024-08-05T20:09:47.572Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-fgxv-gw55-r5fq","url":"https://github.com/advisories/GHSA-fgxv-gw55-r5fq","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:10.507Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2024-2604","url":"https://pkg.go.dev/vuln/GO-2024-2604","licence":"CC-BY-4.0","modified":"2024-05-20T16:03:47.000Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-27302","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-27302","licence":"Public domain","modified":"2026-06-17T07:19:36.433Z"}],"updatedAt":"2026-11-25T22:58:37.309Z","epss":{"score":0.00774,"percentile":0.56958,"date":"2026-12-01T12:00:22.000Z"}}