Hello,
Our project underwent a penetration test. In the test result, it is suggested that our project needs to stop responding for tokens without an encryption algorithm. Which means that, it should not allow access for the tokens that have "alg": "none" in their headers.
How can we implement this in our project? Will it break anything related to ABP framework, authentication, authorization etc.?
Thanks!
2 Answer(s)
-
0
To deny access for JWT tokens with
"alg": "none"
in their headers, you should rely on the default behavior of the JWT Bearer authentication middleware used by ABP (which is based on ASP.NET Core and Microsoft.IdentityModel). By default, the middleware will reject tokens with"alg": "none"
and will not treat them as valid, as this is a well-known security risk.No additional configuration is required in ABP or ASP.NET Core to block
"alg": "none"
tokens, unless you have custom code that overrides the default token validation behavior. As long as you use the standardAddJwtBearer
orAddAbpJwtBearer
setup, tokens with"alg": "none"
will be denied.Example configuration (default, secure):
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.Authority = "https://your-auth-server"; options.Audience = "YourAudience"; // No need to add custom logic for "alg": "none" });
If you have not customized the token validation pipeline to allow
"alg": "none"
, your application is already protected. Allowing"alg": "none"
would require explicit, insecure customization, which is not present in ABP's default templates.This will not break any ABP authentication or authorization features, as rejecting
"alg": "none"
is the secure and expected behavior.Sources:
- https://abp.io/community/articles/4u3wrbs5
- https://learn.microsoft.com/en-us/aspnet/core/security/authentication/configure-jwt-bearer-authentication
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0
We do not have the code block that is given by the AI-Bot. Moreover, I have created a new project and it does not have this block neither.