Skip to content

Fix stale ssl_con_map entry after TcpConnection move-assignment#813

Open
MarkRose wants to merge 1 commit into
sm0svx:masterfrom
MarkRose:fix-tcpconnection-move-and-recvbuf
Open

Fix stale ssl_con_map entry after TcpConnection move-assignment#813
MarkRose wants to merge 1 commit into
sm0svx:masterfrom
MarkRose:fix-tcpconnection-move-and-recvbuf

Conversation

@MarkRose

Copy link
Copy Markdown
Contributor

TcpConnection::operator=(TcpConnection&&) transferred m_ssl from the
source object and nulled it out, but never updated the static
ssl_con_map lookup table used by the OpenSSL verify callback to map an
SSL* back to its owning TcpConnection. The map still pointed the SSL*
key at the moved-from object. Since that object's m_ssl was now null,
its destructor's cleanup path skipped erasing the stale entry, leaving
ssl_con_map[ssl] referencing freed memory. A later TLS handshake
invoking the verify callback would resolve the SSL* through this stale
entry, causing a use-after-free.

  • In operator=(TcpConnection&&), after taking ownership of other.m_ssl,
    re-point ssl_con_map[m_ssl] at this so the map always reflects the
    live owner of the SSL* key.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

TcpConnection::operator=(TcpConnection&&) transferred m_ssl from the
source object and nulled it out, but never updated the static
ssl_con_map lookup table used by the OpenSSL verify callback to map an
SSL* back to its owning TcpConnection. The map still pointed the SSL*
key at the moved-from object. Since that object's m_ssl was now null,
its destructor's cleanup path skipped erasing the stale entry, leaving
ssl_con_map[ssl] referencing freed memory. A later TLS handshake
invoking the verify callback would resolve the SSL* through this stale
entry, causing a use-after-free.

- In operator=(TcpConnection&&), after taking ownership of other.m_ssl,
  re-point ssl_con_map[m_ssl] at `this` so the map always reflects the
  live owner of the SSL* key.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@MarkRose MarkRose closed this Jul 12, 2026
@MarkRose MarkRose reopened this Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant