Описание
Authorization Bypass Through User-Controlled Key in go-zero
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
PoC
Use code below as a PoC. Only requests from safe.com should bypass the CORS Filter
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.
Пакеты
github.com/zeromicro/go-zero
< 1.4.4
1.4.4
Связанные уязвимости
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.