{"record":{"id":"a35e57e44f78305b","repo":"shadow1ng/fscan","slug":"s-socks5-invalid-request","errorCode":null,"errorMessage":"%s [socks5_invalid_request]","messagePattern":"(.+?) \\[socks5_invalid_request\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/local/socks5proxy.go","lineNumber":197,"sourceCode":"\n\t// 发送握手响应（无认证）\n\tresponse := []byte{0x05, 0x00} // 版本5，无认证\n\tif _, err := conn.Write(response); err != nil {\n\t\treturn fmt.Errorf(\"%s: %w\", i18n.GetText(\"socks5_handshake_write_failed\"), err)\n\t}\n\n\treturn nil\n}\n\n// handleSocks5Request 处理SOCKS5连接请求\nfunc (p *Socks5ProxyPlugin) handleSocks5Request(clientConn net.Conn, session *common.ScanSession) (net.Conn, int, error) {\n\theader := make([]byte, 4)\n\tif _, err := io.ReadFull(clientConn, header); err != nil {\n\t\treturn nil, 0, fmt.Errorf(\"%s: %w\", i18n.GetText(\"socks5_request_read_failed\"), err)\n\t}\n\n\tif header[0] != 0x05 || header[2] != 0x00 {\n\t\treturn nil, 0, fmt.Errorf(\"%s\", i18n.GetText(\"socks5_invalid_request\"))\n\t}\n\n\tcmd := header[1]\n\tif cmd != 0x01 { // 只支持CONNECT命令\n\t\t// 发送不支持的命令响应\n\t\tresponse := []byte{0x05, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}\n\t\t_, _ = clientConn.Write(response)\n\t\treturn nil, 0, fmt.Errorf(i18n.GetText(\"socks5_unsupported_command\")+\": %d\", cmd)\n\t}\n\n\t// 解析目标地址\n\taddrType := header[3]\n\tvar targetHost string\n\tvar targetPort int\n\n\tswitch addrType {\n\tcase 0x01: // IPv4\n\t\taddr := make([]byte, 6)","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/local/socks5proxy.go#L179-L215","documentation":"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.","triggerScenarios":"Thrown at plugins/local/socks5proxy.go:197 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}