{"record":{"id":"ce6511a2aa874d0f","repo":"peass-ng/PEASS-ng","slug":"invalid-encoding-value","errorCode":null,"errorMessage":"invalid encoding value","messagePattern":"invalid encoding value","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/DerExternal.cs","lineNumber":55,"sourceCode":"\t\t\t{\n\t\t\t\tdataValueDescriptor = enc;\n\t\t\t\toffset++;\n\t\t\t\tenc = GetObjFromVector(vector, offset);\n\t\t\t}\n\n\t\t\tif (vector.Count != offset + 1)\n\t\t\t\tthrow new ArgumentException(\"input vector too large\", \"vector\");\n\n\t\t\tif (!(enc is Asn1TaggedObject))\n\t\t\t\tthrow new ArgumentException(\"No tagged object found in vector. Structure doesn't seem to be of type External\", \"vector\");\n\n\t\t\tAsn1TaggedObject obj = (Asn1TaggedObject)enc;\n\n\t\t\t// Use property accessor to include check on value\n\t\t\tEncoding = obj.TagNo;\n\n\t\t\tif (encoding < 0 || encoding > 2)\n\t\t\t\tthrow new InvalidOperationException(\"invalid encoding value\");\n\n\t\t\texternalContent = obj.GetObject();\n\t\t}\n\n\t\t/**\n\t\t* Creates a new instance of DerExternal\n\t\t* See X.690 for more informations about the meaning of these parameters\n\t\t* @param directReference The direct reference or <code>null</code> if not set.\n\t\t* @param indirectReference The indirect reference or <code>null</code> if not set.\n\t\t* @param dataValueDescriptor The data value descriptor or <code>null</code> if not set.\n\t\t* @param externalData The external data in its encoded form.\n\t\t*/\n\t\tpublic DerExternal(DerObjectIdentifier directReference, DerInteger indirectReference, Asn1Object dataValueDescriptor, DerTaggedObject externalData)\n\t\t\t: this(directReference, indirectReference, dataValueDescriptor, externalData.TagNo, externalData.ToAsn1Object())\n\t\t{\n\t\t}\n\n\t\t/**","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/DerExternal.cs#L37-L73","documentation":"The DER External encoding field's tag number selects the encoding type: 0 = single-ASN1-type, 1 = octet-aligned, 2 = arbitrary. The constructor validates TagNo after reading it, and throws InvalidOperationException if it falls outside 0-2, meaning the tagged object uses a tag number undefined for External encodings.","triggerScenarios":"Constructing DerExternal from a vector whose final Asn1TaggedObject has TagNo < 0 or > 2.","commonSituations":"Decoding BER data with a non-standard or application-specific tag used where an External encoding tag is expected; hand-built tagged objects with the wrong tag number; protocol implementations that mis-encode the External content.","solutions":["Use TagNo 0, 1, or 2 on the tagged encoding object (explicit tagging) before constructing DerExternal","If parsing input data, treat this as malformed BER and reject/re-fetch the data","For custom content, wrap it correctly: new DerTaggedObject(true, 0, content) rather than an arbitrary tag"],"exampleFix":"// before\nvar bad = new DerTaggedObject(true, 5, content); // TagNo 5\nvar ext = new DerExternal(vector);\n// after\nvar good = new DerTaggedObject(true, 0, content); // valid encoding tag\nvar ext = new DerExternal(vector);","handlingStrategy":"validation","validationCode":"var tag = ((Asn1TaggedObject)vector[vector.Count - 1]).TagNo;\nif (tag < 0 || tag > 2)\n    throw new FormatException($\"External encoding tag {tag} out of range 0-2\");\nvar ext = new DerExternal(vector);","typeGuard":"static bool IsValidEncodingTag(Asn1TaggedObject o) => o.TagNo >= 0 && o.TagNo <= 2;","tryCatchPattern":"try { var ext = new DerExternal(vector); }\ncatch (InvalidOperationException ex) when (ex.Message == \"invalid encoding value\") {\n    // tagged encoding uses an unsupported tag number\n}","preventionTips":["Only use tag numbers 0, 1, or 2 for the External encoding field","Map application encodings to the standard three External encoding choices","Reject non-standard BER data at parse time instead of passing it into DerExternal"],"tags":["asn1","bouncycastle","der-encoding","invalid-operation"],"backgroundTag":"invalid-asn1-encoding","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}