Skip to content

Commit 63eede3

Browse files
committed
fix some lockdown bugs
1 parent ed46c85 commit 63eede3

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121

2222
### Fixed
2323

24+
- Optional-auth routes (`GET /bots/{id}`, `/servers/{id}`, `/teams/{id}`,
25+
`/users/{id}`) rejected valid user sessions that failed the "limited to
26+
Bug Hunters" Origin check or belonged to a banned user, with a 403
27+
instead of serving the public response. Server-rendered pages send no
28+
`Origin`, so every logged-in regular user got "Bot not found" on
29+
approved bots. Those sessions are now treated as anonymous on
30+
optional-auth routes.
31+
2432
- The `noxss` validator's event-handler check matched any `on<letters>=`
2533
anywhere in the text, so an ordinary bot invite link
2634
(`...applications.commands&permissions=...`) made a long description

‎api/uapi.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ func Authorize(r uapi.Route, req *http.Request) (uapi.AuthData, uapi.HttpRespons
193193

194194
if urlutil.DifferentHost(req.Header.Get("Origin"), state.Config.Sites.Frontend) &&
195195
!bugHunter && !perms.IsConfigOwner(targetId) {
196+
if r.AuthOptional {
197+
return uapi.AuthData{}, uapi.HttpResponse{}, true
198+
}
199+
196200
return uapi.AuthData{}, uapi.HttpResponse{
197201
Status: http.StatusForbidden,
198202
Json: types.ApiError{Message: "This environment is limited to Bug Hunters."},
@@ -295,6 +299,10 @@ func Authorize(r uapi.Route, req *http.Request) (uapi.AuthData, uapi.HttpRespons
295299
}
296300

297301
if authData.Banned && auth.AllowedScope != "ban_exempt" {
302+
if r.AuthOptional {
303+
return uapi.AuthData{}, uapi.HttpResponse{}, true
304+
}
305+
298306
return uapi.AuthData{}, uapi.HttpResponse{
299307
Status: http.StatusForbidden,
300308
Json: types.ApiError{Message: "You are banned from the list. If you think this is a mistake, please contact support."},

0 commit comments

Comments
 (0)