Hardcoded JWT signing key (ARCH338)
هذا المحتوى غير متوفر بلغتك بعد.
Key dotnet.security.hardcoded-jwt-signing-key · Severity error · Category security · CWE CWE-321
Embedding a JWT signing key in source code lets anyone with repo access mint valid tokens. This results in a complete bypass of the authentication mechanism.
Incorrect
Section titled “Incorrect”var key = new SymmetricSecurityKey( Encoding.UTF8.GetBytes("super-secret-signing-key-123"));Correct
Section titled “Correct”var key = new SymmetricSecurityKey( Encoding.UTF8.GetBytes(configuration["Jwt:SigningKey"]!));// Value comes from environment variable / secret storeRemove signing keys from source; load them from configuration, environment variables, or a secret store, and rotate them regularly.