sqlmapproject/sqlmap · error · KerberosError

connection closed by KDC

Error message

connection closed by KDC

What it means

Transport failure in _recvExactly: the TCP connection to the KDC closed before the full length-prefixed reply (or the 4-byte prefix itself) arrived, so the response is incomplete and cannot be parsed.

Solutions

  1. Retry the KDC exchange (transient resets are common)
  2. Check KDC reachability, firewall and failover KDC list
  3. Verify the reply stays under MAX_KDC_RESPONSE and the connection isn't being cut by an intermediary
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at extra/kerberos/client.py:148 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of sqlmapproject/sqlmap@0a35b20e39 (2026-08-26). Data as JSON: /api/errors/2d5056ddbd7c17e8. Report an issue: GitHub.

Appendix: source

Thrown at extra/kerberos/client.py:148

    return der.sequence(
        der.tagged(0, der.integer(nameType)),
        der.tagged(1, der.sequenceOf([der.generalString(_) for _ in components])),
    )

def _encryptedData(etype, cipher, kvno=None):
    parts = [der.tagged(0, der.integer(etype))]
    if kvno is not None:
        parts.append(der.tagged(1, der.integer(kvno)))
    parts.append(der.tagged(2, der.octetString(cipher)))
    return der.sequence(*parts)

# ---- KDC transport (RFC 4120 section 7.2.2: 4-byte length-prefixed over TCP) ----------------------
def _recvExactly(sock, count):
    buf = b""
    while len(buf) < count:
        chunk = sock.recv(count - len(buf))
        if not chunk:
            raise KerberosError(-1, "connection closed by KDC")
        buf += chunk
    return buf

def _sendReceive(host, port, request):
    sock = socket.create_connection((host, port), timeout=KDC_TIMEOUT)
    try:
        sock.sendall(struct.pack(">I", len(request)) + request)
        length = struct.unpack(">I", _recvExactly(sock, 4))[0]
        if length > MAX_KDC_RESPONSE:
            raise KerberosError(-1, "KDC reply length %d exceeds the sane maximum" % length)
        return _recvExactly(sock, length)
    finally:
        sock.close()

def _raiseIfError(message):
    tag, content, _ = der.peel(message)
    if tag == der.applicationTag(KRB_ERROR):
        fields = _fields(der.peel(content)[1])

View on GitHub (pinned to 0a35b20e39)