shadow1ng/fscan · error
%s [socks5_invalid_request]
Error message
%s [socks5_invalid_request]
What it means
Guard in handleSocks5Request rejecting a SOCKS5 request header that is not well-formed: the version byte (header[0]) is not 0x05 or the reserved byte (header[2]) is not 0x00. It fires when a client connected to the local SOCKS5 proxy port sends a malformed or non-SOCKS5 request, before any command or address parsing.
Source
Thrown at plugins/local/socks5proxy.go:197
// 发送握手响应(无认证)
response := []byte{0x05, 0x00} // 版本5,无认证
if _, err := conn.Write(response); err != nil {
return fmt.Errorf("%s: %w", i18n.GetText("socks5_handshake_write_failed"), err)
}
return nil
}
// handleSocks5Request 处理SOCKS5连接请求
func (p *Socks5ProxyPlugin) handleSocks5Request(clientConn net.Conn, session *common.ScanSession) (net.Conn, int, error) {
header := make([]byte, 4)
if _, err := io.ReadFull(clientConn, header); err != nil {
return nil, 0, fmt.Errorf("%s: %w", i18n.GetText("socks5_request_read_failed"), err)
}
if header[0] != 0x05 || header[2] != 0x00 {
return nil, 0, fmt.Errorf("%s", i18n.GetText("socks5_invalid_request"))
}
cmd := header[1]
if cmd != 0x01 { // 只支持CONNECT命令
// 发送不支持的命令响应
response := []byte{0x05, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
_, _ = clientConn.Write(response)
return nil, 0, fmt.Errorf(i18n.GetText("socks5_unsupported_command")+": %d", cmd)
}
// 解析目标地址
addrType := header[3]
var targetHost string
var targetPort int
switch addrType {
case 0x01: // IPv4
addr := make([]byte, 6)View on GitHub (pinned to 95cc12e753)
Solutions
- Use a SOCKS5-compliant client/proxy consumer
- Verify the client library's request framing against RFC 1928
- Reject and close the connection; log the peer for diagnosis
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at plugins/local/socks5proxy.go:197 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/a35e57e44f78305b.
Report an issue: GitHub.