Inspecting .deb files before installation: reader limits and ICU data

Inspect .deb contents before installation using ICU: archive size, the per-file bound and a controlled increase to the reader limit.

A paper archive unfolds from a green box between wooden limit bars.
A paper archive unfolds from a green box between wooden limit bars.

While moving PHP installation into our own CLI, a plan with ten selected components expanded into 53 new packages. The plan upgraded none of the existing packages. On the disposable Debian 13 VM, the download reached archive inspection and stopped before installation: one ICU file exceeded our reader’s limit.

Download size and file size measure different things

The intl extension needs ICU. In this plan, the libicu76 archive was 9,722,072 bytes, while its data file was 31,864,368 bytes. The original reader allowed 16 MiB per file, or 16,777,216 bytes. A package small enough to download exceeded this separate inspection limit.

MeasurementBytes
Compressed libicu76 archive9,722,072
Filesystem tar stream38,266,880
libicudata.so.76.131,864,368

These measurements belong to this particular run. Another package version may have different contents and sizes; the dependency definition should not hardcode these exact numbers.

Reading the contents without installing the package

We ran a check using dpkg-deb and Python in the VM console. Below is the same code expanded for readability, followed by its complete response. The example selects an already downloaded libicu76 archive from this fixture’s cache.

python3 -I -c '
import pathlib, subprocess, tarfile, io, json
p = next(pathlib.Path("/var/cache/apt/archives").glob("libicu76_*.deb"))
r = subprocess.run(
    ["/usr/bin/dpkg-deb", "--fsys-tarfile", str(p)],
    capture_output=True,
    check=True,
)
a = tarfile.open(fileobj=io.BytesIO(r.stdout), mode="r:")
print(json.dumps(dict(
    package="libicu76",
    tar_bytes=len(r.stdout),
    large_members=[dict(path=x.name, size=x.size) for x in a if x.size > 16777216],
)))
'
{"package": "libicu76", "tar_bytes": 38266880, "large_members": [{"path": "./usr/lib/x86_64-linux-gnu/libicudata.so.76.1", "size": 31864368}]}

The --fsys-tarfile option returns the package’s filesystem data as a tar stream. It is described in the dpkg-deb documentation. Here Python reads member headers and sizes; package files are not extracted into the root filesystem, and maintainer scripts do not run.

In this small diagnostic example, capture_output holds the tar stream in memory. The actual reader has separate limits for archive size, total uncompressed data, entry count and individual file size. This command should not be treated as a general processor for arbitrarily large or unknown archives.

Changing the reader’s budget

The full PHP profile now explicitly selects a 32 MiB per-file limit: 33,554,432 bytes. The overall tar-stream limit remains 64 MiB. The original reader mode keeps its 16 MiB per-file limit. The larger budget is selected by the role’s code, rather than an arbitrary field in operator JSON.

A local check using a test package built with dpkg-deb confirmed the distinction: the original mode refuses a 31,864,368-byte file, while the explicitly larger budget admits it. This checks the reader. It does not replace installing the complete PHP set again on a clean fixture.

Why APT authentication does not remove content limits

Byte provenance and the permitted amount of work are separate concerns. APT checks signed repository metadata and the checksums linked to it; it does not check a separate signature on every .deb. This chain is described in the apt-secure documentation. Our reader also checks the approved archive size and SHA256, then applies its own limits while reading.

After the stop, the cache contained all 53 approved archives, totalling 32,077,664 bytes. Their sizes and hashes matched the plan. The dpkg state matched the last completed operation: this run had not installed PHP. The operation journal and cache had already changed, so describing the entire attempt as having written nothing would be inaccurate.

We retained the pending journal and did not repeat apply against the same incomplete state. To check the correction, we prepared another clean VM and new approved plans.

Checking a real installation

The full PHP profile in the new run also included logrotate: the plan added 54 packages totalling 32,139,620 bytes without updating existing packages. Installation passed archive-content admission, and a separate SSH verification confirmed the completed state. The command below follows the executed invocation with generalized private paths; the variables contain values already reviewed.

deploy-cli host fpm packages-apply --joint-start-policy \
  --env-file "$PRIVATE_DIR/administrator.env" \
  --request-file "$PRIVATE_DIR/request.json" \
  --fpm-file "$PRIVATE_DIR/php-profile.json" \
  --key-file "$PRIVATE_DIR/repository.gpg" \
  --key-sha256 "$PUBLIC_KEY_SHA256" \
  --dependencies-file "$PRIVATE_DIR/php-packages-deps.json" \
  --plan-file "$PRIVATE_DIR/php-packages-plan.json" \
  --plan-sha256 "$APPROVED_PLAN_SHA256" --approve-privileges

Reduced actual receipt from the successful packages-apply:

{
  "status": "passed",
  "action": "packages-apply",
  "write_performed": true,
  "write_state": "changed",
  "access_verified": true
}

This confirms package installation under the new plan. Process readiness, PHP pools and HTTP requests are checked by subsequent separate CLI operations.

  1. Operations & Security Updating Debian: verification starts before installation
  2. Operations & Security Controlled PHP 8.5 installation on Debian 13
  3. Platform Engineering PHP runtime: extensions, owned INI and OPcache in FPM
  4. Platform Engineering Updating a configured Debian server: APT and a managed reboot

A project by the author · Weather Solution200

After reading, a look outside.

Temperature, rain and wind in your city. Check the forecast and plan the hours ahead.

Check the forecast
Next article