peass-ng/PEASS-ng · error · ArgumentException
byte value should have 1 byte in it
Error message
byte value should have 1 byte in it
What it means
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.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/DerBoolean.cs:66
public static DerBoolean GetInstance(
Asn1TaggedObject obj,
bool isExplicit)
{
Asn1Object o = obj.GetObject();
if (isExplicit || o is DerBoolean)
{
return GetInstance(o);
}
return FromOctetString(((Asn1OctetString)o).GetOctets());
}
public DerBoolean(
byte[] val)
{
if (val.Length != 1)
throw new ArgumentException("byte value should have 1 byte in it", "val");
// TODO Are there any constraints on the possible byte values?
this.value = val[0];
}
private DerBoolean(
bool value)
{
this.value = value ? (byte)0xff : (byte)0;
}
public bool IsTrue
{
get { return value != 0; }
}
internal override void Encode(
DerOutputStream derOut)View on GitHub (pinned to 53fb989abc)
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
Example fix
// before
var b = new DerBoolean(contentBytes);
// after
if (contentBytes.Length != 1) throw new FormatException("BOOLEAN must be 1 byte");
var b = new DerBoolean(contentBytes); Defensive patterns
Strategy: validation
Validate before calling
if (val == null || val.Length != 1) throw new FormatException("BOOLEAN content must be exactly 1 byte"); Type guard
bool IsValidBooleanBytes(byte[] b) => b != null && b.Length == 1;
Try / catch
try { var b = new DerBoolean(val); }
catch (ArgumentException) { /* reject record as malformed */ } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- unknown object encountered in constructed OCTET STRING:
- unknown tag {tagNo} encountered
- DER length more than 4 bytes:
- illegal object in GetInstance:
- BOOLEAN value should have 1 byte in it
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/d6b3d5247450359e.
Report an issue: GitHub.