Skip to content

fix(bookworm): drop unusable C headers to clear linux-libc-dev CVEs - #502

Merged
sidey79 merged 1 commit into
devfrom
fix/strip-build-headers-bookworm
Sep 5, 2026
Merged

fix(bookworm): drop unusable C headers to clear linux-libc-dev CVEs#502
sidey79 merged 1 commit into
devfrom
fix/strip-build-headers-bookworm

Conversation

@sidey79

@sidey79 sidey79 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Problem

Trivy reports several CVEs against linux-libc-dev in the bookworm images, e.g.

CVE-2026-53138 │ HIGH │ fixed │ 6.1.176-1 │ 6.1.177-1
kernel: drm/amd/display: Bound VBIOS record-chain walk loops

The package does not come from this repository. It is inherited from the
upstream Perl base image, which ships a C header toolchain so that XS modules
can be compiled inside the container:

perl:5.38.5-slim-bookworm → libc6-dev, linux-libc-dev, libssl-dev,
                            zlib1g-dev, libcrypt-dev, libnsl-dev, ...

A fixed base tag will never arrive: the tag is pinned to Perl 5.38, which is
end-of-life upstream, so no rebuilt image is published.

The key observation is that the runtime image contains no C compiler
cc, gcc and g++ are all absent, only make is present. The headers can
therefore never be used for anything. They are roughly 36 MB of dead weight
that drags kernel and OpenSSL CVEs into every scan. linux-libc-dev contains
only .h files; the CVE concerns the host kernel, never the container.

Change

Applied to Dockerfile-bookworm and Dockerfile-threaded-bookworm:

  1. Purge the inherited header toolchain in the base-cpan stage:
    linux-libc-dev, libc6-dev, libcrypt-dev, libssl-dev, zlib1g-dev.
    Their auto-installed companions (libc-dev-bin, libnsl-dev,
    libtirpc-dev, rpcsvc-proto) are taken by the autoremove that already
    follows. The matching runtime libraries (libc6, libssl3, zlib1g,
    libarchive13) stay installed.
  2. libarchive-devlibarchive13. Only the runtime library was ever
    needed; no cpanfile requires the headers. The -dev package has been in
    here since the first bookworm Dockerfile without a consumer.
  3. Drop python3-dev. It would pull libc6-dev and thus linux-libc-dev
    straight back into the full image, and is equally unusable without a
    compiler.

The deprecated CPAN_PKGS / PIP_PKGS runtime install paths in entry.sh
could not build C extensions before this change either, for lack of a
compiler — pure-Perl and pure-Python packages are unaffected.

Scope

Bullseye is deliberately left untouched.

Worth noting separately: bullseye builds are currently broken for an unrelated,
pre-existing reason — deb.debian.org/debian-security returns 404 for
libperl5.32, avahi-daemon and libavahi-common-data since Debian 11 moved
to the archive.

Verification

The patched base-cpan stage was replayed against both real base images
(perl:5.38.5-slim-bookworm and perl:5.38.5-slim-threaded-bookworm):

Check bookworm threaded-bookworm
apt errors none none
remaining -dev packages none none
smoke test perl, IO::Socket::SSL, sqlite3, svn, mysql perl, sqlite3, svn
useithreads define

An earlier draft that also listed rpcsvc-proto was dropped: that package does
not exist in bullseye and apt-get purge aborts hard on an unknown name.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N3oE4DmgZNsmXsTtCP4Z45

The Perl base image ships a C header toolchain (libc6-dev, linux-libc-dev,
libssl-dev, zlib1g-dev, libcrypt-dev) so that XS modules can be compiled
inside the container. Our runtime image has no C compiler, so those headers
can never be used -- but Trivy keeps reporting kernel and OpenSSL CVEs
against them (e.g. CVE-2026-53138 on linux-libc-dev 6.1.176-1).

The fixed versions will never arrive: the base tag is pinned to Perl 5.38,
which is end-of-life upstream, so no rebuilt tag is published. Removing the
packages is therefore the only way to clear these findings, and it costs
nothing because they were already dead weight (~36 MB).

Alongside that:

- libarchive-dev -> libarchive13. Only the runtime library was ever needed;
  no cpanfile requires the headers. The -dev package has been in here since
  the first bookworm Dockerfile without a consumer.
- Drop python3-dev, which would pull libc6-dev and linux-libc-dev straight
  back into the full image and is equally unusable without a compiler.

The runtime libraries (libc6, libssl3, zlib1g, libarchive13) stay installed.
The deprecated CPAN_PKGS/PIP_PKGS runtime install paths in entry.sh could
not build C extensions before this change either, for lack of a compiler.

Bullseye is left untouched on purpose.

Verified by replaying the patched base-cpan stage against both bookworm base
images: no apt errors, no -dev packages left, and perl, IO::Socket::SSL,
sqlite3, svn and mysql still work (useithreads=define on the threaded image).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N3oE4DmgZNsmXsTtCP4Z45
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

CPAN Build Report -bookworm / 386

Artifact: cpan-inventory-bookworm-386

Excluded CPAN requirements for this image

  • core: Math::Pari, Crypt::Random, HiPi
  • 3rdparty: SNMP

core

  • Requirements: 139
  • Satisfied from local libs: 138
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

3rdparty

  • Requirements: 17
  • Satisfied from local libs: 16
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

all

  • Requirements: 144
  • Satisfied from local libs: 143
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

CPAN Build Report -bookworm / arm64

Artifact: cpan-inventory-bookworm-arm64

Excluded CPAN requirements for this image

  • core: Device::Firmata::Constants, HiPi
  • 3rdparty: Device::Firmata::Constants, SNMP

core

  • Requirements: 139
  • Satisfied from local libs: 138
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

3rdparty

  • Requirements: 17
  • Satisfied from local libs: 16
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

all

  • Requirements: 144
  • Satisfied from local libs: 143
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

CPAN Build Report -bookworm / arm/v7

Artifact: cpan-inventory-bookworm-arm-v7

Excluded CPAN requirements for this image

  • core: Device::Firmata::Constants, Math::Pari, Crypt::Random, HiPi
  • 3rdparty: Device::Firmata::Constants, SNMP

core

  • Requirements: 138
  • Satisfied from local libs: 137
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

3rdparty

  • Requirements: 17
  • Satisfied from local libs: 16
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

all

  • Requirements: 143
  • Satisfied from local libs: 142
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

CPAN Build Report -threaded-bookworm / arm/v7

Artifact: cpan-inventory-threaded-bookworm-arm-v7

Excluded CPAN requirements for this image

  • core: Device::Firmata::Constants, Math::Pari, Crypt::Random, HiPi
  • 3rdparty: Device::Firmata::Constants, SNMP

core

  • Requirements: 138
  • Satisfied from local libs: 137
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

3rdparty

  • Requirements: 17
  • Satisfied from local libs: 16
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

all

  • Requirements: 143
  • Satisfied from local libs: 142
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

CPAN Build Report -threaded-bookworm / 386

Artifact: cpan-inventory-threaded-bookworm-386

Excluded CPAN requirements for this image

  • core: Math::Pari, Crypt::Random, HiPi
  • 3rdparty: SNMP

core

  • Requirements: 139
  • Satisfied from local libs: 138
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

3rdparty

  • Requirements: 17
  • Satisfied from local libs: 16
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

all

  • Requirements: 144
  • Satisfied from local libs: 143
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

CPAN Build Report -threaded-bookworm / arm64

Artifact: cpan-inventory-threaded-bookworm-arm64

Excluded CPAN requirements for this image

  • core: Device::Firmata::Constants, HiPi
  • 3rdparty: Device::Firmata::Constants, SNMP

core

  • Requirements: 139
  • Satisfied from local libs: 138
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

3rdparty

  • Requirements: 17
  • Satisfied from local libs: 16
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

all

  • Requirements: 144
  • Satisfied from local libs: 143
  • Satisfied from core/base: 1
  • Missing probable install failures: 0
  • Unresolved requirements: 0
  • Version mismatches: 0

@sidey79
sidey79 merged commit d7ec2f4 into dev Sep 5, 2026
30 checks passed
@sidey79
sidey79 deleted the fix/strip-build-headers-bookworm branch September 5, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant