peass-ng/PEASS-ng · error · IOException

unsupported tag number

Error message

unsupported tag number

What it means

DerApplicationSpecific.GetObject(int derTagNo) refuses tag numbers >= 0x1f because only low tag numbers can be represented by a single-octet tag when the tag number is rewritten; it throws IOException 'unsupported tag number'.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/DerApplicationSpecific.cs:152

		 * @throws IOException if reconstruction fails.
		 */
		public Asn1Object GetObject()
		{
			return FromByteArray(GetContents());
		}

		/**
		 * Return the enclosed object assuming implicit tagging.
		 *
		 * @param derTagNo the type tag that should be applied to the object's contents.
		 * @return  the resulting object
		 * @throws IOException if reconstruction fails.
		 */
		public Asn1Object GetObject(
			int derTagNo)
		{
			if (derTagNo >= 0x1f)
				throw new IOException("unsupported tag number");

			byte[] orig = this.GetEncoded();
			byte[] tmp = ReplaceTagNumber(derTagNo, orig);

			if ((orig[0] & Asn1Tags.Constructed) != 0)
			{
				tmp[0] |= Asn1Tags.Constructed;
			}

			return FromByteArray(tmp);
		}

		internal override void Encode(
			DerOutputStream derOut)
		{
			int classBits = Asn1Tags.Application;
			if (isConstructed)
			{

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Use a tag number below 0x1f, masking: derTagNo & 0x1f only if the value was a full tag octet
  2. If a high tag is genuinely needed, parse the content manually: new Asn1InputStream(app.GetContents()).ReadObject()
  3. Double-check you are not passing a class/constructed-flag byte — pass only the 5-bit tag number
  4. Update the protocol design/constant to a supported low tag number

Example fix

// before
Asn1Object o = app.GetObject(0x40); // >= 0x1f -> throws
// after
int tagNo = 0x40 & 0x1f; // or use a tag < 31
Asn1Object o = app.GetObject(tagNo);
Defensive patterns

Strategy: validation

Validate before calling

bool IsLowTagNumber(int tagNo) => tagNo >= 0 && tagNo < 0x1f;

Try / catch

if (tagNo >= 0x1f) { // fallback: parse contents directly
    return new Asn1InputStream(app.GetContents()).ReadObject(); }

Prevention

When it happens

Trigger: Calling appSpecific.GetObject(tagNo) with tagNo >= 31 (0x1f) — e.g. passing 0x1f itself, or accidentally passing a combined tag octet (class+constructed+tag) instead of just the tag number.

Common situations: Extracting the inner object of an APPLICATION element with a high-tag-number; passing an already-masked byte like 0x61 ('a') as a tag instead of its low 5 bits; protocol implementations using tags > 30.

Related errors


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