diff --git a/src/svxlink/reflector/Reflector.cpp b/src/svxlink/reflector/Reflector.cpp index 7540ff1..7899d16 100644 --- a/src/svxlink/reflector/Reflector.cpp +++ b/src/svxlink/reflector/Reflector.cpp @@ -4023,7 +4023,25 @@ void Reflector::twinPendingFrameReceived(Async::FramedTcpConnection* con, return; } - // Secret/prefix validation lives inside TwinLink::acceptInboundConnection. + // Verify HMAC (shared secret proof) before leaking any other info. + if (!msg.verify(m_twin_link->secret())) + { + std::cerr << "*** ERROR: TWIN inbound: authentication failed " + << "(wrong secret)" << std::endl; + rejectPending(); + return; + } + + // Twins must share the same LOCAL_PREFIX. + if (msg.localPrefix() != m_twin_link->localPrefix()) + { + std::cerr << "*** ERROR: TWIN inbound: local_prefix mismatch: " + << "ours='" << m_twin_link->localPrefix() + << "' theirs='" << msg.localPrefix() << "'" << std::endl; + rejectPending(); + return; + } + // Clean up our pending entry and hand off. delete pit->second; // timer m_twin_pending_cons.erase(pit); diff --git a/src/svxlink/reflector/TwinLink.h b/src/svxlink/reflector/TwinLink.h index 49f87c4..b86decf 100644 --- a/src/svxlink/reflector/TwinLink.h +++ b/src/svxlink/reflector/TwinLink.h @@ -95,6 +95,8 @@ class TwinLink bool isActive(void) const; const std::string& partnerHost(void) const { return m_peer_host; } uint16_t partnerPort(void) const { return m_peer_port; } + const std::string& secret(void) const { return m_secret; } + const std::string& localPrefix(void) const { return m_local_prefix; } private: using FramedTcpClient =