Bug Description
Socks5Client.connect() does not enforce an authenticated/ready state before sending a SOCKS CONNECT request.
Reproducible By
import { EventEmitter } from "node:events";
import { Socks5Client } from "undici/lib/core/socks5-client.js";
class MockSocket extends EventEmitter {
constructor() {
super();
this.writes = [];
this.destroyed = false;
}
write(chunk) {
this.writes.push(Buffer.from(chunk));
}
destroy() {
this.destroyed = true;
}
}
const socket = new MockSocket();
const client = new Socks5Client(socket);
client.connect("example.com", 80);
console.log(client.state); // connecting
console.log(socket.writes[0]); // CONNECT request already written
Expected Behavior
connect() should only be allowed after SOCKS negotiation has completed successfully.
Logs & Screenshots
connecting
<Buffer 05 01 00 03 0b 65 78 61 6d 70 6c 65 2e 63 6f 6d 00 50>
Environment
macOS 26.4.1
Node v24.15.0
undici v8.1.0
Bug Description
Socks5Client.connect()does not enforce an authenticated/ready state before sending a SOCKSCONNECTrequest.Reproducible By
Expected Behavior
connect()should only be allowed after SOCKS negotiation has completed successfully.Logs & Screenshots
Environment
macOS 26.4.1
Node v24.15.0
undici v8.1.0