9.1critical
Authorization Bypass Through User-Controlled Key in go-zero
- Severity
- 9.1critical CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.77% (higher than 56% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-fgxv-gw55-r5fqGO-2024-2604
Description
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| zeromicro go-zero | < 1.4.4, before 1.4.4 | CVE List |
| github.com/zeromicro/go-zero (Go) | before 1.4.4 | GitHub Advisory Database, Go Vulnerability Database |
| go-zero go-zero | before 1.4.4 | NVD |
All scores
| GitHub_M | 9.1critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N |
| GitHub | 9.1critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N |
Classification
SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact total.
What each source says
CVE List
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.
GitHub Advisory Database
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 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
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
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
Impact
This vulnerability is capable of breaking CORS policy and thus allowing any page to make requests, retrieve data on behalf of other users.
Go Vulnerability Database
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.
NVD (es)
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.
References
| https://github.com/zeromicro/go-zero/security/advisories/GHSA-fgxv-gw55-r5fq | advisory, exploit, vendor-advisory, web | |
| https://github.com/zeromicro/go-zero/commit/d9d79e930dff6218a873f4f02115df61c38b15db | fix, patch, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2024-27302 | advisory | |
| https://github.com/zeromicro/go-zero | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-27302 changed 2024-08-05 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-fgxv-gw55-r5fq changed 2026-09-10 | CC-BY-4.0 |
| Go Vulnerability Database | GO-2024-2604 changed 2024-05-20 | CC-BY-4.0 |
| NVD | CVE-2024-27302 changed 2026-06-17 | Public domain |