Skip to content

False positive: missing-function-level-access-control with custom Authorize attribute #19279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
phil000 opened this issue Apr 10, 2025 · 4 comments

Comments

@phil000
Copy link

phil000 commented Apr 10, 2025

Description of the false positive

We are using .NET and C# code scanning.

The issue raised is 'cs/web/missing-function-level-access-control'

We have a custom attribute 'RequirePermission' on the action methods (or sometimes on the controller) that inherits from [Authorize] attribute. This is providing the access control.

e.g. Action Method

[RequirePermission(OnSendPermissions.ManagePricing)]
[HttpDelete("{extraId:int:min(1)}/rates/{rateId:int:min(1)}")]
public async Task<IActionResult> DeleteDeliveryExtraRate(int extraId, int rateId)

e.g. Custom Authorize Attribute that checks permissions

public class RequirePermissionAttribute : AuthorizeAttribute

Presumably you are not checking attribute inheritance.

@michaelnebel
Copy link
Contributor

Yes, I think you are right; The query uses the attribute name (and not any attribute type super types) to get an indication whether permissions are controlled by attributes.

@michaelnebel
Copy link
Contributor

This will be addressed here: #19302

@michaelnebel
Copy link
Contributor

Thank you for reporting this and for providing details on, what you think the issue is! It is a big time saver!

@michaelnebel
Copy link
Contributor

PR merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants