Cloudreve WOPI access tokens are generated as <session-id>.<random-secret>, but the WOPI middleware validates only the session id prefix and never compares the supplied token to the stored token. In addition, a WOPI viewer session does not store or enforce the requested viewer action. A session created for a view or preview action can still call WOPI write routes if the underlying file is writable by the session user.
A WOPI integration that is only expected to view a user's file can modify that file through the WOPI write endpoints. If the WOPI URL or session id leaks, the random token suffix does not protect the session because any suffix is accepted for an existing session id.
This affects deployments that configure WOPI viewers for user files. The attacker primitive is strongest when a malicious or compromised WOPI viewer receives a view-only URL and then writes content back to Cloudreve.
Verified in source and runtime on latest master commit ba2e870bbd17f1918dd2321de861e453f696d6a3 and latest observed tag 4.16.1.
Cloudreve creates WOPI viewer sessions in pkg/filemanager/manager/viewer.go:
sessionID := uuid.Must(uuid.NewV4()).String()
token := util.RandStringRunesCrypto(128)
sessionCache := &ViewerSessionCache{
ID: sessionID,
Uri: file.Uri(false).String(),
UserID: m.user.ID,
ViewerID: viewer.ID,
FileID: file.ID(),
Version: version,
Token: fmt.Sprintf("%s.%s", sessionID, token),
}
The token includes a 128-character random suffix, but middleware.ViewerSessionValidation() only uses the prefix before the dot:
accessToken := strings.Split(c.Query(wopi.AccessTokenQuery), ".")
if len(accessToken) != 2 {
...
}
sessionRaw, exist := store.Get(manager.ViewerSessionCachePrefix + accessToken[0])
The middleware checks that the file id matches the loaded session, but it never compares c.Query("access_token") with...
4.0.0-20260626022433-f3347130ac48Exploitability
AV:NAC:LPR:LUI:RScope
S:UImpact
C:LI:HA:N6.3/CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:H/A:NAccess Control