Open Closed

JWT - Deny Access for "alg": "none" #9994


User avatar
0
kkmy created

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)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    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 standard AddJwtBearer or AddAbpJwtBearer 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.

  • User Avatar
    0
    kkmy created

    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.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on October 14, 2025, 08:24