The vulnerability is a path traversal that allows an authenticated user to read arbitrary files on the server. The analysis of the provided information, including the detailed vulnerability description and the commit patch, reveals two key functions involved in this vulnerability.
-
SliverRPC.WebsiteAddContent in server/rpc/rpc-website.go: This is the entry point of the vulnerability. It's a gRPC method that allows an operator to add content to a website. The vulnerability description explicitly states that this function accepts a content.Path from the operator and persists it without proper validation. This allows an attacker to save a malicious path (e.g., ../../../../etc/passwd) in the database.
-
Website.ToProtobuf in server/db/models/website.go: This function is responsible for preparing the website content to be sent over gRPC. The provided patch clearly shows that this function was vulnerable. Before the fix, it used os.ReadFile(filepath.Join(webContentDir, webcontent.Path)) to read the content of a file. The webcontent.Path is the value that was previously stored via WebsiteAddContent. Since this path is not sanitized, filepath.Join does not prevent the path traversal, leading to an arbitrary file read. The patch fixes this by using a non-user-controllable identifier (webcontent.ID.String()) to construct the file path, thus mitigating the vulnerability.
Therefore, an exploit would first call WebsiteAddContent to store a malicious path, and then trigger a call to Website.ToProtobuf (likely via the Website gRPC method) to read and retrieve the content of an arbitrary file on the server.