fix(http): enforce download permission on the checksum branch

The ?checksum= branch of the resource GET handler read the whole file to
compute its digest and returned it without checking Perm.Download, unlike the
sibling raw, preview, subtitle and X-Encoding paths. A user provisioned with
Perm.Download=false could therefore obtain md5/sha1/sha256/sha512 digests of
files they are not allowed to download, giving a file-content hash oracle, and
force a full-file read.

Return 202 Accepted before computing the checksum when the user lacks
Perm.Download, matching the other read paths. This completes the fix for
CVE-2026-35606, whose original patch gated only the content-returning paths.

Refs GHSA-7whw-q6gh-xr59
This commit is contained in:
Henrique Dias committed 2026-07-25 08:16:18 +02:00
1 parent 4b8a8d72ce
commit 6c69b5cd89
1 file changed
+4
+4
View File
@@ -67,6 +67,10 @@ var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
}
if checksum := r.URL.Query().Get("checksum"); checksum != "" {
if !d.user.Perm.Download {
return http.StatusAccepted, nil
}
err := file.Checksum(checksum)
if errors.Is(err, fberrors.ErrInvalidOption) {
return http.StatusBadRequest, nil