{"record":{"id":"98404a128c3a0297","repo":"peass-ng/PEASS-ng","slug":"illegal-object-in-getinstance-98404a","errorCode":null,"errorMessage":"illegal object in GetInstance: ","messagePattern":"illegal object in GetInstance: ","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/DerBoolean.cs","lineNumber":27,"sourceCode":"        private readonly byte value;\n\n        public static readonly DerBoolean False = new DerBoolean(false);\n        public static readonly DerBoolean True = new DerBoolean(true);\n\n        /**\n         * return a bool from the passed in object.\n         *\n         * @exception ArgumentException if the object cannot be converted.\n         */\n        public static DerBoolean GetInstance(\n            object obj)\n        {\n            if (obj == null || obj is DerBoolean)\n            {\n                return (DerBoolean)obj;\n            }\n\n            throw new ArgumentException(\"illegal object in GetInstance: \" + Platform.GetTypeName(obj));\n        }\n\n        /**\n         * return a DerBoolean from the passed in bool.\n         */\n        public static DerBoolean GetInstance(\n            bool value)\n        {\n            return value ? True : False;\n        }\n\n        /**\n         * return a Boolean from a tagged object.\n         *\n         * @param obj the tagged object holding the object we want\n         * @param explicitly true if the object is meant to be explicitly\n         *              tagged false otherwise.\n         * @exception ArgumentException if the tagged object cannot","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/DerBoolean.cs#L9-L45","documentation":"DerBoolean.GetInstance is BouncyCastle's strict conversion helper: it only accepts null or an object that is already a DerBoolean. Passing any other object type (e.g. DerInteger, DerOctetString, a raw bool/byte[]) makes the parser throw this ArgumentException with the offending type name appended to the message.","triggerScenarios":"Calling DerBoolean.GetInstance(obj) with an Asn1Object that is not a DerBoolean (e.g. a DerInteger or Asn1Null parsed from an ASN.1 stream), or passing a non-null object when expecting a BOOLEAN-tagged element that was actually encoded as a different ASN.1 type.","commonSituations":"Parsing X.509/CRL/CMS structures where a field is misinterpreted or a different certificate profile encodes a value as INTEGER/NULL instead of BOOLEAN; mixing up GetInstance(object) vs GetInstance(Asn1TaggedObject, bool) overloads.","solutions":["Inspect the actual type in the message (Platform.GetTypeName output) and use the matching Der* GetInstance, e.g. DerInteger.GetInstance","If the value is inside a tagged object, call GetInstance((Asn1TaggedObject)obj, true) so tagging is unwrapped first","Verify the ASN.1 structure you are parsing actually defines this field as BOOLEAN","Wrap parsing in try/catch ArgumentException and treat the element as absent/malformed"],"exampleFix":"// before\nvar b = DerBoolean.GetInstance(asn1Obj);\n// after\nif (asn1Obj is DerBoolean db) { var b = db; }\nelse if (asn1Obj is Asn1TaggedObject t) { var b = DerBoolean.GetInstance(t, true); }\nelse { /* handle wrong type */ }","handlingStrategy":"type-guard","validationCode":"bool ok = obj == null || obj is DerBoolean;","typeGuard":"bool IsDerBoolean(object o) => o is DerBoolean;","tryCatchPattern":"try { var b = DerBoolean.GetInstance(obj); }\ncatch (ArgumentException ex) { /* log ex.Message, treat field as invalid */ }","preventionTips":["Check 'is DerBoolean' before GetInstance","For tagged objects always use GetInstance((Asn1TaggedObject)obj, true)","Read the type name in the exception message to pick the right Der* class","Fuzz-test parsers against mismatched ASN.1 types"],"tags":["asn1","bouncycastle","argumentexception","parsing"],"backgroundTag":"asn1-type-mismatch","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}