# Database resource exhaustion for logged-in users via sharee recommendations with circles

Logged-in user creates >50 circle-folder shares, then hits sharees_recommended endpoint which loops until max_execution_time, exhausting DB/CPU.

- Payout: $250
- Severity: medium
- Program: Nextcloud
- Found by: michag86
- Disclosed: 2022-11-26
- CVE: CVE-2022-39330
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1688199
- Library page: https://bugbountylibrary.com/r/h1%3A1688199
- Tags: area:web domain:web impact:dos kind:bounty platform:hackerone sev:medium tech:php technique:recon vuln:business-logic vuln:dos

**Target:** Nextcloud circles app / files_sharing sharees_recommended OCS endpoint
**Root cause:** The sharee recommendation logic iterates over circle-folder share combinations without bounding the work, so the number of combinations (circles × folders) drives an unbounded loop.
**Steps:**
1. Create 9 circles and 6 folders so circles*folders > 50.
2. Share every folder with every circle.
3. Open another folder's share tab to trigger `GET /ocs/v2.php/apps/files_sharing/api/v1/sharees_recommended`.
4. Observe the request loops until PHP `max_execution_time` (default 3600s) is reached.
5. Repeat a few requests to stress DB/CPU on large servers.
**How found:** Researcher noticed the recommendation endpoint's cost scaled with the number of circle-folder share combinations and tested the >50 threshold to trigger the loop.
**Exploitation:** Any authenticated user with share permissions sets up the circle/folder matrix, then repeatedly requests the sharees_recommended endpoint; each request consumes a full max_execution_time window of DB/CPU, degrading availability for all users.
**Insight:** Recommendation/autocomplete endpoints that fan out over user-created share graphs are prime DoS targets: count the multiplicative combinations (groups × resources) an attacker can cheaply create and check whether the endpoint bounds its iteration.

