Security: TLS I/O doesn't handle SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE #160

Closed
opened 2026-07-29 18:35:44 +02:00 by TapTap · 0 comments
Owner

Description

The TLS wrapping code in src/shared/protocol.c:68-115 and src/shared/transport_tls.c:80-100 treats any SSL_write/SSL_read/SSL_accept/SSL_connect return value <= 0 as a fatal error. For non-blocking or partially blocking TLS I/O, OpenSSL may return SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE, which should be retried rather than failing immediately. The current code never calls SSL_get_error(), so benign retry conditions are reported as hard failures.

Location

  • src/shared/protocol.c:77-84SSL_write() errors are treated as fatal.
  • src/shared/protocol.c:98-109SSL_read() errors are treated as fatal.
  • src/shared/transport_tls.c:88-97SSL_accept()/SSL_connect() errors are treated as fatal.

Suggested fix

  1. After each SSL_* call that returns <= 0, call SSL_get_error().
  2. For SSL_ERROR_WANT_READ/SSL_ERROR_WANT_WRITE, retry the operation with the appropriate file descriptor readiness check (select()/poll()).
  3. For SSL_ERROR_SYSCALL/SSL_ERROR_SSL, log the error and abort the connection.

Severity

Medium

Category

security


This issue was automatically generated by the issue-creator agent.

## Description The TLS wrapping code in `src/shared/protocol.c:68-115` and `src/shared/transport_tls.c:80-100` treats any `SSL_write`/`SSL_read`/`SSL_accept`/`SSL_connect` return value `<= 0` as a fatal error. For non-blocking or partially blocking TLS I/O, OpenSSL may return `SSL_ERROR_WANT_READ` or `SSL_ERROR_WANT_WRITE`, which should be retried rather than failing immediately. The current code never calls `SSL_get_error()`, so benign retry conditions are reported as hard failures. ## Location - `src/shared/protocol.c:77-84` — `SSL_write()` errors are treated as fatal. - `src/shared/protocol.c:98-109` — `SSL_read()` errors are treated as fatal. - `src/shared/transport_tls.c:88-97` — `SSL_accept()`/`SSL_connect()` errors are treated as fatal. ## Suggested fix 1. After each `SSL_*` call that returns `<= 0`, call `SSL_get_error()`. 2. For `SSL_ERROR_WANT_READ`/`SSL_ERROR_WANT_WRITE`, retry the operation with the appropriate file descriptor readiness check (`select()`/`poll()`). 3. For `SSL_ERROR_SYSCALL`/`SSL_ERROR_SSL`, log the error and abort the connection. ## Severity Medium ## Category security --- _This issue was automatically generated by the issue-creator agent._
TapTap added the bugsecurityneeds-triage labels 2026-07-29 18:35:44 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#160