Cloudreve: Broken Access Control in file event stream: a single-file share recipient is subscribed to the owner's parent folder and receives activity events for unshared siblings
위협 신호 · CVSS · EPSS · KEV
이론적 심각도 점수
예측 데이터 없음
실측 악용 기록 없음
계획된 패치 주기 내 조치(60일 이내)
CVSS 벡터 · 메트릭
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N상세 설명
Summary
When an authenticated recipient of a single-file share opens the file event stream (GET /api/v4/file/events?uri=<share-root>), Cloudreve validates the URI by listing it and then subscribes the caller to parent.ID(). For a single-file share, the share navigator resolves the bare share-root URI to the owner-side parent folder of the shared file (not the file), while the visible listing is filtered down to just the shared file. The event hub then keys topics by numeric file ID only and, on each file change, fans the event out to subscribers of every ancestor topic, filtering only the client ID that caused the event — never the subscriber's share scope.
Consequently, a recipient of one shared file can receive Server-Sent Events (type, sibling path/name, rename target, hashed file ID) for other files and subfolders in the owner's parent folder that were never shared. Contents are not disclosed; file-activity metadata is.
Details
Root cause (verified at 26b6b10)
1. Events route — authenticated, feature-flagged, no share-scope check (routers/router.go):
1file := v4.Group("file"); file.Use(middleware.RequiredScopes(types.ScopeFilesRead)) 2file.GET("events", 3 middleware.LoginRequired(), 4 middleware.IsFunctionEnabled(func(c *gin.Context) bool { return dep.SettingProvider().EventHubEnabled(c) }), 5 controllers.FromQuery[explorer.ExplorerEventService](...), controllers.HandleExplorerEventsPush)EventHubEnabled defaults true (inventory/setting.go: "fs_event_push_enabled":"1").
2. Service subscribes to the listed parent's ID (service/explorer/events.go):
1parent, _, err := m.List(c, uri, &manager.ListArgs{Page:0, PageSize:1}) // also runs share validity/password 2... 3rx, resumed, err := eventHub.Subscribe(c, parent.ID(), requestInfo.ClientID)3. Single-file share Root swaps the share root to the owner parent (share_navigator.go):
1n.shareRoot = newFile(nil, share.Edges.File) 2... 3if n.shareRoot.Type() == types.FileTypeFile { 4 n.singleFileShare = true 5 n.shareRoot = n.shareRoot.Parent // <-- owner-side parent folder 6}4. To returns that parent for the bare root URI (share_navigator.go):
1elements := path.Elements() 2if len(elements) == 1 && n.singleFileShare { return latestSharedSingleFile(...) } // only when URI names the file 3... 4return current // current == shareRoot == owner parent folderThe bare root share URI has zero path elements (URI.Elements() returns nil for path /), so the len(elements)==1 guard is skipped and To returns the parent folder. dbfs.List returns that as parent, so parent.ID() is the owner parent folder's real ID.
5. Children masks the broader parent — for singleFileShare it returns only []*File{sharedFile}, so the recipient's listing shows just the shared file even though the subscribed topic is the whole parent.
6. Publication fans out to ancestor topics with only a client-ID filter (dbfs/events.go):
1func (f *DBFS) getEligibleSubscriber(ctx, file, checkParentPerm) []foundSubscriber { 2 roots := file.Ancestors() 3 for _, root := range roots { 4 subscribers := f.eventHub.GetSubscribers(ctx, root.Model.ID) 5 subscribers = lo.Filter(subscribers, func(s eventhub.Subscriber, _ int) bool { 6 return !(requestInfo != nil && s.ID() == requestInfo.ClientID) // ONLY exclude the causing client 7 }) 8 ... 9 }10}11// emit*: From: subscriber.relativePath(file) // owner-side path of the changed siblingrelativePath trims the changed file's owner path by the subscribed root's owner path, yielding the sibling's name (e.g. /Secret-Plan.pdf). No check that the subscriber is authorized for the changed file or within their share scope.
Validation performed
Independent validation against commit 26b6b10 in a clean sandbox.
Source-verified (static): all of (1)–(6) confirmed verbatim, including the negative direction (an explicit …/shared.txt URI resolves to the file, and oss/qiniu-style flows are irrelevant here).
Dynamic (control-flow executed): the full binary is not buildable offline (modules behind an unreachable proxy, embedded frontend, DB/eventhub). The reseacher ran two harnesses:
- A
net/url-based check of the linchpin — the bare root share URI yields0path elements (soToreturns the parent), while…/shared.txtyields1(returns the file). This is the subtle point on which the whole finding turns, and it holds. - A model of
Root/To/getEligibleSubscriber/relativePathdriving the end-to-end flow:
1[1] single-file share root URI -> m.List parent = "docs" (id 10), NOT shared.txt (id 11) -> subscribed to owner parent 2[2] owner renames /docs/Secret-Plan.pdf -> client 'attacker' receives: from="/Secret-Plan.pdf" file_id=12 (topic 10) 3[3] CONTROL: event caused by attacker's own client id -> suppressed (the only filter) 4[4] CONTROL: explicit URI 'shared.txt' -> resolves to file (id 11) -> no sibling eventsSteps to reproduce
- Owner shares a single file
shared.txtfrom/docs, which also containsSecret-Plan.pdf. - Recipient (logged-in,
Files.Read, with the share password if any) opens the event stream on the share root:text1GET /api/v4/file/events?uri=cloudreve%3A%2F%2F<share-id>%40share2Cookie: cloudreve-session=<recipient-session>3X-Cr-Client-Id: <uuid>4Accept: text/event-stream - Owner creates/renames/modifies/moves/deletes
Secret-Plan.pdf. - The recipient's stream receives, e.g.:
text1event: event2data: {"type":"rename","file_id":"<hashed>","from":"/Secret-Plan.pdf","to":"/Secret-Plan-v2.pdf"}
Expected: the recipient only receives events for the shared file.
Actual: the recipient receives activity events for unshared siblings in the owner's parent folder.
Impact
A single-file share recipient gains a real-time feed of file-activity metadata for the owner's parent folder — sibling names, operation types, and rename targets they were never granted access to. No file contents are exposed.
Remediation
- For single-file shares, subscribe to the shared file's ID, or reject event subscriptions on the single-file share root view.
- Store an authorization scope (navigator/share root) per subscriber and publish only events whose path stays within that scope.
- Incorporate user/share scope into topic keys, not just file ID + client ID.
- On subscriber reactivation, re-verify the requester still matches the subscriber and is authorized for the topic.
AI 심층 분석
공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.