peass-ng/PEASS-ng · error · EndOfStreamException
EOF found when length expected
Error message
EOF found when length expected
What it means
An EndOfStreamException from ReadLength: the first byte read for the length octets of a TLV was -1, i.e. the stream ended right after the tag with no length field present. It indicates a truncated or prematurely terminated ASN.1 stream.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/Asn1InputStream.cs:277
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)
{
int size = length & 0x7f;
// Note: The invalid long form "0xff" (see X.690 8.1.3.5c) will be caught here
if (size > 4)
throw new IOException("DER length more than 4 bytes: " + size);
length = 0;
for (int i = 0; i < size; i++)
{
int next = s.ReadByte();
if (next < 0)View on GitHub (pinned to 53fb989abc)
Solutions
- Verify the input is complete and well-formed ASN.1 before constructing Asn1InputStream
- Fix upstream truncation (network cutoff, partial file write, bad Base64 decode)
- Catch EndOfStreamException where partial/malformed input is expected and report it as malformed data
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/Asn1InputStream.cs:277 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/babd8c3b09d0b999.
Report an issue: GitHub.