Repository navigation
Apply the FAB login rate limit to the API login endpoints - #77931
Open
ChickenBenny wants to merge 3 commits into
Open
ChickenBenny wants to merge 3 commits into
ChickenBenny wants to merge 3 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[fab] auth_rate_limit(5 requests per 40 seconds by default) is applied only to the Flask login form.The other endpoints that take a username and password have no limit:
POST /auth/token,POST /auth/token/cliand the Flask-AppBuilder security API login (POST /auth/api/v1/security/login).The FAB docs and the config descriptions say that authentication requests are rate limited, so a password
guess sent to these endpoints is not slowed down although the docs say it is.
The Airflow security team assessed this as hardening, not a vulnerability: rate limiting is the Deployment
Manager's job under the Security Model, and the FAB limiter is a convenience. They suggested fixing it in a
public PR.
check_api_login_rate_limitcounts each attempt directly in the Flask-Limiter storage, with the same[fab] auth_rate_limit. Both token endpoints share one counter per client address and return 429 when itis reached. They use the configured storage and
RATELIMIT_SWALLOW_ERRORS, so with an unreachable storagethey fail, or let the login through when errors are swallowed, as the login form does. The in-memory
fallback storage,
RATELIMIT_KEY_FUNCandRATELIMIT_KEY_PREFIXonly work inside Flask-Limiter's requesthandling, so they do not apply to the token endpoints, and the docs say so.
loginendpoint is limited.refreshtakes a refresh token, not a password, andlimiting it would change what clients that refresh often get today.
_rate_limit_loginshelper in the security manager, and the token routes only callcheck_api_login_rate_limit.replaces the old gunicorn worker example with
[api] workers, lists whichRATELIMIT_*settings apply tothe token endpoints, notes that the API server needs
--proxy-headersbehind a proxy, and links theSecurity Model.
limitswas already installed throughflask-limiter. It is now declared, since thesecurity manager imports it.
The three counters (login form, token endpoints, security API login) stay separate. Sharing one with the
login form would mean building Flask-Limiter's internal keys (prefix, key and scope) by hand for the token
endpoints, which would break when Flask-Limiter changes them.
Tests: with the default limit, the two token endpoints return 401 five times and then 429, alternating
between them, and so does the security API login, while its refresh is not limited. With
AUTH_RATE_LIMITEDoff, or the limiter disabled, the token endpoints are not limited. A storage error fails the token request, oris logged and ignored with
RATELIMIT_SWALLOW_ERRORS.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5.5) following the guidelines