Package: release.debian.org
Severity: normal
Tags: trixie
X-Debbugs-Cc: [email protected]
Control: affects -1 + src:python-engineio
User: [email protected]
Usertags: pu

[ Reason ]

Fixing CVE-2026-48802

https://security-tracker.debian.org/tracker/CVE-2026-48802
- The initial background thread (or async task( for heartbeat management is only launched if a client passes authentication in the connect handler. - The server now ensures that there is only one background heatbeat thread (or async task) per client at a given point in time. Out of sequence PONG packets are now discarded when an active heartbeat thread is already running.

Fixing CVE-2026-48809

https://security-tracker.debian.org/tracker/CVE-2026-48809
- ASGI severs now only load the body of incoming requests into memory after the client is confirmed to be known and authenticated, and the payload size is below the maximum allowed size. Requests that do not comply with these requirements are discarded. - Aiohttp servers configure the maximum payload size in the underlying WebSocket layer from Aiohttp, so that large messages are discarded by Aiohttp before they are delivered to python-engineio.

[ Impact ]

CVE-2026-48802:

An attacker can cause the creation of unnecessary background threads in the python-engineio server by exploiting the heartbeat mechanism, which launches a thread when a new connection is received, and when the client sends a PONG packet.

Note: this issue primarily affects synchronous servers. Asynchronous servers allocate background tasks instead of physical threads, which are lightweight and less likely to cause denial of service. However, the fix that was implemented was also applied to the asynchronous case.

CVE-2026-48809:

There are two specific configurations of the python-engineio server in which the size of incoming messages is not checked before the messages are loaded into memory. An attacker can take advantage of these to cause unnecessary memory allocations in the python-engineio server. The two cases are:

- POST requests, when using ASGI with the long polling transport
- WebSocket messages, when using Aiohttp with the WebSocket transport

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Other info ]

Branch on salsa:
https://salsa.debian.org/debian/python-engineio/-/tree/debian/trixie

This is my first p-u, so please let me know If I will need to fix anything here.

Best regards,

--
Paulo Henrique de Lima Santana (phls)
Belo Horizonte - Brasil
Debian Developer
Site: http://phls.com.br
GPG ID: 0443C450

diff -Nru python-engineio-4.11.2/debian/changelog 
python-engineio-4.11.2/debian/changelog
--- python-engineio-4.11.2/debian/changelog     2025-03-10 15:23:34.000000000 
-0300
+++ python-engineio-4.11.2/debian/changelog     2026-11-21 17:37:07.000000000 
-0300
@@ -1,3 +1,13 @@
+python-engineio (4.11.2-1+deb13u1) trixie; urgency=medium
+
+  * gbp.conf debian-branch to debian/trixie.
+  * patches/0001-Fix-breakage-introduced-by-CVE-2026-48802.patch
+      - Added upstream patch.
+  * patches/0002-Fix-breakage-introduced-by-CVE-2026-48809.patch
+      - Added upstream patch.
+
+ -- Paulo Henrique de Lima Santana (phls) <[email protected]>  Sat, 21 Nov 2026 
17:37:07 -0300
+
 python-engineio (4.11.2-1) unstable; urgency=medium
 
   * New upstream version 4.11.2.
diff -Nru python-engineio-4.11.2/debian/copyright 
python-engineio-4.11.2/debian/copyright
--- python-engineio-4.11.2/debian/copyright     2025-03-10 15:23:34.000000000 
-0300
+++ python-engineio-4.11.2/debian/copyright     2026-11-21 17:37:07.000000000 
-0300
@@ -83,7 +83,7 @@
 
 Files: debian/*
 Copyright: 2024, Alexandre Detiste <[email protected]>
-           2017-2025, Paulo Henrique de Lima Santana (phls) <[email protected]>
+           2017-2026, Paulo Henrique de Lima Santana (phls) <[email protected]>
 License: MIT
 
 License: MIT
diff -Nru python-engineio-4.11.2/debian/gbp.conf 
python-engineio-4.11.2/debian/gbp.conf
--- python-engineio-4.11.2/debian/gbp.conf      2025-03-10 15:23:05.000000000 
-0300
+++ python-engineio-4.11.2/debian/gbp.conf      2026-11-21 17:37:07.000000000 
-0300
@@ -1,4 +1,4 @@
 [DEFAULT]
-debian-branch = debian/master
+debian-branch = debian/trixie
 upstream-branch = upstream
 pristine-tar = True
diff -Nru 
python-engineio-4.11.2/debian/patches/0001-Fix-breakage-introduced-by-CVE-2026-48802.patch
 
python-engineio-4.11.2/debian/patches/0001-Fix-breakage-introduced-by-CVE-2026-48802.patch
--- 
python-engineio-4.11.2/debian/patches/0001-Fix-breakage-introduced-by-CVE-2026-48802.patch
  1969-12-31 21:00:00.000000000 -0300
+++ 
python-engineio-4.11.2/debian/patches/0001-Fix-breakage-introduced-by-CVE-2026-48802.patch
  2026-11-21 17:37:07.000000000 -0300
@@ -0,0 +1,244 @@
+Description: Fix breakage introduced by CVE-2026-48802
+Author: Paulo Henrique de Lima Santana (phls) <[email protected]>
+Last-Update: 2026-11-21
+Index: python-engineio-4.11.2/src/engineio/async_drivers/aiohttp.py
+===================================================================
+--- python-engineio-4.11.2.orig/src/engineio/async_drivers/aiohttp.py
++++ python-engineio-4.11.2/src/engineio/async_drivers/aiohttp.py
+@@ -86,11 +86,13 @@ class WebSocket:  # pragma: no cover
+     """
+     def __init__(self, handler, server):
+         self.handler = handler
++        self.server = server
+         self._sock = None
+ 
+     async def __call__(self, environ):
+         request = environ['aiohttp.request']
+-        self._sock = WebSocketResponse(max_msg_size=0)
++        self._sock = WebSocketResponse(
++            max_msg_size=self.server.max_http_buffer_size)
+         await self._sock.prepare(request)
+ 
+         self.environ = environ
+Index: python-engineio-4.11.2/src/engineio/async_drivers/asgi.py
+===================================================================
+--- python-engineio-4.11.2.orig/src/engineio/async_drivers/asgi.py
++++ python-engineio-4.11.2/src/engineio/async_drivers/asgi.py
+@@ -136,10 +136,18 @@ class ASGIApp:
+ 
+ async def translate_request(scope, receive, send):
+     class AwaitablePayload:  # pragma: no cover
+-        def __init__(self, payload):
+-            self.payload = payload or b''
++        def __init__(self, event):
++            self.event = event
++            self.payload = None
+ 
+         async def read(self, length=None):
++            if self.payload is None and event['type'] == 'http.request':
++                # read payload from http request
++                self.payload = self.event.get('body') or b''
++                while self.event.get('more_body'):
++                    self.event = await receive()
++                    if self.event['type'] == 'http.request':
++                        self.payload += self.event.get('body') or b''
+             if length is None:
+                 r = self.payload
+                 self.payload = b''
+@@ -149,16 +157,7 @@ async def translate_request(scope, recei
+             return r
+ 
+     event = await receive()
+-    payload = b''
+-    if event['type'] == 'http.request':
+-        payload += event.get('body') or b''
+-        while event.get('more_body'):
+-            event = await receive()
+-            if event['type'] == 'http.request':
+-                payload += event.get('body') or b''
+-    elif event['type'] == 'websocket.connect':
+-        pass
+-    else:
++    if event['type'] not in ['http.request', 'websocket.connect']:
+         return {}
+ 
+     raw_uri = scope['path']
+@@ -171,7 +170,7 @@ async def translate_request(scope, recei
+         else:
+             raw_uri += '?' + query_string
+     environ = {
+-        'wsgi.input': AwaitablePayload(payload),
++        'wsgi.input': AwaitablePayload(event),
+         'wsgi.errors': sys.stderr,
+         'wsgi.version': (1, 0),
+         'wsgi.async': True,
+Index: python-engineio-4.11.2/src/engineio/async_server.py
+===================================================================
+--- python-engineio-4.11.2.orig/src/engineio/async_server.py
++++ python-engineio-4.11.2/src/engineio/async_server.py
+@@ -460,7 +460,6 @@ class AsyncServer(base_server.BaseServer
+             'maxPayload': self.max_http_buffer_size,
+         })
+         await s.send(pkt)
+-        s.schedule_ping()
+ 
+         ret = await self._trigger_event('connect', sid, environ,
+                                         run_async=False)
+@@ -469,6 +468,8 @@ class AsyncServer(base_server.BaseServer
+             self.logger.warning('Application rejected connection')
+             return self._unauthorized(ret or None)
+ 
++        s.schedule_ping()
++
+         if transport == 'websocket':
+             ret = await s.handle_get_request(environ)
+             if s.closed and sid in self.sockets:
+Index: python-engineio-4.11.2/src/engineio/async_socket.py
+===================================================================
+--- python-engineio-4.11.2.orig/src/engineio/async_socket.py
++++ python-engineio-4.11.2/src/engineio/async_socket.py
+@@ -128,10 +128,12 @@ class AsyncSocket(base_socket.BaseSocket
+                 await self.queue.join()
+ 
+     def schedule_ping(self):
+-        self.server.start_background_task(self._send_ping)
++        # only schedule a new ping if the previous ping wait cycle completed
++        if self.last_ping:
++            self.last_ping = None
++            self.server.start_background_task(self._send_ping)
+ 
+     async def _send_ping(self):
+-        self.last_ping = None
+         await asyncio.sleep(self.server.ping_interval)
+         if not self.closing and not self.closed:
+             self.last_ping = time.time()
+Index: python-engineio-4.11.2/src/engineio/base_socket.py
+===================================================================
+--- python-engineio-4.11.2.orig/src/engineio/base_socket.py
++++ python-engineio-4.11.2/src/engineio/base_socket.py
+@@ -1,3 +1,6 @@
++import time
++
++
+ class BaseSocket:
+     upgrade_protocols = ['websocket']
+ 
+@@ -5,7 +8,7 @@ class BaseSocket:
+         self.server = server
+         self.sid = sid
+         self.queue = self.server.create_queue()
+-        self.last_ping = None
++        self.last_ping = time.time()
+         self.connected = False
+         self.upgrading = False
+         self.upgraded = False
+Index: python-engineio-4.11.2/src/engineio/server.py
+===================================================================
+--- python-engineio-4.11.2.orig/src/engineio/server.py
++++ python-engineio-4.11.2/src/engineio/server.py
+@@ -400,7 +400,6 @@ class Server(base_server.BaseServer):
+             'maxPayload': self.max_http_buffer_size,
+         })
+         s.send(pkt)
+-        s.schedule_ping()
+ 
+         # NOTE: some sections below are marked as "no cover" to workaround
+         # what seems to be a bug in the coverage package. All the lines below
+@@ -412,6 +411,9 @@ class Server(base_server.BaseServer):
+             self.logger.warning('Application rejected connection')
+             return self._unauthorized(ret or None)
+ 
++        s.schedule_ping()
++
++
+         if transport == 'websocket':  # pragma: no cover
+             ret = s.handle_get_request(environ, start_response)
+             if s.closed and sid in self.sockets:
+Index: python-engineio-4.11.2/src/engineio/socket.py
+===================================================================
+--- python-engineio-4.11.2.orig/src/engineio/socket.py
++++ python-engineio-4.11.2/src/engineio/socket.py
+@@ -130,10 +130,12 @@ class Socket(base_socket.BaseSocket):
+                 self.queue.join()
+ 
+     def schedule_ping(self):
+-        self.server.start_background_task(self._send_ping)
++        # only schedule a new ping if the previous ping wait cycle completed
++        if self.last_ping:
++            self.last_ping = None
++            self.server.start_background_task(self._send_ping)
+ 
+     def _send_ping(self):
+-        self.last_ping = None
+         self.server.sleep(self.server.ping_interval)
+         if not self.closing and not self.closed:
+             self.last_ping = time.time()
+Index: python-engineio-4.11.2/tests/async/test_socket.py
+===================================================================
+--- python-engineio-4.11.2.orig/tests/async/test_socket.py
++++ python-engineio-4.11.2/tests/async/test_socket.py
+@@ -95,14 +95,30 @@ class TestSocket:
+         s = async_socket.AsyncSocket(mock_server, 'sid')
+         s.send = mock.AsyncMock()
+ 
+-        async def schedule_ping():
++        async def schedule_ping_and_sleep():
+             s.schedule_ping()
+             await asyncio.sleep(0.05)
+ 
+-        await schedule_ping()
++        await schedule_ping_and_sleep()
+         assert s.last_ping is not None
+         assert s.send.await_args_list[0][0][0].encode() == '2'
+ 
++    async def test_schedule_ping_twice(self):
++        mock_server = self._get_mock_server()
++        mock_server.ping_interval = 0.01
++        s = async_socket.AsyncSocket(mock_server, 'sid')
++        s.send = mock.AsyncMock()
++
++        async def schedule_ping_and_sleep():
++            s.schedule_ping()
++            await asyncio.sleep(0.05)
++
++        s.schedule_ping()
++        assert s.last_ping is None
++        await schedule_ping_and_sleep()
++        assert s.last_ping is not None
++        assert s.send.await_count == 1
++
+     async def test_schedule_ping_closed_socket(self):
+         mock_server = self._get_mock_server()
+         mock_server.ping_interval = 0.01
+Index: python-engineio-4.11.2/tests/common/test_socket.py
+===================================================================
+--- python-engineio-4.11.2.orig/tests/common/test_socket.py
++++ python-engineio-4.11.2/tests/common/test_socket.py
+@@ -21,6 +21,7 @@ class TestSocket:
+         mock_server.ping_interval_grace_period = 0.001
+         mock_server.async_handlers = True
+         mock_server.max_http_buffer_size = 128
++        mock_server.sleep = time.sleep
+ 
+         try:
+             import queue
+@@ -104,6 +105,19 @@ class TestSocket:
+         assert s.last_ping is not None
+         assert s.send.call_args_list[0][0][0].encode() == '2'
+ 
++    def test_schedule_ping_twice(self):
++        mock_server = self._get_mock_server()
++        mock_server.ping_interval = 0.1
++        s = socket.Socket(mock_server, 'sid')
++        s.send = mock.MagicMock()
++        s.schedule_ping()
++        assert s.last_ping is None
++        time.sleep(0.01)
++        s.schedule_ping()
++        time.sleep(0.1)
++        assert s.last_ping is not None
++        assert s.send.call_count == 1
++
+     def test_schedule_ping_closed_socket(self):
+         mock_server = self._get_mock_server()
+         mock_server.ping_interval = 0.01
diff -Nru 
python-engineio-4.11.2/debian/patches/0002-Fix-breakage-introduced-by-CVE-2026-48809.patch
 
python-engineio-4.11.2/debian/patches/0002-Fix-breakage-introduced-by-CVE-2026-48809.patch
--- 
python-engineio-4.11.2/debian/patches/0002-Fix-breakage-introduced-by-CVE-2026-48809.patch
  1969-12-31 21:00:00.000000000 -0300
+++ 
python-engineio-4.11.2/debian/patches/0002-Fix-breakage-introduced-by-CVE-2026-48809.patch
  2026-11-21 17:37:07.000000000 -0300
@@ -0,0 +1,85 @@
+Description: Fix breakage introduced by CVE-2026-48809
+Author: Paulo Henrique de Lima Santana (phls) <[email protected]>
+Last-Update: 2026-11-21
+Index: python-engineio-4.11.2/src/engineio/async_drivers/asgi.py
+===================================================================
+--- python-engineio-4.11.2.orig/src/engineio/async_drivers/asgi.py
++++ python-engineio-4.11.2/src/engineio/async_drivers/asgi.py
+@@ -147,7 +147,8 @@ async def translate_request(scope, recei
+                 while self.event.get('more_body'):
+                     self.event = await receive()
+                     if self.event['type'] == 'http.request':
+-                        self.payload += self.event.get('body') or b''
++                        if length is None or len(self.payload) < length:
++                            self.payload += self.event.get('body') or b''
+             if length is None:
+                 r = self.payload
+                 self.payload = b''
+Index: python-engineio-4.11.2/tests/async/test_asgi.py
+===================================================================
+--- python-engineio-4.11.2.orig/tests/async/test_asgi.py
++++ python-engineio-4.11.2/tests/async/test_asgi.py
+@@ -441,6 +441,27 @@ class TestAsgi:
+         body = await environ['wsgi.input'].read()
+         assert body == b'hello world'
+ 
++    async def test_translate_request_read_zero(self):
++        receive = mock.AsyncMock(
++            return_value={'type': 'http.request', 'body': b'hello world'}
++        )
++        send = mock.AsyncMock()
++        environ = await async_asgi.translate_request(
++            {
++                'type': 'http',
++                'method': 'PUT',
++                'headers': [
++                    (b'content-type', b'application/json'),
++                    (b'content-length', b'123'),
++                ],
++                'path': '/foo/bar',
++            },
++            receive,
++            send,
++        )
++        body = await environ['wsgi.input'].read(0)
++        assert body == b''
++
+     async def test_translate_websocket_request(self):
+         receive = mock.AsyncMock(return_value={'type': 'websocket.connect'})
+         send = mock.AsyncMock()
+Index: python-engineio-4.11.2/tests/async/test_socket.py
+===================================================================
+--- python-engineio-4.11.2.orig/tests/async/test_socket.py
++++ python-engineio-4.11.2/tests/async/test_socket.py
+@@ -209,6 +209,8 @@ class TestSocket:
+         }
+         await s.handle_post_request(environ)
+         assert s.receive.await_count == 2
++        assert s.receive.call_args_list[0][0][0].data == 'hello'
++        assert s.receive.call_args_list[1][0][0].data == 'bye'
+ 
+     async def test_polling_write_too_large(self):
+         mock_server = self._get_mock_server()
+@@ -226,6 +228,22 @@ class TestSocket:
+         }
+         with pytest.raises(exceptions.ContentTooLongError):
+             await s.handle_post_request(environ)
++    async def test_polling_write_without_content_length(self):
++        mock_server = self._get_mock_server()
++        pkt1 = packet.Packet(packet.MESSAGE, data='hello')
++        pkt2 = packet.Packet(packet.MESSAGE, data='bye')
++        p = payload.Payload(packets=[pkt1, pkt2]).encode().encode('utf-8')
++        s = async_socket.AsyncSocket(mock_server, 'foo')
++        s.receive = mock.AsyncMock()
++        environ = {
++            'REQUEST_METHOD': 'POST',
++            'QUERY_STRING': 'sid=foo',
++            'wsgi.input': self._get_read_mock_coro(p),
++        }
++        await s.handle_post_request(environ)
++        assert s.receive.await_count == 2
++        assert environ['wsgi.input'].read.call_count == 1
++        assert environ['wsgi.input'].read.call_args[0] == (0,)
+ 
+     async def test_upgrade_handshake(self):
+         mock_server = self._get_mock_server()
diff -Nru python-engineio-4.11.2/debian/patches/series 
python-engineio-4.11.2/debian/patches/series
--- python-engineio-4.11.2/debian/patches/series        1969-12-31 
21:00:00.000000000 -0300
+++ python-engineio-4.11.2/debian/patches/series        2026-11-21 
17:37:07.000000000 -0300
@@ -0,0 +1,2 @@
+0001-Fix-breakage-introduced-by-CVE-2026-48802.patch
+0002-Fix-breakage-introduced-by-CVE-2026-48809.patch

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to