peass-ng/PEASS-ng · error · StreamOverflowException
Data Overflow
Error message
Data Overflow
What it means
Streams.PipeAllLimited copies at most `limit` bytes from inStr to outStr. If reading more bytes would exceed the limit, it throws StreamOverflowException('Data Overflow'). This protects against unbounded input (decompression bombs, huge payloads) exhausting memory or disk.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/util/io/Streams.cs:86
/// A <see cref="Stream"/>
/// </param>
/// <param name="limit">
/// A <see cref="System.Int64"/>
/// </param>
/// <param name="outStr">
/// A <see cref="Stream"/>
/// </param>
/// <returns>The number of bytes actually transferred, if not greater than <c>limit</c></returns>
/// <exception cref="IOException"></exception>
public static long PipeAllLimited(Stream inStr, long limit, Stream outStr)
{
byte[] bs = new byte[BufferSize];
long total = 0;
int numRead;
while ((numRead = inStr.Read(bs, 0, bs.Length)) > 0)
{
if ((limit - total) < numRead)
throw new StreamOverflowException("Data Overflow");
total += numRead;
outStr.Write(bs, 0, numRead);
}
return total;
}
/// <exception cref="IOException"></exception>
public static void WriteBufTo(MemoryStream buf, Stream output)
{
buf.WriteTo(output);
}
/// <exception cref="IOException"></exception>
public static int WriteBufTo(MemoryStream buf, byte[] output, int offset)
{
#if PORTABLE
byte[] bytes = buf.ToArray();
bytes.CopyTo(output, offset);View on GitHub (pinned to 53fb989abc)
Solutions
- Raise the limit parameter to a value above the legitimate maximum expected size.
- Pre-check the source length (stream.Length if seekable) against the limit before piping.
- Treat the exception as a guard: reject the input as oversized rather than increasing limits blindly for untrusted data.
- Read in bounded chunks yourself and enforce your own policy (truncate, reject, or stream to disk).
Example fix
// before
Streams.PipeAllLimited(input, 1024, output); // input has 4096 bytes
// after
long max = input.CanSeek ? input.Length : long.MaxValue;
if (max > 1024) throw new InvalidOperationException("payload too large");
Streams.PipeAllLimited(input, 1024, output); Defensive patterns
Strategy: try-catch
Validate before calling
if (input.CanSeek && input.Length > limit) throw new InvalidOperationException("stream exceeds limit"); Type guard
static bool WithinLimit(Stream s, long limit) => !s.CanSeek || s.Length <= limit;
Try / catch
try { Streams.PipeAllLimited(inStr, limit, outStr); } catch (StreamOverflowException) { throw new PayloadTooLargeException(limit); } Prevention
- Set limits above the legitimate maximum with headroom
- Pre-check stream length when seekable
- Treat overflow of untrusted input as rejection, not a limit to raise
When it happens
Trigger: Calling PipeAllLimited (directly or via ReadAllLimited) on a stream whose total readable bytes exceed the configured limit — e.g. limit=1024 but the stream delivers 2000 bytes.
Common situations: Reading decompressed data larger than an expected maximum; parsing attacker-controlled embedded blobs; processing files bigger than an application-enforced cap.
Related errors
- invalid characters encountered in Hex data
- A maximum of 32 parameters can be supplied to RunEx.
- drivePath
- Resources.InvalidDriveLetterArgument
- driveName
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/ac78a7a42cc35563.
Report an issue: GitHub.