{"record":{"id":"d00f86ae64dac5f7","repo":"cloudflare/cloudflared","slug":"unrecognized-address-type","errorCode":null,"errorMessage":"Unrecognized address type","messagePattern":"Unrecognized address type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"socks/request.go","lineNumber":184,"sourceCode":"\t\taddr := make([]byte, 16)\n\t\tif _, err := io.ReadAtLeast(r, addr, len(addr)); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\td.IP = net.IP(addr)\n\n\tcase fqdnAddress:\n\t\tif _, err := r.Read(addrType); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\taddrLen := int(addrType[0])\n\t\tfqdn := make([]byte, addrLen)\n\t\tif _, err := io.ReadAtLeast(r, fqdn, addrLen); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\td.FQDN = string(fqdn)\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Unrecognized address type\")\n\t}\n\n\t// Read the port\n\tport := []byte{0, 0}\n\tif _, err := io.ReadAtLeast(r, port, 2); err != nil {\n\t\treturn nil, err\n\t}\n\td.Port = (int(port[0]) << 8) | int(port[1])\n\n\treturn d, nil\n}\n","sourceCodeStart":166,"sourceCodeEnd":196,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/socks/request.go#L166-L196","documentation":"readAddrSpec parses the destination address in a SOCKS5 request and supports IPv4, domain name (FQDN), and IPv6 address types. If the ATYP byte is any other value (0x00, 0x04 was IPv6, >0x04, etc.), the parser cannot decode the address and returns this error. It indicates a malformed or non-standard SOCKS5 client packet.","triggerScenarios":"NewRequest receiving a request whose address-type byte (fourth byte) is outside {0x01 IPv4, 0x03 FQDN, 0x04 IPv6} — corrupted stream, wrong offset parsing, or a client speaking a divergent protocol variant.","commonSituations":"A buggy or hand-rolled SOCKS5 client writing the ATYP byte incorrectly; stream desynchronization after a partial/misread greeting; fuzzing or malicious clients probing the proxy.","solutions":["Fix or replace the SOCKS5 client library so it emits standard ATYP values 1, 3, or 4","Capture the raw bytes of the failing client to confirm where desynchronization begins","If clients are known-good, check for an intermediary (proxy/inspection tool) that corrupts the stream","For custom address types, fork readAddrSpec and add support explicitly"],"exampleFix":"// client writing nonstandard ATYP=0\nbuf[3] = 0x00\n\n// after\nbuf[3] = 0x01 // ATYP IPv4 (or 0x03 FQDN / 0x04 IPv6)","handlingStrategy":"try-catch","validationCode":"// validate ATYP byte before parsing (client side)\nswitch atyp {\ncase 0x01, 0x03, 0x04:\n    // ok\ndefault:\n    return fmt.Errorf(\"invalid SOCKS5 ATYP byte: %#x\", atyp)\n}","typeGuard":"func isKnownATYP(b byte) bool { return b == 0x01 || b == 0x03 || b == 0x04 }","tryCatchPattern":"if err := serve(conn); err != nil && strings.Contains(err.Error(), \"Unrecognized address type\") {\n    log.Warn().Msg(\"malformed SOCKS5 client packet; capture raw bytes\")\n}","preventionTips":["Use a maintained SOCKS5 client library rather than hand-rolled packet writers","Test client implementations against this server in CI","Monitor for this error as a signal of malicious/fuzzing traffic"],"tags":["network","socks5","malformed-packet"],"backgroundTag":"invalid-enum-value","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}