Quick historical context: On April 13, 2026, a security advisory (DSA-6277-1) was released for the openjpeg2 package on Debian.
The issue was an integer overflow in the function opj_pi_initialise_encode inside src/lib/openjp2/pi.c. In simple terms, an attacker could feed a specially crafted JPEG 2000 image to any application using OpenJPEG, causing the library to crash (denial of service) or, in theory, run malicious code.
- Debian 12 (bookworm): 2.5.0-2+deb12u3
- Debian 13 (trixie): 2.5.3-2.1~deb13u2
1. How to check if you are vulnerable (Debian commands)
# 1. Check if openjpeg2 is installed at all dpkg -l | grep -E "openjpeg2|libopenjp2" # 2. Show exact installed version apt policy openjpeg2 # or apt show openjpeg2 2>/dev/null | grep Version # 3. Compare against the fixed version (Debian 12 bookworm) # Vulnerable if version < 2.5.0-2+deb12u3 apt-cache policy openjpeg2 | grep -A2 "Installed:"
Installed: 2.5.0-2+deb12u2 Candidate: 2.5.0-2+deb12u3
2. Automation script to apply the fix
#!/bin/bash # fix-openjpeg.sh - Automatically patches CVE-2026-6192 on Debian # Run as root on Debian 12 (bookworm) or 13 (trixie) set -e VULN_VERSION_12="2.5.0-2+deb12u2" FIXED_VERSION_12="2.5.0-2+deb12u3" VULN_VERSION_13="2.5.3-2.1~deb13u1" FIXED_VERSION_13="2.5.3-2.1~deb13u2" echo "[*] Checking current openjpeg2 version..." CURRENT=$(dpkg -l | grep -E "^ii.*openjpeg2" | awk '{print $3}') if [ -z "$CURRENT" ]; then echo "[!] openjpeg2 not installed. Nothing to fix." exit 0 fi echo "[*] Installed version: $CURRENT" # Detect Debian version DEBIAN_VER=$(lsb_release -sc) if [ "$DEBIAN_VER" = "bookworm" ]; then if dpkg --compare-versions "$CURRENT" ge "$FIXED_VERSION_12"; then echo "[✓] Already fixed (>= $FIXED_VERSION_12)." exit 0 else echo "[!] Vulnerable version detected. Patching..." apt update apt install --only-upgrade openjpeg2 -y echo "[✓] Update complete. Please reboot any services using libopenjp2 (e.g., web servers, image processors)." fi elif [ "$DEBIAN_VER" = "trixie" ]; then if dpkg --compare-versions "$CURRENT" ge "$FIXED_VERSION_13"; then echo "[✓] Already fixed (>= $FIXED_VERSION_13)." exit 0 else echo "[!] Vulnerable version detected. Patching..." apt update apt install --only-upgrade openjpeg2 -y echo "[✓] Update complete." fi else echo "[-] Unsupported Debian version: $DEBIAN_VER" echo " Check manually: https://security-tracker.debian.org/tracker/openjpeg2" exit 1 fi
3. Alternative mitigation if you can’t update right now
Option A: Restrict OpenJPEG via AppArmor
AppArmor restricts what the library (and the application that loads it) can do. Create a profile for any application that uses OpenJPEG (e.g., image converters, thumbnailers).
# Install AppArmor if missing sudo apt install apparmor apparmor-utils # Create a simple profile for a vulnerable binary sudo aa-genprof /usr/bin/your-image-processor # Follow the interactive prompts
/usr/bin/my-image-tool {
#include <abstractions/base>
#include <abstractions/nameservice>
# Allow only reading from /tmp and /var/uploads
/tmp/* r,
/var/uploads/* r,
# Deny writes except to specific logs
/var/log/myapp/* w,
# Block network entirely
deny network,
}
sudo apparmor_parser -r /etc/apparmor.d/usr.bin.my-image-tool sudo aa-enforce /usr/bin/my-image-tool
# Example: only process JPEG 2000 files that are well-formed if file "$IMAGE" | grep -q "JPEG 2000"; then # Extra: run through a validation tool if available opj_decompress -i "$IMAGE" -o /dev/null 2>&1 || { echo "Invalid image detected. Blocking." exit 1 } fi
# Block a specific attacker IP sudo iptables -A INPUT -s 203.0.113.45 -j DROP # Rate-limit new connections from any IP to port 80 (apache/nginx) sudo iptables -A INPUT -p tcp --dport 80 -m connlimit --connlimit-above 20 -j REJECT

Nenhum comentário:
Postar um comentário