Skip to content

Commit a6b5d30

Browse files
author
Matt Wright
committed
Use safe_str_cmp when evaluating tokens. Fixes pallets-eco#252
1 parent 0a48997 commit a6b5d30

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

flask_security/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from passlib.context import CryptContext
1919
from werkzeug.datastructures import ImmutableList
2020
from werkzeug.local import LocalProxy
21+
from werkzeug.security import safe_str_cmp
2122

2223
from .utils import config_value as cv, get_config, md5, url_for_security, string_types
2324
from .views import create_blueprint
@@ -193,7 +194,7 @@ def _token_loader(token):
193194
try:
194195
data = _security.remember_token_serializer.loads(token)
195196
user = _security.datastore.find_user(id=data[0])
196-
if user and md5(user.password) == data[1]:
197+
if user and safe_str_cmp(md5(user.password), data[1]):
197198
return user
198199
except:
199200
pass

0 commit comments

Comments
 (0)