π ~4 min read β’ Source: Debian Security Tracker
Related CVEs: CVE-2004-0941 CVE-2004-0990 CVE-2006-2906 CVE-2006-4484 CVE-2007-0455 CVE-2007-1001 CVE-2007-2445 CVE-2007-2756 +12 more
Upstream summary: Multiple buffer overflows in the gd graphics library (libgd) 2.0.21 and earlier may allow remote attackers to execute arbitrary code via malformed image files that trigger the overflows due to improper calls to the gdMalloc function, a different set of vulnerabilities than CVE-2004-0990.
Table of contents
Symptom & Impact
On Debian 12 hosts running libgd2, administrators observe behaviour consistent with the Debian Security Tracker entry: apt refusing to install or restart affected services, and β for security-rated advisories β exposure to the vulnerability set above. Impact ranges from a single service restart to wider availability incidents whenever libgd2 sits on the serving path.
Environment & Reproduction
Reproduction targets Debian 12. Confirm release with cat /etc/debian_version and lsb_release -a, and the currently installed package with dpkg -l libgd2 and apt-cache policy libgd2. Capture system state with sudo reportbug libgd2 if you need to file upstream. Trigger the workflow that exposes libgd2 β multiple vulnerabilities (20 CVEs) β patch and remediation guide while collecting journalctl -b, /var/log/apt/history.log, and dpkg -l output.
Root Cause Analysis
Root cause is tracked at Debian Security Tracker. The Debian Security Team shipped fixes in the corresponding libgd2 point release for Debian 12; running an outdated build leaves the host exposed to the failure modes referenced above. Correlate journalctl --since with apt history (/var/log/apt/history.log) and any kernel taint flags in /proc/sys/kernel/tainted to isolate the originating change.
Quick Triage
Quick triage: systemctl status libgd2, journalctl -u libgd2 -n 200, sudo apt update && apt list --upgradable, sudo nft list ruleset (or sudo iptables -L), and sudo dpkg --audit. For kernel issues review journalctl -k --since "1 hour ago".
Step-by-Step Diagnosis
1) systemctl --failed. 2) journalctl -xe and journalctl -u libgd2. 3) Validate firewall: sudo nft list ruleset or sudo iptables -L -n -v. 4) dpkg -V libgd2 for integrity. 5) sudo apt install --reinstall libgd2 if files were tampered. 6) Correlate findings with /var/log/apt/history.log, /var/log/dpkg.log, and Debian Security Tracker to pin the change that introduced libgd2 β multiple vulnerabilities (20 CVEs) β patch and remediation guide.
Solution – Primary Fix
Primary fix: apply the corrective apt transaction documented in Debian Security Tracker, then reload the affected systemd unit. Typical commands: sudo apt update, sudo apt -y install --only-upgrade libgd2 (or sudo unattended-upgrade -v), sudo systemctl daemon-reload, sudo systemctl restart libgd2, then dpkg -l libgd2 to validate the new build is installed. For kernel advisories add sudo reboot.
Need help rolling this patch across a Debian fleet? Our IT Solutions & Services team manages Debian patch windows with zero-downtime change controls. Get in touch for a free consultation.
Solution – Alternative Approaches
Alternatives include pinning a known-good version via /etc/apt/preferences.d/libgd2.pref, holding the package with sudo apt-mark hold libgd2, rolling back with sudo apt install libgd2=<old-version>, switching firewall backends between iptables-legacy and nftables via update-alternatives --config iptables, or applying the patch from the security archive only β deb debian-12-security main contrib non-free β while delaying the full point-release upgrade.
Verification & Acceptance Criteria
Acceptance: dpkg -l libgd2 shows the expected fixed version, systemctl is-active libgd2 is active, journalctl -u libgd2 --since "5 minutes ago" shows no errors, apt list --upgradable no longer lists the advisory, sudo nft list ruleset matches the intended policy, and the original reproduction steps for libgd2 β multiple vulnerabilities (20 CVEs) β patch and remediation guide no longer trigger the failure across two consecutive runs.
Rollback Plan
Capture state with apt list --installed > /root/apt-pre.txt and dpkg --get-selections > /root/dpkg-pre.txt. To revert, run sudo apt install --allow-downgrades libgd2=<old-version> and reload systemctl daemon-reload. Reboot if the kernel or initramfs changed and re-verify symptoms. Where LVM snapshots are in use, sudo lvconvert --merge /dev/<vg>/preupgrade is the fastest rollback path.
Prevention & Hardening
Prevent recurrence by enabling unattended-upgrades with Unattended-Upgrade::Origins-Pattern tuned to origin=Debian,codename=${distro_codename},label=Debian-Security, subscribing to debian-security-announce, mirroring through a local apt-mirror or aptly repo for controlled rollouts, version-locking sensitive packages, and monitoring file integrity with debsums -c or aide --check. Apply CIS Debian hardening and keep needrestart installed so service restarts happen automatically after library upgrades.
Related Errors & Cross-Refs
Related issues that commonly surface alongside libgd2 β multiple vulnerabilities (20 CVEs) β patch and remediation guide: apt lock contention (dpkg --configure -a), systemd unit ordering cycles, firewall rule drift, and kernel taint flags in cat /proc/sys/kernel/tainted. See sibling common-problem articles in this Debian 12 series for adjacent failure modes.
View all debian-12 tutorials on the Tutorials Hub β
Browse all common problems & solutions on the Tutorials Hub.
References & Further Reading
Primary reference: Debian Security Tracker. Supporting docs: Debian Administrators Handbook, man apt, man systemctl, man nft, man iptables, man journalctl, man debsums, the Debian Security Tracker at security-tracker.debian.org, and Debian Security FAQ at debian.org/security/faq. Review /usr/share/doc/libgd2/ for component-level notes implicated in libgd2 β multiple vulnerabilities (20 CVEs) β patch and remediation guide.