Handle store authorization resources
What changed, and why it matters
This commit changes how BTCPay Server figures out which store a user is acting on behalf of during permission checks. Previously, when an authorization policy checked a scoped permission, the code only looked at the raw 'resource' object as a plain string. The patch adds a fallback: if the resource is a StoreData object, use that store's ID as the scope. This likely fixes a bug where store-scoped permissions were not being resolved correctly in certain code paths, which could allow a user with permission on one store to perform actions on another store or have their permissions evaluated incorrectly. However, the diff is tiny and partial, so the exact attack path is not visible from this commit alone.
Treat as a likely authorization bug fix. Review related pull request and issue history to confirm whether this fixed a reported security issue. Audit other authorization handlers and resource types for similar missing scope extraction. If this was a security fix, request a CVE and advisory from the project maintainers.
Security signals we found
Authorization scope resolution fallback added for StoreData resource
Potential incorrect scope fallback before patch could cause cross-store authorization errors
Single-line patch in security-critical authorization handler
No explicit security disclosure, CVE, or researcher attribution in commit or references
Evidence from the diff
In PermissionAuthorizationHandler.cs, the HandleRequirementAsync method derives the authorization scope from context.Resource. Before the patch, it only attempted scope = context.Resource as string;. The patch adds scope ??= (context.Resource as Data.StoreData)?.Id;, allowing the handler to extract a store ID when the resource is a StoreData instance rather than a string. This is an authorization-scope resolution fix. The change suggests that some authorization paths pass a StoreData object as the resource but the handler did not recognize it, causing the scope to fall back to an implicit scope lookup. A misresolved scope could lead to incorrect access-control decisions, such as applying the current user’s default/implicit store scope instead of the explicitly provided store resource.
Changed components
BTCPayServer/Security/PermissionAuthorizationHandler.csStore-scoped authorization requirementsAuthorizationHandlerContext resource handlingInspect captured patch +1 / −0
### BTCPayServer/Security/PermissionAuthorizationHandler.cs
@@ -32,6 +32,7 @@ protected override async Task HandleRequirementAsync(AuthorizationHandlerContext
if (!requirement.RequireUnscoped)
{
scope = context.Resource as string;
+ scope ??= (context.Resource as Data.StoreData)?.Id;
explicitScope = scope is not null;
if (!explicitScope)
scope = await GetImplicitScope(userId, context, requirement, httpContext.HttpContext);Why this scored 63/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.