Skip to content

Guard the provider cache against concurrent access - #5765

Open
btwshivam wants to merge 1 commit into
cs3org:masterfrom
btwshivam:fix-oidc-provider-race
Open

Guard the provider cache against concurrent access#5765
btwshivam wants to merge 1 commit into
cs3org:masterfrom
btwshivam:fix-oidc-provider-race

Conversation

@btwshivam

@btwshivam btwshivam commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

getOIDCProviderForIssuer reads and writes am.providers with no lock, which the code already flags with // FIXME: op not atomic.

two logins landing together for an issuer that isn't cached yet race on that map. Go doesn't make this a panic, it's fatal error: concurrent map writes, so neither recover() nor the grpc recovery interceptor catches it and revad exits.

map is empty after every restart, so the window is the first logins after one, which is also when a lot of people tend to log in at once. With more than one issuer configured a read racing a write is equally fatal, so it isn't only a startup thing.

guarded with a RWMutex and a re-check under the write lock. Discovery stays outside the lock, otherwise one unreachable issuer would block logins for every other issuer, and goes through a singleflight group so a burst costs the IdP one request instead of one per caller.

Testing

ran with -race against master the same tests report the data race and die with the fatal error, with the fix they pass. also assert that concurrent logins cause a single discovery request, dropping the singleflight makes that fail

Signed-off-by: btwshivam <shivam.devline@gmail.com>
@btwshivam btwshivam changed the title fix(oidc): guard the provider cache against concurrent access Guard the provider cache against concurrent access Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant