توضیح (فارسی)
httpx2 با افزودن هر frame continuation به یک bytes buffer پیامهای WebSocket شکستهشده را بازسازی میکند و در هر frame کل پیام جمعشده را کپی میکند. یک WebSocket server یا یک مهاجم on-path روی یک اتصال unencrypted ws:// میتواند پیامها را به frameهای continuation بسیار کوچک تقسیم کند تا بازسازی زمان برابر با تعداد frameها در درجه دو بگیرد. بازسازی در clientهای synchronous GIL را نگه میدارد و event loop را در clientهای asynchronous مسدود میکند. برنامههایی که با client.websocket() یا httpx2.websocket() به یک endpoint غیرقابل اعتماد WebSocket session باز میکنند و از httpx2 در نسخههای 2.6.0 تا (but excluding) 2.18.0 استفاده میکنند. از 2.10.0 محدودیت default max_message_size_bytes برابر با 64 KiB کار برای هر پیام را محدود میکند بنابراین بار پایدار نیاز به پیامهای زیاد دارد و نسخههای 2.6.0 تا 2.9.1 چنین محدودیتی ندارند. این مشکل در 2.18.0 اصلاح میشود که fragments را در یک list جمع میکند و زمانی که frame نهایی میآید یک بار join میکند. تا آن زمان max_message_size_bytes را کوچک نگه دارید و فقط به endpointهای trusted wss:// متصل شوید.
Original description (English)
httpx2 reassembled fragmented WebSocket messages by appending each continuation frame to a bytes buffer, copying the whole accumulated message on every frame. A WebSocket server, or an on-path attacker on an unencrypted ws:// connection, can split messages into many tiny continuation frames so that reassembly takes time quadratic in the number of frames. Reassembly holds the GIL in the synchronous client and blocks the event loop in the asynchronous client.
Applications are affected when they open a WebSocket session with client.websocket() or httpx2.websocket() to an untrusted endpoint, using httpx2 from 2.6.0 up to (but excluding) 2.18.0. From 2.10.0, the default max_message_size_bytes limit of 64 KiB bounds the work per message, so sustained load needs many messages; versions 2.6.0 to 2.9.1 have no such limit.
The issue is fixed in 2.18.0, which collects fragments in a list and joins them once when the final frame arrives. Until then, keep max_message_size_bytes small and connect only to trusted wss:// endpoints.