peass-ng/PEASS-ng · error · EndOfStreamException

EOF found inside tag value.

Error message

EOF found inside tag value.

What it means

An EndOfStreamException from ReadTagNumber: while accumulating the base-128 continuation octets of a high tag number, ReadByte returned -1 before a terminating octet (high bit clear) was seen. The stream ends in the middle of the multi-octet tag value, indicating truncation.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/Asn1InputStream.cs:265

            {
                tagNo = 0;

                int b = s.ReadByte();

                // X.690-0207 8.1.2.4.2
                // "c) bits 7 to 1 of the first subsequent octet shall not all be zero."
                if ((b & 0x7f) == 0) // Note: -1 will pass
                    throw new IOException("corrupted stream - invalid high tag number found");

                while ((b >= 0) && ((b & 0x80) != 0))
                {
                    tagNo |= (b & 0x7f);
                    tagNo <<= 7;
                    b = s.ReadByte();
                }

                if (b < 0)
                    throw new EndOfStreamException("EOF found inside tag value.");

                tagNo |= (b & 0x7f);
            }

            return tagNo;
        }

        internal static int ReadLength(Stream s, int limit, bool isParsing)
        {
            int length = s.ReadByte();
            if (length < 0)
                throw new EndOfStreamException("EOF found when length expected");

            if (length == 0x80)
                return -1;      // indefinite-length encoding

            if (length > 127)
            {

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Ensure the complete ASN.1 document is available before parsing (read all bytes, verify expected length)
  2. Check transport framing (TLS records, Base64 padding, file size) for truncation upstream
  3. Handle EndOfStreamException and discard the partial input
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/Asn1InputStream.cs:265 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02). Data as JSON: /api/errors/92145c5d6742711f. Report an issue: GitHub.