peass-ng/PEASS-ng · error · ArgumentException

No tagged object found in vector. Structure doesn't seem to

Error message

No tagged object found in vector. Structure doesn't seem to be of type External

What it means

A DER External's encoding field must be an explicitly tagged object (tag 0, 1, or 2) holding the content. After the constructor consumes optional reference/descriptor fields, the remaining element must be an Asn1TaggedObject; if it is not, the structure is not a valid External and ArgumentException is thrown.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/DerExternal.cs:47

			}
			if (enc is DerInteger)
			{
				indirectReference = (DerInteger)enc;
				offset++;
				enc = GetObjFromVector(vector, offset);
			}
			if (!(enc is Asn1TaggedObject))
			{
				dataValueDescriptor = enc;
				offset++;
				enc = GetObjFromVector(vector, offset);
			}

			if (vector.Count != offset + 1)
				throw new ArgumentException("input vector too large", "vector");

			if (!(enc is Asn1TaggedObject))
				throw new ArgumentException("No tagged object found in vector. Structure doesn't seem to be of type External", "vector");

			Asn1TaggedObject obj = (Asn1TaggedObject)enc;

			// Use property accessor to include check on value
			Encoding = obj.TagNo;

			if (encoding < 0 || encoding > 2)
				throw new InvalidOperationException("invalid encoding value");

			externalContent = obj.GetObject();
		}

		/**
		* Creates a new instance of DerExternal
		* See X.690 for more informations about the meaning of these parameters
		* @param directReference The direct reference or <code>null</code> if not set.
		* @param indirectReference The indirect reference or <code>null</code> if not set.
		* @param dataValueDescriptor The data value descriptor or <code>null</code> if not set.

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Ensure the last vector element is an Asn1TaggedObject with TagNo 0-2 before constructing
  2. Validate with a type check: if (!(vector[offset] is Asn1TaggedObject)) reject the input
  3. Re-parse the source bytes — the input likely is not actually a DER External structure

Example fix

// before
var ext = new DerExternal(vector, 0);
// after
if (!(vector[0] is Asn1TaggedObject))
    throw new FormatException("External encoding must be tagged");
var ext = new DerExternal(vector, 0);
Defensive patterns

Strategy: type-guard

Validate before calling

var last = vector != null && vector.Count == offset + 1 ? vector[offset] : null;
if (last is Asn1TaggedObject tagged && tagged.TagNo >= 0 && tagged.TagNo <= 2) {
    var ext = new DerExternal(vector, offset);
}

Type guard

static bool HasTaggedEncoding(Asn1EncodableVector v, int i) =>
    v != null && v.Count > i && v[i] is Asn1TaggedObject;

Try / catch

try { var ext = new DerExternal(vector, offset); }
catch (ArgumentException ex) when (ex.Message.Contains("No tagged object")) {
    // structure is not a DER External
}

Prevention

When it happens

Trigger: Calling DerExternal(Asn1EncodableVector, int) where the final element of the vector (at position offset) is a plain Asn1Object (e.g. DerSequence or DerOctetString) rather than an Asn1TaggedObject.

Common situations: Parsing BER data where an EXTERNAL element was encoded without the required tagging; passing the wrong vector (contents of some other sequence type) into DerExternal; hand-assembled vectors missing the tagged encoding field.

Related errors


AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02). Data as JSON: /api/errors/1e185a152d4e246d. Report an issue: GitHub.