Skip to content

Commit 8fead34

Browse files
committed
fix(facebook): Use json_script to encode settings
1 parent 11fa4e8 commit 8fead34

File tree

9 files changed

+19
-13
lines changed

9 files changed

+19
-13
lines changed

ChangeLog.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
0.63.6 (2024-07-12)
2+
*******************
3+
4+
Security notice
5+
---------------
6+
7+
- When the Facebook provider was configured to use the ``js_sdk`` method the
8+
login page could become vulnerable to an XSS attack.
9+
10+
111
0.63.5 (2024-07-11)
212
*******************
313

allauth/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
"""
1010

11-
VERSION = (0, 63, 5, "final", 0)
11+
VERSION = (0, 63, 6, "final", 0)
1212

1313
__title__ = "django-allauth"
1414
__version_info__ = VERSION

allauth/socialaccount/providers/facebook/provider.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import requests
32
import string
43
from urllib.parse import quote
@@ -9,7 +8,6 @@
98
from django.urls import reverse
109
from django.utils.crypto import get_random_string
1110
from django.utils.html import escapejs
12-
from django.utils.safestring import mark_safe
1311

1412
from allauth.account.models import EmailAddress
1513
from allauth.socialaccount.adapter import get_adapter
@@ -176,7 +174,7 @@ def abs_uri(name):
176174
"errorUrl": abs_uri("socialaccount_login_error"),
177175
"csrfToken": get_token(request),
178176
}
179-
ctx = {"fb_data": mark_safe(json.dumps(fb_data))}
177+
ctx = {"fb_data": fb_data}
180178
return render_to_string("facebook/fbconnect.html", ctx, request=request)
181179

182180
def get_nonce(self, request, or_create=False, pop=False):

allauth/socialaccount/providers/facebook/static/facebook/js/fbconnect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
var allauth = window.allauth = window.allauth || {}
32-
var fbSettings = JSON.parse(document.getElementById('allauth-facebook-settings').innerHTML)
32+
const fbSettings = JSON.parse(document.getElementById('allauth-facebook-settings').textContent)
3333
var fbInitialized = false
3434

3535
allauth.facebook = {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{% load static %}
22
<div id="fb-root"></div>
3-
<script id="allauth-facebook-settings" type="application/json">{{ fb_data }}</script>
3+
{{ fb_data|json_script:"allauth-facebook-settings" }}
44
<script type="text/javascript" src="{% static 'facebook/js/fbconnect.js' %}"></script>

allauth/socialaccount/providers/facebook/tests.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import json
2-
31
from django.contrib.auth import get_user_model
42
from django.test.client import RequestFactory
53
from django.test.utils import override_settings
@@ -130,7 +128,7 @@ def test_login_by_token(self):
130128
)
131129
def test_login_by_token_reauthenticate(self):
132130
resp = self.client.get(reverse("account_login"))
133-
nonce = json.loads(resp.context["fb_data"])["loginOptions"]["auth_nonce"]
131+
nonce = resp.context["fb_data"]["loginOptions"]["auth_nonce"]
134132
with mocked_response(
135133
{"access_token": "app_token"},
136134
{

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
# built documents.
5454
#
5555
# The short X.Y version.
56-
version = "0.63.5"
56+
version = "0.63.6"
5757
# The full version, including alpha/beta/rc tags.
58-
release = "0.63.5"
58+
release = "0.63.6"
5959

6060
# The language for content autogenerated by Sphinx. Refer to documentation
6161
# for a list of supported languages.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
django-allauth[mfa,socialaccount]>=0.63.5
1+
django-allauth[mfa,socialaccount]>=0.63.6
22
qrcode >= 7.0.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
django-allauth[mfa,saml,socialaccount]>=0.63.5
1+
django-allauth[mfa,saml,socialaccount]>=0.63.6

0 commit comments

Comments
 (0)