What changed, and why it matters
This small patch changes how a Monero peer-to-peer network connection decides whether to proceed with closing. Previously, if the connection was not in the 'RUNNING' state, close() simply returned false and did nothing. Now it returns true (success) if the connection is already in a terminal state (TERMINATED or WASTED), and only returns false if the caller does not want to wait for shutdown and the connection is not running. The change makes connection cleanup more predictable and prevents callers from thinking a close failed when the connection was already dead. There is no direct evidence in the commit that this fixes an exploitable security vulnerability, but it removes a logic path that could leave connections in an inconsistent state.
Treat as a routine hardening/cleanup fix. Review related connection lifecycle code for any remaining inconsistent state handling. No urgent security response is indicated by the available evidence.
Security signals we found
State-machine hardening in network connection teardown
Possible use-after-close or double-close risk reduced by explicit terminal-state handling
No explicit security claim in commit message or diff
Evidence from the diff
In contrib/epee/include/net/abstract_tcp_server2.inl, the close() method of connection
Changed components
contrib/epee/include/net/abstract_tcp_server2.inlconnection<T>::close()Monero P2P networking layerInspect captured patch +3 / −1
diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl
index 0772644..283b6d5 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.inl
+++ b/contrib/epee/include/net/abstract_tcp_server2.inl
@@ -1140,7 +1140,9 @@ namespace net_utils
bool connection<T>::close(const bool wait_for_shutdown)
{
std::lock_guard<std::mutex> guard(m_state.lock);
- if (m_state.status != status_t::RUNNING)
+ if (m_state.status == status_t::TERMINATED || m_state.status == status_t::WASTED)
+ return true;
+ if (!wait_for_shutdown && m_state.status != status_t::RUNNING)
return false;
terminate_async();
Why this scored 26/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.