{"record":{"id":"9d9953324f90b892","repo":"peass-ng/PEASS-ng","slug":"corrupted-stream-invalid-high-tag-number-found","errorCode":null,"errorMessage":"corrupted stream - invalid high tag number found","messagePattern":"corrupted stream - invalid high tag number found","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/Asn1InputStream.cs","lineNumber":255,"sourceCode":"        internal static int ReadTagNumber(\n            Stream s,\n            int tag)\n        {\n            int tagNo = tag & 0x1f;\n\n            //\n            // with tagged object tag number is bottom 5 bits, or stored at the start of the content\n            //\n            if (tagNo == 0x1f)\n            {\n                tagNo = 0;\n\n                int b = s.ReadByte();\n\n                // X.690-0207 8.1.2.4.2\n                // \"c) bits 7 to 1 of the first subsequent octet shall not all be zero.\"\n                if ((b & 0x7f) == 0) // Note: -1 will pass\n                    throw new IOException(\"corrupted stream - invalid high tag number found\");\n\n                while ((b >= 0) && ((b & 0x80) != 0))\n                {\n                    tagNo |= (b & 0x7f);\n                    tagNo <<= 7;\n                    b = s.ReadByte();\n                }\n\n                if (b < 0)\n                    throw new EndOfStreamException(\"EOF found inside tag value.\");\n\n                tagNo |= (b & 0x7f);\n            }\n\n            return tagNo;\n        }\n\n        internal static int ReadLength(Stream s, int limit, bool isParsing)","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/Asn1InputStream.cs#L237-L273","documentation":"An ASN.1 header validation in ReadTagNumber: for a high tag number form (tagNo == 0x1f), X.690 8.1.2.4.2 requires that bits 7-1 of the first subsequent octet are not all zero; the parser read an octet whose low 7 bits are zero (EOF -1 also passes this check) and rejects the stream. It fires on malformed tag encodings or truncated input.","triggerScenarios":"Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/Asn1InputStream.cs:255 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the ASN.1 data with a conforming encoder so high tag numbers use minimal octet encoding","Validate/truncate-check the byte stream before parsing","Catch IOException and treat the document as malformed/corrupted"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}