sqlmapproject/sqlmap · error · ValueError

Kerberos ciphertext too short

Error message

Kerberos ciphertext too short

What it means

decrypt in the RFC 3961 enctype profile raises this when the ciphertext is shorter than one confounder block plus the MAC size. A reply that short cannot possibly contain confounder + plaintext + integrity MAC, so the code fails fast instead of slicing negative ranges off hostile data.

Solutions

  1. Check what produced the ciphertext: a truncated network reply vs. a caller passing the wrong buffer.
  2. Verify the entire Kerberos message was received (length prefixes read fully over TCP).
  3. If this is a parser slicing bug, fix the offsets so the full enc-part is passed in.
  4. Inspect the raw ciphertext length against the expected minimum for the etype.
Defensive patterns

Strategy: validation

When it happens

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

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at extra/kerberos/crypto.py:187

        secondLast = _xor(aes.decryptBlock(bytes(blocks[-1] + omitted)), prev)
        return bytes(out) + secondLast + lastPlain

    # --- authenticated encryption (RFC 3961 section 5.3) --------------------------------------------
    def _keys(self, key, usage):
        ke = self.dk(key, struct.pack(">IB", usage, 0xAA))
        ki = self.dk(key, struct.pack(">IB", usage, 0x55))
        return ke, ki

    def encrypt(self, key, usage, plaintext, confounder=None):
        ke, ki = self._keys(key, usage)
        if confounder is None:
            confounder = os.urandom(self.blocksize)
        basic = confounder + plaintext
        return self._basicEncrypt(ke, basic) + hmac.new(ki, basic, hashlib.sha1).digest()[:self.macsize]

    def decrypt(self, key, usage, ciphertext):
        if len(ciphertext) < self.blocksize + self.macsize:   # confounder block + HMAC; guards a hostile short reply
            raise ValueError("Kerberos ciphertext too short")
        ke, ki = self._keys(key, usage)
        ct, mac = ciphertext[:-self.macsize], ciphertext[-self.macsize:]
        basic = self._basicDecrypt(ke, ct)
        if not _eq(mac, hmac.new(ki, basic, hashlib.sha1).digest()[:self.macsize]):
            raise ValueError("Kerberos integrity check failed (wrong key or corrupted ciphertext)")
        return basic[self.blocksize:]

def _rc4(key, data):
    """RC4 (ARCFOUR) stream cipher."""

    key, data = bytearray(key), bytearray(data)
    if not key:
        raise ValueError("RC4 requires a non-empty key")
    s = list(range(256))
    j = 0
    for i in range(256):
        j = (j + s[i] + key[i % len(key)]) & 0xff
        s[i], s[j] = s[j], s[i]

View on GitHub (pinned to 0a35b20e39)