Summary
Authorization Bypass Through User-Controlled Key in go-zero
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
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 has a CVSS score of 9.1 (Critical). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (1.4.4); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is CVE-2024-27302? CVE-2024-27302 is a critical-severity security vulnerability in github.com/zeromicro/go-zero (go), affecting versions < 1.4.4. It is fixed in 1.4.4.
- How severe is CVE-2024-27302? CVE-2024-27302 has a CVSS score of 9.1 (Critical). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of github.com/zeromicro/go-zero are affected by CVE-2024-27302? github.com/zeromicro/go-zero (go) versions < 1.4.4 is affected.
- Is there a fix for CVE-2024-27302? Yes. CVE-2024-27302 is fixed in 1.4.4. Upgrade to this version or later.
- Is CVE-2024-27302 exploitable, and should I be worried? Whether CVE-2024-27302 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2024-27302 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2024-27302? Upgrade
github.com/zeromicro/go-zeroto 1.4.4 or later.