Public bug reported:

# hplip 3.23.12+dfsg0-0ubuntu5.3: network scanning broken via hpaio —
false "response exceeds buffer" in http_read()

**Package:** hplip / libsane-hpaio
**Ubuntu:** 24.04.5 LTS (noble)
**Severity:** high — all HP HTTP-based network scanning via the `hpaio` SANE 
backend is broken
**Status:** workaround exists (`sane-airscan`), no fix available in the package

---

## Summary

After the `hplip 3.23.12+dfsg0-0ubuntu5.1 -> 3.23.12+dfsg0-0ubuntu5.3` security 
update, the `hpaio`
SANE backend cannot open any network scanner. Every attempt fails immediately 
with
`Error during device I/O`. The underlying error, written to syslog, is:

```
scan/sane/http.c 501: http_read: response exceeds buffer (read=8183 len=51 
max=8192)
```

The bounds check that produces this error was **newly introduced** by the update
(`debian/patches/CVE-2026-91XXX.patch`, CVE-2026-91097..91106, HP advisory 
HPSBPI04151,
backported from HPLIP 3.26.6). The check mis-counts the bytes it has buffered 
and aborts
responses that comfortably fit inside the buffer. On this device it fires when 
the real HTTP
response is 5964 bytes and the limit is 8192.

This is a regression introduced by hardening, not a genuine overflow, and not a 
device or
network problem.

---

## Affected system

| | |
|---|---|
| Hostname | redacted-host.example.invalid |
| OS | Ubuntu 24.04.5 LTS (noble), amd64 |
| Kernel | 6.8.0-149-generic (also fails on 6.8.0-147 — kernel is not a factor) 
|
| hplip / libhpmud0 / libsane-hpaio | 3.23.12+dfsg0-0ubuntu5.3 |
| sane-utils / libsane1 | 1.2.1-7build4 (unchanged) |
| sane-airscan | 0.99.29-0ubuntu4 (unchanged, **works**) |
| Frontend | simple-scan (GNOME Document Scanner) |

## Affected device

| | |
|---|---|
| Model | HP OfficeJet Pro 7740 Wide Format All-in-One (G5J38A) |
| Serial | CN08P550QN |
| Firmware | `{EDWINXPP1N002.2615B.00}`, built Fri Apr 10 2026 |
| Connection | Ethernet/Wi-Fi, static IP 192.168.1.150 (**not USB**) |

Device is healthy and reachable: 0% packet loss, and the `airscan` (eSCL) 
backend scans from it
normally — flatbed and ADF both produce valid output. Only `hpaio` is broken.

---

## Steps to reproduce

On a stock install with `hpaio` enabled in `/etc/sane.d/dll.d/hplip`:

```sh
scanimage -d 'hpaio:/net/OfficeJet_Pro_7740_series?ip=192.168.1.150' \
          --resolution=75 --mode=Gray --format=png -o /tmp/out.png
echo "exit=$?"
```

Reproduced 4/4 attempts, deterministically, from `scanimage` and from
`simple-scan`.

### Expected

A PNG is written and the exit status is 0.

### Actual

```
scanimage: open of device hpaio:/net/OfficeJet_Pro_7740_series?ip=192.168.1.150 
failed: Error during device I/O
exit=1
```

No output file is created. The device is never calibrated; the failure is in 
the capability
handshake.

---

## Debug trace

### `SANE_DEBUG_HPAIO=255`

```
[sanei_debug] Setting debug level of hpaio to 255.
[hpaio] sane_hpaio_init(): scan/sane/hpaio.c 357
[hpaio] sane_hpaio_open(/net/OfficeJet_Pro_7740_series?ip=192.168.1.150): 
scan/sane/hpaio.c 396 scan_type=7 scansrc=3
scanimage: open of device hpaio:/net/OfficeJet_Pro_7740_series?ip=192.168.1.150 
failed: Error during device I/O
[hpaio] sane_hpaio_exit(): scan/sane/hpaio.c 372
```

hpaio's own debug output stops at `sane_hpaio_open`; the real diagnostic
is in syslog.

### syslog (`/var/log/syslog`), four consecutive attempts

```
2026-11-15T19:42:54.624152-05:00 redacted-host scanimage: scan/sane/http.c 501: 
http_read: response exceeds buffer (read=8183 len=51 max=8192)
2026-11-15T19:56:33.936513-05:00 redacted-host scanimage: scan/sane/http.c 501: 
http_read: response exceeds buffer (read=8183 len=51 max=8192)
2026-11-15T19:56:46.168360-05:00 redacted-host scanimage: scan/sane/http.c 501: 
http_read: response exceeds buffer (read=8183 len=51 max=8192)
2026-11-15T19:57:10.673458-05:00 redacted-host scanimage: scan/sane/http.c 501: 
http_read: response exceeds buffer (read=8183 len=51 max=8192)
```

Note the values are byte-identical every time: 8183 + 51 = 8234 bytes required, 
against
`max=8192`.

### strace — the exchange fails *after* a successful HTTP 200

```
socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)         = 4
sendmsg(4, {sa_family=AF_INET, sin_port=htons(161), 
sin_addr=inet_addr("192.168.1.150")}, MSG_DONTWAIT) = 48
recvmsg(4, {...sin_port=htons(161), sin_addr=inet_addr("192.168.1.150")...}, 
MSG_DONTWAIT) = 416   # SNMP OK
socket(AF_INET, SOCK_STREAM, IPPROTO_IP)        = 4
connect(4, {sa_family=AF_INET, sin_port=htons(8080), 
sin_addr=inet_addr("192.168.1.150")}, 16) = 0  # TCP OK
sendto(4, "GET /Scan/ScanCaps HTTP/1.1\r\nHos"..., 214, 0, NULL, 0) = 214
recvfrom(4, "HTTP/1.1 200 OK\r\nServer: HP HTTP"..., 4096, 0, NULL, NULL) = 280
recvfrom(4, "FD6\r\n<?xml version=\"1.0\" encodin"..., 4096, 0, NULL, NULL) = 
4061
recvfrom(4, "64B\r\nMaxOpticalXResolution>300</"..., 4096, 0, NULL, NULL) = 1623
read(5, "TZif2\0\0\0...", 4096) = 3552
connect(5, {sa_family=AF_UNIX, sun_path="/dev/log"}, 110) = 0
sendto(5, "<11>Nov 15 19:57:10 scanimage: s"..., 116, MSG_NOSIGNAL, NULL, 0) = 
116   # the BUG() above
write(2, "scanimage: open of device hpaio:"..., 112) = 112
+++ exited with 1 +++
```

The device answers the capability request with **HTTP 200 OK**. The connection 
is not refused,
not reset, not timed out. `http_read()` rejects a perfectly good response.

### hpaio's exact request, captured and replayed

```
GET /Scan/ScanCaps HTTP/1.1
Host: 192.168.1.150
User-Agent: hplip
Accept: text/xml
Accept-Language: en-us,en
Accept-Charset:utf-8
Keep-Alive: 20
Proxy-Connection: keep-alive
Cookie: AccessCounter=new
```

Replaying this request byte-for-byte against the device:

```
HTTP/1.1 200 OK
Content-Type: text/xml
Transfer-Encoding: chunked

total wire bytes (headers + chunked framing): 5964
  headers                        :  276
  body + framing                 : 5684
http.c buffer limit              : 8192
verdict                          : UNDER the limit by 2228 bytes
hpaio actually counted           : 8183 (+51 wanted) = 8234
```

**The response is 5964 bytes. The buffer holds 8192. `http_read()` counts 
8183.** The guard fires
roughly 2.2 kB early and rejects a response that fits with ~27% to spare.

---

## Root cause

`0ubuntu5.3` adds `debian/patches/CVE-2026-91XXX.patch`
(`Bug-Debian: 1148269`, `Last-Update: 2026-11-04`, backported from HPLIP 
3.26.6).
In `scan/sane/http.c`, inside `http_read()`, it replaces two unchecked 
`strcpy()` calls with a
bounds check and a `memcpy()`. The first hunk (around line 473):

```diff
-                    strcpy(data, line);
+                    if (*bytes_read + len > max_size)
+                    {
+                       BUG("http_read: response exceeds buffer (read=%d len=%d 
max=%d)\n", *bytes_read, len, max_size);
+                       stat = HTTP_R_IO_ERROR;
+                       goto bugout;
+                    }
+                    memcpy(data, line, len);
                     data=data+len;
                     ps->footer -= len;
              *bytes_read += len;
```

The second hunk (around line 496) is where `*bytes_read` is incremented for the 
first time —
note the added line at the bottom:

```diff
-            strcpy(data, line);
+            if (*bytes_read + len > max_size)
+            {
+               BUG("http_read: response exceeds buffer (read=%d len=%d 
max=%d)\n", *bytes_read, len, max_size);
+               stat = HTTP_R_IO_ERROR;
+               goto bugout;
+            }
+            memcpy(data, line, len);
             data = data + len;
+            *bytes_read += len;
             DBG("http_read len=%d datalen=%d data=%s\n", len, 
strlen((char*)data), (char*)data);
```

Before the patch, `*bytes_read` was only maintained in the first branch, and 
nothing checked it,
so an inflated counter was harmless. After the patch **both** branches 
increment `*bytes_read` and
**both** test it against `max_size`, so bytes reachable through both paths are 
counted twice. That
is consistent with the measured overshoot: 8183 counted vs 5964 actually 
transferred.

Two things worth reviewing:

1. The `*bytes_read += len` added in the second hunk appears to double-count 
against the
   accounting already performed in the first branch, producing false 
`HTTP_R_IO_ERROR` aborts.
   Either the increment is duplicated, or `max_size` is being passed as 
remaining-space where the
   new check assumes total capacity.
2. `strcpy(data, line)` -> `memcpy(data, line, len)` drops the NUL terminator 
while `data` is
   advanced by exactly `len`. The `DBG()` on the immediately following line 
calls
   `strlen((char*)data)` on it. That looks like an uninitialised/out-of-bounds 
read on the debug
   path, and any consumer expecting a terminated string is exposed. Worth 
confirming there is a
   terminator written elsewhere.

## Blast radius

`CVE-2026-91XXX.patch` touches 50 files, including 10 under
`scan/sane/`:

`bb_ledm.c`, `escl.c`, **`http.c`**, `ledm.c`, `marvell.c`, `mfpdtf.c`, 
`sclpml.c`, `soap.c`,
`soapht.c`, `xml.c`

`http.c`'s `http_read()` is the shared HTTP transport for the LEDM, Marvell, 
MFPDTF, SCLPML,
SOAP and eSCL backends. This is unlikely to be limited to the OfficeJet Pro 
7740 — any HP
multi-function device scanned over the network through `hpaio` is exposed to 
the same false abort.

## Ruled out

* **Network / device health** — 0% packet loss; SNMP/161 answers; TCP/8080 
connects and returns
  `200 OK`.
* **Firewall or closed port** — `hpaio` uses UDP/161 and TCP/8080 here. The 
legacy HP channel on
  tcp/60000 is closed on this device, but `strace` shows `hpaio` never attempts 
it, so it is not
  implicated.
* **Kernel / udev** — device is network-attached; also fails identically on the 
previous kernel.
* **SANE core** — `sane-utils`/`libsane1` were not updated (still 
`1.2.1-7build4`) and
  `sane-airscan` scans the same device successfully.

---

## Workaround (tested, no packaging change required)

`sane-airscan` reaches the same hardware over eSCL and is unaffected. On this 
machine the broken
backend was hidden so frontends cannot select it:

```sh
sudo sed -i 's/^hpaio/#hpaio/' /etc/sane.d/dll.d/hplip
```

After this, `scanimage -L` lists only the working device and scanning is
fully restored:

```
device `airscan:e1:HP OfficeJet Pro 7740 series [B85ADA]' is a eSCL HP 
OfficeJet Pro 7740 series [B85ADA] ip=192.168.1.150
```

Verified with real captures: flatbed at 300 dpi -> 877907-byte valid PDF; ADF 
at 200 dpi ->
409575-byte valid PDF. Both exit 0. Caveat: this hides the HPLIP-only features 
(fax, some
supplies diagnostics via `hpaio`) and must be re-applied after a 
`--force-confnew` upgrade of
`libsane-hpaio`.

## Suggested fix

Correct the `*bytes_read` accounting in `http_read()` so the new guard measures 
the same quantity
the caller's buffer actually reserves, and re-test against a device whose 
`/Scan/ScanCaps`
response exceeds a few kilobytes. A cheap regression test: assert that a 200 OK 
response smaller
than `max_size` never yields `HTTP_R_IO_ERROR`.

Given the regression disables network scanning outright, a corrected 
`-0ubuntu5.4` (or a
temporarily relaxed bound) would be worth considering for 
noble-updates/noble-security.

## Version / bisection notes

* Working: `3.23.12+dfsg0-0ubuntu5.1` (installed until 2026-11-10 23:47)
* Broken: `3.23.12+dfsg0-0ubuntu5.3`
* There is no `0ubuntu5.2`.

The causal link is established from the patch itself rather than from a runtime 
bisect: the file,
line and message in the failure (`scan/sane/http.c:501`, `http_read: response 
exceeds buffer`)
exist **only** in `CVE-2026-91XXX.patch`, which is new in `0ubuntu5.3`. I could 
not reinstall
`0ubuntu5.1` to confirm the A/B directly — that version is no longer published. 
The pool returns
404 for it and `apt` reports the version as not found:

```
$ apt-get install --allow-downgrades libsane-hpaio=3.23.12+dfsg0-0ubuntu5.1
E: Version '3.23.12+dfsg0-0ubuntu5.1' for 'libsane-hpaio' was not found

$ curl -I 
http://us.archive.ubuntu.com/ubuntu/pool/main/h/hplip/libsane-hpaio_3.23.12+dfsg0-0ubuntu5.1_amd64.deb
404
```

## Data redaction

The attached Apport report and the traces here have been scrubbed of 
site-identifying data before
upload: hostnames and DNS domain, all four MAC addresses present (wired NIC, 
wireless adapter,
two access-point BSSIDs), the desktop machine model, the local username and 
home path as they
appear in AppArmor audit lines, and an NFS export name. Placeholders are 
format-preserving
(`aa:bb:cc:dd:ee:0N` for MACs), so nothing structural is lost. Deliberately 
retained because they
aid reproduction: the RFC1918 scanner address `192.168.1.150`, the printer 
model and firmware
string, and all HTTP/SNMP behaviour. See `SCRUB-NOTES.txt` for the exact 
substitution list. This
is why `MachineType` reads `REDACTED-MODEL` rather than a product name.

## Attachments to include

All present in `/home/tony/hplip-bug-attachments/`:

* `hplip-apport-report.txt` — full Apport report, collected with
  `apport-cli --package hplip --file-bug --save` (1.06 MB, scrubbed; unmodified 
original in
  `pre-scrub-original/`)
* `trace_hpaio_open.log` — `SANE_DEBUG_HPAIO=255` run
* `trace_full.log` — `strace -f -s 4096 -e trace=network` of the failing open
* `trace_strace_fullsyscalls.log` — wider strace (network, read/write, poll)
* `scancaps.xml` — device's `/Scan/ScanCaps` response (5665-byte body, 
retrieved out of band)
* `hpaio_request.raw` — the exact 214-byte request `hpaio` sends
* `hplip_3.23.12+dfsg0-0ubuntu5.3.debian.tar.xz` vs `-0ubuntu5` — patch delta
* `syslog-excerpts.txt` — the `http_read` failures above
* `SCRUB-NOTES.txt` — redaction manifest

---

*Report prepared on the affected machine; every command above was run as stated 
and the traces are
verbatim.*

** Affects: hplip (Ubuntu)
     Importance: Undecided
         Status: New

** Attachment added: "UbuntuBug.zip"
   
https://bugs.launchpad.net/bugs/2174557/+attachment/6018367/+files/UbuntuBug.zip

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2174557

Title:
  hplip-scan-regression-ubuntu-bug - hplip 3.23.12+dfsg0-0ubuntu5.3:
  network scanning broken via hpaio — false "response exceeds buffer" in
  http_read()

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/hplip/+bug/2174557/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to