Skip to content

Stop reading a device response past 8MiB (OCU-01-028) - #143

Closed
Dhirenderchoudhary wants to merge 3 commits into
OpenPrinting:masterfrom
Dhirenderchoudhary:fix-device-response-limit
Closed

Dhirenderchoudhary wants to merge 3 commits into
OpenPrinting:masterfrom
Dhirenderchoudhary:fix-device-response-limit

Conversation

@Dhirenderchoudhary

@Dhirenderchoudhary Dhirenderchoudhary commented Nov 4, 2026 •

Copy link
Copy Markdown

What this fixes

7ASecurity audit of OpenPrinting, finding OCU-01-028, WP3, Medium.

During initialization, ipp-usb retrieves IPP and eSCL capability responses from a connected device over HTTP. In the affected code paths, these responses are read with ioutil.ReadAll(resp.Body) before decoding, with no explicit upper bound on response size. This allows a malicious or malfunctioning USB device to trigger memory exhaustion by returning an excessively large response body or by streaming response data without a reasonable bound. Because ipp-usb continues allocating memory until the read completes or the process is terminated, the issue can result in a local denial of service during normal capability discovery after a hostile device is connected.

The changes

  • This PR stops the IPP and eSCL reads at 8MiB.
  • Review on the PR: cutting the read leaves the rest of the response on the USB connection, so the device is left mid-transfer. That is not a safe fix for this finding.

@alexpevzner

Copy link
Copy Markdown
Member

Is there any real device that can return more that 8 Mb when queried for the eSCL scanner capabilities or this is just a theoretical problem?

@Dhirenderchoudhary

Copy link
Copy Markdown
Author

@alexpevzner No real device returns that. The case I tested is a body that does not end, because ioutil.ReadAll has no limit. 8MB is just where I stopped it. A normal ScannerCapabilities is far under that. Tell me if you want a smaller number.

@alexpevzner

Copy link
Copy Markdown
Member

The problem is that if we stop reading, we will leave a device in the inconsistent state.

I don't consider this hypothetical problem to be serious. Unlike network connection, USB connection is under the user control, there is no too much chances that malicious device could be inserted into the USB socket.

But if this problem is to be approached seriously, the hard question in which state we will leave a weird-behavioring device should be answered.

One of the possible answers is the stream decoding of the received response. Though response itself is potentially unlimited, the amount of information that we are about to extract from there is limited.

But I'm not sure this purely hypothetical problem worses this level of effort and complexity.

@Dhirenderchoudhary

Dhirenderchoudhary commented Nov 4, 2026 •

Copy link
Copy Markdown
Author

You are right I didnt thought in this directiom.
Stopping the read leaves the rest of the response on the USB connection, so the device is left mid-transfer. I will drop the PR.

Thanks for the review

@Dhirenderchoudhary Dhirenderchoudhary changed the title Stop reading a device response past 8MiB Stop reading a device response past 8MiB (OCU-01-028) Nov 4, 2026
@alexpevzner

Copy link
Copy Markdown
Member

Anyway, thank you for the interest to this project and for the effort! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants