sqlmapproject/sqlmap · error · ValueError

truncated DER length

Error message

truncated DER length

What it means

peel raises this when the length uses the long form (first byte >= 0x80) but fewer bytes than the declared length-of-length remain in the buffer. The message is truncated mid-header; the decoder aborts rather than reading a bogus length.

Solutions

  1. Verify the message was fully received before parsing (complete the TCP read).
  2. Check the offset used to peel — parsing at a wrong offset can land inside content.
  3. Compare the buffer against an expected structure to find where truncation starts.
  4. Retry the exchange; persistent truncation points at a broken peer or proxy.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at extra/kerberos/der.py:110 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/f70216aa0377a069. Report an issue: GitHub.

Appendix: source

Thrown at extra/kerberos/der.py:110

# ---- decoding -------------------------------------------------------------------------------------
def peel(data, offset=0):
    """Parse one TLV at 'offset'; return (tag, content_bytearray, next_offset). Raises ValueError on
    truncated or indefinite-length input (the data may come from the network, so fail predictably)."""

    data = bytearray(data)
    if offset + 2 > len(data):
        raise ValueError("truncated DER header")
    tag = data[offset]
    first = data[offset + 1]
    offset += 2
    if first < 0x80:
        length = first
    elif first == 0x80:
        raise ValueError("indefinite-length DER is not permitted")
    else:
        count = first & 0x7f
        if offset + count > len(data):
            raise ValueError("truncated DER length")
        length = 0
        for _ in range(count):
            length = (length << 8) | data[offset]
            offset += 1
    if offset + length > len(data):
        raise ValueError("truncated DER content")
    return tag, data[offset:offset + length], offset + length

def children(content):
    """Iterate the TLVs contained in a constructed value; yields (tag, content_bytearray)."""

    content = bytearray(content)
    offset = 0
    out = []
    while offset < len(content):
        tag, inner, offset = peel(content, offset)
        out.append((tag, inner))
    return out

View on GitHub (pinned to 0a35b20e39)