zichen0116 opened a new pull request, #77814: URL: https://github.com/apache/airflow/pull/77814
When `airflow.cfg` does not exist, Airflow writes a generated `[api_auth] jwt_secret` of `b64encode(os.urandom(16))` โ 24 characters. With `jwt_algorithm` unset, JWTs are signed with HS512, and PyJWT warns on every token use because RFC 7518 ยง3.2 asks for a key at least as long as the hash output (64 bytes for SHA-512). This generates 48 random bytes (64 base64 characters) at all three generation sites: - `airflow-core/src/airflow/configuration.py` โ the default config writer (`write_default_airflow_configuration_if_needed`) and the test config loader (`load_test_config`) - `airflow-core/src/airflow/api_fastapi/auth/tokens.py` โ the empty-config signing fallback in `get_signing_key` PyJWT measures the key string as given (it UTF-8 encodes it, it does not base64-decode), so 64 characters clears the check while keeping 384 bits of entropy. Verified with PyJWT 2.15.1: a 24-character key raises `InsecureKeyLengthWarning` on HS512 signing; a 64-character key signs with no warning. Tests: one length assertion per site (the existing `write_default_config_contains_generated_secrets` assertion is strengthened from non-empty to `>= 64`, plus new cases for `load_test_config` and `get_signing_key`). All three new assertions fail before the fix. Closes #77805 -- 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]
