summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-flask-cors/CVE-2024-6221.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-flask-cors/CVE-2024-6221.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-flask-cors/CVE-2024-6221.patch110
1 files changed, 110 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-flask-cors/CVE-2024-6221.patch b/meta-python/recipes-devtools/python/python3-flask-cors/CVE-2024-6221.patch
new file mode 100644
index 000000000..9049b2ffe
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-flask-cors/CVE-2024-6221.patch
@@ -0,0 +1,110 @@
1From 7ae310c56ac30e0b94fb42129aa377bf633256ec Mon Sep 17 00:00:00 2001
2From: Adriano Sela Aviles <adriano.selaviles@gmail.com>
3Date: Fri, 30 Aug 2024 12:14:31 -0400
4Subject: [PATCH] Backwards Compatible Fix for CVE-2024-6221 (#363)
5
6CVE: CVE-2024-6221
7
8Upstream-Status: Backport [https://github.com/corydolphin/flask-cors/commit/7ae310c56ac30e0b94fb42129aa377bf633256ec]
9
10Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com>
11---
12 docs/configuration.rst | 14 ++++++++++++++
13 flask_cors/core.py | 8 +++++---
14 flask_cors/extension.py | 16 ++++++++++++++++
15 3 files changed, 35 insertions(+), 3 deletions(-)
16
17diff --git a/docs/configuration.rst b/docs/configuration.rst
18index 91282d3..c750cf4 100644
19--- a/docs/configuration.rst
20+++ b/docs/configuration.rst
21@@ -23,6 +23,19 @@ CORS_ALLOW_HEADERS (:py:class:`~typing.List` or :py:class:`str`)
22 Headers to accept from the client.
23 Headers in the :http:header:`Access-Control-Request-Headers` request header (usually part of the preflight OPTIONS request) matching headers in this list will be included in the :http:header:`Access-Control-Allow-Headers` response header.
24
25+CORS_ALLOW_PRIVATE_NETWORK (:py:class:`bool`)
26+ If True, the response header :http:header:`Access-Control-Allow-Private-Network`
27+ will be set with the value 'true' whenever the request header
28+ :http:header:`Access-Control-Request-Private-Network` has a value 'true'.
29+
30+ If False, the reponse header :http:header:`Access-Control-Allow-Private-Network`
31+ will be set with the value 'false' whenever the request header
32+ :http:header:`Access-Control-Request-Private-Network` has a value of 'true'.
33+
34+ If the request header :http:header:`Access-Control-Request-Private-Network` is
35+ not present or has a value other than 'true', the response header
36+ :http:header:`Access-Control-Allow-Private-Network` will not be set.
37+
38 CORS_ALWAYS_SEND (:py:class:`bool`)
39 Usually, if a request doesn't include an :http:header:`Origin` header, the client did not request CORS.
40 This means we can ignore this request.
41@@ -83,6 +96,7 @@ Default values
42 ~~~~~~~~~~~~~~
43
44 * CORS_ALLOW_HEADERS: "*"
45+* CORS_ALLOW_PRIVATE_NETWORK: True
46 * CORS_ALWAYS_SEND: True
47 * CORS_AUTOMATIC_OPTIONS: True
48 * CORS_EXPOSE_HEADERS: None
49diff --git a/flask_cors/core.py b/flask_cors/core.py
50index 5358036..bd011f4 100644
51--- a/flask_cors/core.py
52+++ b/flask_cors/core.py
53@@ -36,7 +36,7 @@ CONFIG_OPTIONS = ['CORS_ORIGINS', 'CORS_METHODS', 'CORS_ALLOW_HEADERS',
54 'CORS_MAX_AGE', 'CORS_SEND_WILDCARD',
55 'CORS_AUTOMATIC_OPTIONS', 'CORS_VARY_HEADER',
56 'CORS_RESOURCES', 'CORS_INTERCEPT_EXCEPTIONS',
57- 'CORS_ALWAYS_SEND']
58+ 'CORS_ALWAYS_SEND', 'CORS_ALLOW_PRIVATE_NETWORK']
59 # Attribute added to request object by decorator to indicate that CORS
60 # was evaluated, in case the decorator and extension are both applied
61 # to a view.
62@@ -56,7 +56,8 @@ DEFAULT_OPTIONS = dict(origins='*',
63 vary_header=True,
64 resources=r'/*',
65 intercept_exceptions=True,
66- always_send=True)
67+ always_send=True,
68+ allow_private_network=True)
69
70
71 def parse_resources(resources):
72@@ -186,7 +187,8 @@ def get_cors_headers(options, request_headers, request_method):
73
74 if ACL_REQUEST_HEADER_PRIVATE_NETWORK in request_headers \
75 and request_headers.get(ACL_REQUEST_HEADER_PRIVATE_NETWORK) == 'true':
76- headers[ACL_RESPONSE_PRIVATE_NETWORK] = 'true'
77+ allow_private_network = 'true' if options.get('allow_private_network') else 'false'
78+ headers[ACL_RESPONSE_PRIVATE_NETWORK] = allow_private_network
79
80 # This is a preflight request
81 # http://www.w3.org/TR/cors/#resource-preflight-requests
82diff --git a/flask_cors/extension.py b/flask_cors/extension.py
83index c00cbff..694953f 100644
84--- a/flask_cors/extension.py
85+++ b/flask_cors/extension.py
86@@ -136,6 +136,22 @@ class CORS(object):
87
88 Default : True
89 :type vary_header: bool
90+
91+ :param allow_private_network:
92+ If True, the response header `Access-Control-Allow-Private-Network`
93+ will be set with the value 'true' whenever the request header
94+ `Access-Control-Request-Private-Network` has a value 'true'.
95+
96+ If False, the reponse header `Access-Control-Allow-Private-Network`
97+ will be set with the value 'false' whenever the request header
98+ `Access-Control-Request-Private-Network` has a value of 'true'.
99+
100+ If the request header `Access-Control-Request-Private-Network` is
101+ not present or has a value other than 'true', the response header
102+ `Access-Control-Allow-Private-Network` will not be set.
103+
104+ Default : True
105+ :type allow_private_network: bool
106 """
107
108 def __init__(self, app=None, **kwargs):
109--
1102.40.0