Skip to content
Access control Disclosed report Intermediate

Group restriction bypass via bearer token in user_oidc (SETTING_RESTRICT_LOGIN_TO_GROUPS not enforced in Backend::getCurrentUserId)

The user_oidc app enforced group-based login restrictions in the browser OIDC flow but not when validating bearer tokens, so a user outside the allowed groups could still access the Nextcloud API with a valid bearer token. Exploitation required the OAuth client secret to exchange an authorization code for a token, limiting it to attackers with privileged identity provider access.

msatz Follow

Originally disclosed on HackerOne

Bounty$150 Medium 4.2 View original
  • Triaged in 4 hours
  • Fixed in 42 days
  • Paid in 7 months
  • Disclosed after 3 months

Summary by the program

A security inconsistency was identified in the user_oidc app where group-based login restrictions were enforced in the browser OIDC flow but not in bearer token validation. This could allow users outside whitelisted groups to access the Nextcloud API with a valid bearer token.

Exploitation requires possession of the OAuth client_secret for the OIDC client configuration to exchange an authorization code into a bearer token, limiting practical exploitability to scenarios where an attacker has privileged access to the identity provider infrastructure.

The original report as published on HackerOne, by msatz. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 4 min read.

What the report shows

The target is the user_oidc app for Nextcloud, which lets a Nextcloud instance delegate authentication to an OpenID Connect identity provider. The app supports a setting, SETTING_RESTRICT_LOGIN_TO_GROUPS, that limits who may log in to members of whitelisted groups. The researcher, msatz, found that this restriction was applied in the browser-based OIDC login flow but not when a bearer token was validated.

The report is short and does not include a reproduction with requests, so the sequence below is the one the summary describes rather than a captured exchange:

  1. An OIDC client is configured against the Nextcloud instance, with group-based login restriction enabled.
  2. A user who is not in any whitelisted group completes the OIDC flow at the identity provider and obtains an authorization code.
  3. The authorization code is exchanged for a bearer token. This exchange requires the OAuth client_secret of the OIDC client configuration.
  4. The bearer token is presented to the Nextcloud API. The token is accepted even though the user is outside the whitelisted groups, because the group check is missing from bearer token validation.

The result is that a user the administrator intended to keep out can reach the Nextcloud API. The program classified the issue as medium severity with a CVSS score of 4.2, under the weakness "Improper Access Control - Generic", and paid a bounty of 150.00 USD. The report was disclosed on 2026-05-21. The text does not describe the patch itself.

The program is explicit about the limits: exploitation requires possession of the OAuth client_secret for the OIDC client configuration, in order to exchange an authorization code into a bearer token. That confines practical exploitation to scenarios where an attacker already has privileged access to the identity provider infrastructure.

Root cause

The root cause is that the group restriction is enforced in one authentication path only. The browser flow and the bearer token path are separate code paths, and the check for SETTING_RESTRICT_LOGIN_TO_GROUPS was implemented in the former but omitted from the latter, specifically from the logic that resolves the current user from a bearer token (Backend::getCurrentUserId).

Impact

A user outside the whitelisted groups can use the Nextcloud API with a valid bearer token, defeating the administrator's group-based access restriction. The report does not enumerate which API operations were reachable or what data was exposed, so the impact should be read as "API access that the configuration intended to deny". The client_secret requirement substantially reduces real-world risk, since an attacker who can perform the code exchange already holds a privileged secret from the identity provider side.

How this kind of bug works

Access control bugs of this class arise when a policy is checked at one layer and a second layer trusts the result without re-checking. In OIDC deployments there are typically several ways to become an authenticated principal: a browser session established through the interactive flow, a bearer token presented on API calls, and sometimes refresh tokens or app passwords. Each path has its own code that maps credentials to a user identity. If the group restriction is written into the interactive flow only, the token path authenticates the user successfully and never asks whether that user is allowed.

The bearer token itself is usually valid: it was issued by the identity provider to a real user. The bug is not token forgery but a missing authorisation decision after successful authentication. Defences are structural: centralise the group check in the identity resolution used by every path, deny by default when the setting is on and group membership cannot be confirmed, and test each authentication path against the restriction.

How to test for it

  1. Identify targets where login is delegated to an external identity provider and where the application exposes a group or role restriction setting. Documentation and admin settings pages are the best source.
  2. Create two accounts at the identity provider: one inside the allowed group and one outside it.
  3. Confirm the restriction works in the browser: log in as the outside user through the interactive flow and check that access is refused.
  4. Obtain a bearer token for the outside user through the normal OAuth flow, using the client credentials the deployment issues.
  5. Send API requests with that token in the Authorization: Bearer header, targeting endpoints that return the current user identity and any data the outside user should not see.
  6. A positive result is an authenticated response for a user the interactive flow rejects, especially one that returns that user's identity or data.

Common false positives: the token may belong to a user who was in the group at issue time; the API may return only public data regardless of identity; caching or session reuse may make a browser test look like a bypass when it is not; and some deployments intentionally allow API tokens broader access than interactive login, which is a design decision rather than a bug. Confirm the group membership at the identity provider at the moment of testing, and repeat the request to rule out stale state.

How it is fixed

A fix would apply the same group membership check wherever a user identity is established from OIDC credentials, including bearer token validation, so that a token for a user outside the whitelisted groups is rejected.

Hunting notes

This bug class hides in applications that support multiple authentication mechanisms: SSO plus API tokens, session cookies plus personal access tokens, or interactive login plus machine-to-machine credentials. Recon signals include admin documentation describing group, role or tenant restrictions, OIDC or SAML configuration pages, and API documentation that accepts bearer tokens. When you find such a target, enumerate every way to obtain a credential and test the restriction against each one.

State clearly what the attacker needs to exploit it, as this report does with the client_secret requirement, so the program can judge severity accurately.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 6 min read.

What happened, in plain words

Nextcloud is software that lets an organisation run its own file storage and collaboration server, a bit like a private version of Google Drive. The user_oidc app is an add-on for Nextcloud that lets the server hand off the job of checking who you are to a separate service, called an identity provider. Think of it like a building that does not check your badge itself but asks the security desk at the entrance to do it for them.

That identity provider can group people, for example "staff" and "contractors". The user_oidc app has a setting called SETTING_RESTRICT_LOGIN_TO_GROUPS that lets an administrator say: only people in these listed groups may log in. Everyone else should be turned away.

The researcher, msatz, found that this rule was only half applied. When a person logs in through a normal web browser, the group check runs and outsiders are refused. But there is a second way to prove who you are, using a bearer token, and on that path the group check was missing. A bearer token is a long string of characters that you attach to a request instead of logging in each time, like a cloakroom ticket: whoever holds it is treated as the person it was issued to. The check was missing from the bearer token validation path.

The program's summary describes the sequence like this:

  1. An administrator sets up the OIDC connection to Nextcloud and switches on the group restriction.
  2. A user who is not in any of the allowed groups goes through the login process at the identity provider and receives an authorization code. An authorization code is a short-lived one-time slip that proves you just logged in.
  3. That code is swapped for a bearer token. This swap requires the OAuth client_secret, a password-like value belonging to the Nextcloud connection at the identity provider.
  4. The bearer token is sent to the Nextcloud API, the programming interface that other software uses to talk to Nextcloud. The token is accepted even though the user is outside the allowed groups.

The result is that someone the administrator meant to keep out can reach the Nextcloud API. The report does not say which API operations were reachable or what data could be seen, so the impact is best read as "API access the configuration intended to deny".

The program was clear about the limits. To exploit this, an attacker needs the OAuth client_secret in order to turn an authorization code into a bearer token. That means the practical risk is confined to situations where the attacker already has privileged access to the identity provider infrastructure. In everyday terms: the door was left unlocked, but you still needed a key from the security desk to get to it.

The issue was rated medium severity with a CVSS score of 4.2, under the weakness "Improper Access Control - Generic", and a bounty of 150.00 USD was paid. It was disclosed on 2026-05-21. The report does not describe the patch itself.

In general, how this kind of bug works

This is an access control bug, and the pattern is common: a rule is checked in one place and a second place trusts the result without checking again. Imagine a club with two entrances, a front door with a bouncer holding the guest list and a side door with a turnstile that only checks whether your ticket is genuine. The ticket is real, so the turnstile lets you in, but nobody asks whether you are on the list.

In systems that use OIDC, there are usually several ways to become a recognised user: a browser session from the interactive login, a bearer token on API calls, and sometimes refresh tokens or app passwords. Each path has its own code that turns credentials into a user identity. If the group restriction is written into the browser path only, the token path authenticates the user successfully and never asks whether that user is allowed.

The token itself is usually genuine: the identity provider issued it to a real user. The bug is not a forged token but a missing authorisation decision after successful authentication. Authentication answers "who are you?"; authorisation answers "are you allowed to do this?". Here the first question was answered and the second was skipped.

  • Put the group check in the shared identity resolution used by every path, so new entry points inherit it.
  • Fail closed: if the setting is on and group membership cannot be confirmed, deny access.
  • Test each authentication path separately against the restriction.
  1. Find applications that delegate login to an external identity provider and offer a group or role restriction setting. Admin documentation and settings pages are the best source.
  2. Create two accounts at the identity provider, one inside the allowed group and one outside.
  3. Confirm the restriction works in the browser: log in as the outside user and check that access is refused.
  4. Obtain a bearer token for the outside user through the normal OAuth flow, using the client credentials the deployment issues.
  5. Send API requests with that token in the Authorization: Bearer header, targeting endpoints that return the current user identity and any data the outside user should not see.
  6. A positive result is an authenticated response for a user the browser flow rejects, especially one that returns that user's identity or data.

Watch out for false positives. The token may belong to a user who was in the group at the time; the API may return only public data regardless of identity; caching or session reuse can make a browser test look like a bypass when it is not; and some deployments deliberately allow API tokens broader access than interactive login, which is a design choice rather than a bug. Confirm group membership at the identity provider at the moment of testing and repeat the request to rule out stale state.

State clearly what an attacker needs, as this report does with the client_secret requirement, so the program can judge severity accurately.

Glossary

  • Nextcloud: software for running your own file storage and collaboration server.
  • user_oidc: a Nextcloud app that delegates login to an external identity provider using OpenID Connect.
  • OpenID Connect (OIDC): a standard way for one service to let another service verify who a user is.
  • Identity provider: the external service that checks credentials and confirms a user's identity.
  • SETTING_RESTRICT_LOGIN_TO_GROUPS: a user_oidc setting that limits login to members of listed groups.
  • Bearer token: a string attached to a request that proves identity, like a cloakroom ticket; whoever holds it is treated as its owner.
  • Authorization code: a short-lived one-time slip issued after login, exchanged for a token.
  • OAuth client_secret: a password-like value belonging to a client configuration, used in the code-to-token exchange.
  • API: a programming interface that software uses to talk to a service.
  • Backend::getCurrentUserId: the code that works out which user a bearer token belongs to.
  • Authentication: establishing who a user is.
  • Authorisation: deciding whether that user is allowed to do something.
  • Access control: the rules that decide who may access what.
  • Improper Access Control - Generic: a weakness category for missing or incorrect access rules.
  • CVSS: a scoring system for the severity of a vulnerability.
  • Bounty: a payment made to a researcher for reporting a valid vulnerability.
  • Fail closed: denying access when a check cannot be completed, rather than allowing it.
  • False positive: a test result that looks like a bug but is not one.

More from Nextcloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.