-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"two-factor-authenticate" remains accessible in the middle of a login flow #70
Comments
Yes, that does seem pretty weird. I could think of a situation like the following:
On a "shared" computer, someone else could re-open the page and enter the token without knowing the original password. I think it is an edge-case, but is unexpected behavior. Expiring the session quickly is a probably a reasonable solution. |
So I've spent two days hunting down a bug related to this one. The behavior was:
I managed to track it down to
That I'm not sure what the problem with "they're half-logged-in" is that requires no other HTTP activity at all until the I get the "On a "shared" computer, someone else could re-open the page and enter the token without knowing the original password" case from the prior comment, but that trick works one and only if the bad guy has control of the TOTP device. In my case it's a non-issue, because my session cookie expiration is set to 0 so the cookie is dead once the tab is closed. I guess someone can restore the cookie by reopening the tab from history? So I'm not sure how to fix this (I can replace |
Looking through |
Since the login forms aren't provided by django-allauth-2fa that could be hard. It could always be documented, of course. Is there a reduced set of steps to reproduce this, by the way? |
I think the minimum set of steps to reproduce would be something like:
|
The Here's the part of my from django.conf import settings
from django.urls import include, path, reverse
from django.conf.urls.static import static
from django.contrib import admin, sitemaps
from django.contrib.sitemaps.views import sitemap
from django.views.generic import TemplateView, RedirectView
# ...
def favicon_path(name, pattern=None):
target = name if pattern is None else pattern
url = f'{settings.STATIC_URL}images/favicons/{target}'
return path(name, RedirectView.as_view(url=url))
# ...
urlpatterns = [
# ...
path("accounts/", include("allauth_2fa.urls")),
path("accounts/", include("allauth.urls")),
# ...
# Favicons
favicon_path('android-chrome-<dims>.png', 'android-chrome-%(dims)s.png'),
favicon_path('apple-touch-icon<dims>.png', 'apple-touch-icon%(dims)s.png'),
favicon_path('apple-touch-icon.png', 'apple-touch-icon.png'),
favicon_path('browserconfig.xml'),
favicon_path('favicon-16x16.png'),
favicon_path('favicon-32x32.png'),
favicon_path('favicon.ico'),
favicon_path('mstile<dims>.png', 'mstile%(dims)s.png'),
favicon_path('safari-pinned-tab.svg'),
favicon_path('site.webmanifest'),
] + static(
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
) |
As noted last November, it's
There needs to be a check here for "harmless" paths that shouldn't reset the login flow. The question is how to get these URLs to this test:
|
i have the same BUG, but with
We must find a solution to ignore specific views from the check. The middleware is loaded when the TwoFactorAuthenticate view is loaded, no normally that others view are loaded in the process. |
If a developer would tell me which of the four options I gave were acceptable, I could provide a pull request. But I'm not going to go to that effort just to have it ignored. |
for me the more easy is to have like an exception list. |
most fast solution with exception list def process_request(self, request):
match = resolve(request.path)
except_list = getattr(settings, 'EXCEPT_VIEWS_FROM_CHECK', ())
except_list += ('two-factor-authenticate',)
if not match.url_name or not match.url_name.startswith(except_list):
try:
del request.session['allauth_2fa_user_id']
except KeyError:
log.info(match.url_name) |
@SoulRaven Use the Also, I'm not sure "must" is the word you wanted, and can't tell what you really meant. |
fix |
Hi,
Regarding the moment after clicking "Sign In" and before completing the 2FA form:
As addressed by issue #8, I know that going to any page other than "two-factor-authenticate" takes the user out of this intermediate state (by removing the "allauth_2fa_user_id" session key).
However, as long as I stay within the "two-factor-authenticate" page, it will remain in that state until the session expires. So, I can, for example, close the page, then reopen it several days later and the 2FA form will still be there waiting for the same user to type the token.
It seems like a behavior that could be potentially exploited. Should there be a mechanism against that? Maybe the session expiry time could be set to a small value, like 5 minutes, when reaching that state, then reset to a longer value only after the flow is completed?
Thank you in advance.
The text was updated successfully, but these errors were encountered: