Skip to content
This repository has been archived by the owner on Sep 11, 2019. It is now read-only.

SG0016 - allow user to change/add to the Token checking attribute name #90

Open
duncan-bradley opened this issue Oct 11, 2017 · 1 comment

Comments

@duncan-bradley
Copy link

I have a custom attribute for token checking, and it would be greate to be able to add this to the attribute list that RSG uses. So, instead of [ValidateAntiForgeryToken], I have one called [ValidateAntiForgeryHeader] which finds the token in the http headers, rather than just in the body.

@felickz
Copy link
Contributor

felickz commented Oct 11, 2017

The "SG0016 Controller method is vulnerable to CSRF" rule also conflicts with some newer patterns for auto validating CSRF tokens in .NET core .

Filters.Add(new AutoValidateAntiforgeryTokenAttribute());

Is there any pattern for detecting this attribute is globally applied and disable SG00016? Potentially here SG00016 could apply to the use of the ignore attribute.

AutoValidateAntiforgeryTokenAttribute can be applied as a global filter to trigger validation of antiforgery tokens by default for an application.

Also, we should call out the usage of IgnoreAntiforgeryTokenAttribute here.

Blog explaining the topic: https://andrewlock.net/automatically-validating-anti-forgery-tokens-in-asp-net-core-with-the-autovalidateantiforgerytokenattribute/

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

No branches or pull requests

2 participants