Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,20 @@ export async function createHsync(config) {
getSocketRelays: hsyncClient.getSocketRelays,
peerRpc: async (requestInfo) => {
requestInfo.hsyncClient = hsyncClient;
const { msg } = requestInfo;
const { msg, myAuth } = requestInfo;
debug('peerRpc handler', requestInfo.fromHost, msg.method);
const peer = hsyncClient.peers.getRPCPeer({ hostName: requestInfo.fromHost, hsyncClient });
requestInfo.peer = peer;

// Security: Validate authentication token before processing any RPC request
// CVE-HSYNC-2026-003: Previously, myAuth was sent but never verified
if (peer.myAuth !== myAuth) {
debug('peerRpc auth failed', requestInfo.fromHost, myAuth ? 'invalid token' : 'missing token');
const authError = new Error('RPC authentication failed: invalid or missing auth token');
authError.code = 401;
throw authError;
}

if (!msg.id) {
// notification
if (Array.isArray(msg.params)) {
Expand Down