HTTPS WebSocket handshake and read loops can spin on WANT_READ/WANT_WRITE
Summary¶
The HTTPS WebSocket path loops immediately on mbedTLS WANT_READ and
WANT_WRITE return codes. Slow or malicious HTTPS clients can pin a worker
thread in a tight loop rather than yielding back to socket readiness.
This blocks Beta 0.7.3 because it is a remote denial-of-service risk on the WebServer surface.
Evidence¶
srchybrid/WebSocket.cpp:354loops during TLS handshake.srchybrid/WebSocket.cpp:355continues immediately onMBEDTLS_ERR_SSL_WANT_READandMBEDTLS_ERR_SSL_WANT_WRITE.srchybrid/WebSocket.cpp:375enters TLS read handling.srchybrid/WebSocket.cpp:379continues immediately on the same WANT codes.
Execution Plan¶
- Revalidate mbedTLS socket mode and how
WSAEventSelectreadiness is used. - Change handshake WANT handling to return to the event wait or otherwise wait on the needed socket readiness.
- Change read WANT handling to yield to the event loop instead of spinning.
- Preserve existing HTTP and HTTPS response behavior.
- Add targeted coverage or a manual repro for a slow TLS handshake/read.
Acceptance Criteria¶
- A slow HTTPS client cannot spin a CPU core.
- TLS handshake still succeeds for normal HTTPS Web UI/API clients.
- Shutdown can interrupt slow HTTPS clients cleanly.
Validation¶
- 2026-05-08: Done in app commit
aa66699. python -m emule_workspace validate --workspace-root .python -m emule_workspace build app --workspace-root . --config Release --platform x64 --variant main- Code validation: TLS handshake
WANT_READ/WANT_WRITEwaits on socket readiness or termination, TLS reads break back to the event loop, TLS writes leave unsent data queued, andclose_notifyno longer spins during shutdown.