@girish a concrete follow-up to the layer discussion above, because I ran into a case where the "shared base gets old" effect matters more than the usual medium CVEs.
Ubuntu fixed a critical Ghostscript bug on 21 September (CVE-2026-39919, CVSS 9.8, a crafted PDF with a JPEG 2000 image can run code; USN-8791-1, fixed in 10.06.0~dfsg-3ubuntu1.1 on 26.04). On my servers the fix is in some images and not in others, also in images that were built weeks after the fix:
Image (build date)
Ghostscript
Nextcloud (16 Oct), Paperless-ngx (19 Oct), LAMP
10.06.0~dfsg-3ubuntu1.1 (fixed)
WordPress Developer (7 Oct), FreeScout (17 Oct), EspoCRM, HumHub, LimeSurvey, Matomo
10.06.0~dfsg-3ubuntu1
Roundcube, YOURLS, AdGuard Home (24.04)
10.02.1~dfsg1-0ubuntu7.8 (fix is 7.9)
The difference seems to be the shared PHP layer (the sury PHP_SERIES step with Imagick), which in these images was built on 20 September, one day before the fix. Apps that install Ghostscript again in their own layer (Nextcloud does apt-get install ghostscript ...) get the current version; apps that rely on the shared layer keep the old one, even when the app itself is rebuilt later.
For most of these apps it doesn't matter much, because they never feed a PDF to ImageMagick. WordPress is the exception: the policy.xml in the image allows PDF (the restrictive lines are in commented-out examples), and WordPress renders a preview for every PDF uploaded to the media library. I checked it in the container: a PDF read through Imagick goes straight to Ghostscript. So anyone with upload rights on a site (author and up) can reach it. Not anonymous, but on a platform with many editors that's still a real path.
This fits nicely with what you said about sharing layers: refreshing that one shared PHP layer when Ubuntu ships a fix for something in it would fix all of these apps at once, without each app needing its own upgrade step. Is there a cadence or trigger for rebuilding those shared layers, or is it tied to app releases for now?
For anyone who wants to close the WordPress path in the meantime: returning an empty array from the fallback_intermediate_image_sizes filter stops WordPress from rendering PDF previews, so uploads never reach Ghostscript (you only lose the PDF thumbnail in the media library).