{"record":{"id":"d6b3d5247450359e","repo":"peass-ng/PEASS-ng","slug":"byte-value-should-have-1-byte-in-it","errorCode":null,"errorMessage":"byte value should have 1 byte in it","messagePattern":"byte value should have 1 byte in it","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/DerBoolean.cs","lineNumber":66,"sourceCode":"        public static DerBoolean GetInstance(\n            Asn1TaggedObject obj,\n            bool isExplicit)\n        {\n            Asn1Object o = obj.GetObject();\n\n            if (isExplicit || o is DerBoolean)\n            {\n                return GetInstance(o);\n            }\n\n            return FromOctetString(((Asn1OctetString)o).GetOctets());\n        }\n\n        public DerBoolean(\n            byte[] val)\n        {\n            if (val.Length != 1)\n                throw new ArgumentException(\"byte value should have 1 byte in it\", \"val\");\n\n            // TODO Are there any constraints on the possible byte values?\n            this.value = val[0];\n        }\n\n        private DerBoolean(\n            bool value)\n        {\n            this.value = value ? (byte)0xff : (byte)0;\n        }\n\n        public bool IsTrue\n        {\n            get { return value != 0; }\n        }\n\n        internal override void Encode(\n            DerOutputStream derOut)","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/DerBoolean.cs#L48-L84","documentation":"The DerBoolean(byte[]) constructor requires exactly one content octet, per the ASN.1 BOOLEAN encoding (a single byte where 0xFF is true and 0x00 is false). A byte array of any other length is invalid and triggers this ArgumentException.","triggerScenarios":"Constructing DerBoolean directly from a byte[] whose Length != 1, e.g. passing multi-byte content from a malformed BER/DER record or from user-supplied bytes.","commonSituations":"Hand-crafting ASN.1 structures; decoding corrupted or non-conformant DER data where the BOOLEAN content length field is wrong; slicing errors that grab surrounding bytes.","solutions":["Validate val.Length == 1 before calling the constructor","If the source is DER content, verify the length octet and slice exactly one byte","If multiple bytes are meaningful, the data is not a BOOLEAN - parse it as the correct ASN.1 type instead","Catch ArgumentException and reject the record as malformed"],"exampleFix":"// before\nvar b = new DerBoolean(contentBytes);\n// after\nif (contentBytes.Length != 1) throw new FormatException(\"BOOLEAN must be 1 byte\");\nvar b = new DerBoolean(contentBytes);","handlingStrategy":"validation","validationCode":"if (val == null || val.Length != 1) throw new FormatException(\"BOOLEAN content must be exactly 1 byte\");","typeGuard":"bool IsValidBooleanBytes(byte[] b) => b != null && b.Length == 1;","tryCatchPattern":"try { var b = new DerBoolean(val); }\ncatch (ArgumentException) { /* reject record as malformed */ }","preventionTips":["Slice exactly the content octets from the TLV","Sanity-check DER length octets before constructing","Prefer GetInstance(Asn1Object) over manual byte[] construction","Validate incoming DER with a strict parser first"],"tags":["asn1","bouncycastle","der","argumentexception"],"backgroundTag":"asn1-boolean-invalid-length","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}