henry3260 commented on code in PR #63115:
URL: https://github.com/apache/airflow/pull/63115#discussion_r2915615125


##########
airflow-core/src/airflow/api_fastapi/auth/tokens.py:
##########
@@ -93,7 +93,7 @@ def _guess_best_algorithm(key: AllowedPrivateKeys):
     from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey
 
     if isinstance(key, RSAPrivateKey):
-        return "RS512"
+        return "RS256"

Review Comment:
   > Why decreasing strength here?
   
   The root cause is that `key_to_jwk_dict` produces JWK entries without an alg 
field. When PyJWT's PyJWK encounters an RSA key without alg field, it always 
fallback to `RS256` as `algorithm_name`.
   Before this change, `_guess_best_algorithm` return `RS512` so the generator 
signed tokens with `alg: RS512 `while the validator expected `RS256`. When I 
write the unit test for this PR, causing `InvalidAlgorithmError` on every RSA 
token in GUESS + JWKS mode.
   IMO, This is not a deliberate security downgrade — it's a bug fix.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to