The vulnerability lies in the failure of django-allauth to consistently check the is_active status of a user account during different stages of the OAuth/OIDC token lifecycle. The analysis of the patches reveals three key areas where this check was missing:
- Device Authorization Grant: The
poll_device_code function did not verify the user's status before issuing tokens, allowing a deactivated user to complete the flow.
- Access Token Validation: The
RequestValidator.validate_bearer_token method failed to check if the user owning the token was active, permitting access to resources with a token belonging to a deactivated user.
- Refresh Token Validation: The
RequestValidator.validate_refresh_token method allowed a deactivated user to obtain new access tokens using a refresh token.
The root cause is an insufficient session invalidation mechanism. Deactivating a user in the system did not automatically invalidate the authentication tokens (access and refresh) that had been previously issued to them. The provided patches fix this by adding explicit user.is_active checks at each of these critical validation points, ensuring that tokens belonging to inactive users are rejected.