Summary
gogs api still accepts tokens in url params like token and access_token, which can leak through logs, browser history, and referrers
Details
static review shows the api still checks tokens in the url query before looking at headers
- internal/context/auth.go reads c.Query("token")
- internal/context/auth.go falls back to c.Query("access_token")
- internal/context/auth.go only checks authorization header when query token is empty
- internal/context/auth.go authenticates using that token and marks request as token-authenticated
token authenticated requests are accepted by API routes through c.IsTokenAuth checks
- internal/route/api/v1/api.go
Impact
if users send tokens in urls like /api/v1/user?token=..., they can leak in logs, browser or shell history, and referrer headers, and can be reused until revoked
Recommended fix
- use auth headers only for tokens
- block token params at proxy or waf
- scrub query strings from logs
- set strict referrer policy
Summary
gogs api still accepts tokens in url params like token and access_token, which can leak through logs, browser history, and referrers
Details
static review shows the api still checks tokens in the url query before looking at headers
token authenticated requests are accepted by API routes through c.IsTokenAuth checks
Impact
if users send tokens in urls like /api/v1/user?token=..., they can leak in logs, browser or shell history, and referrer headers, and can be reused until revoked
Recommended fix