Skip to main content

Vulnerability scanning

LibrePhotos keeps zero known vulnerabilities in its dependencies and in its five images (librephotos-base, librephotos, librephotos-unified, librephotos-frontend and librephotos-proxy): every severity, with or without a released fix. Three workflows check this, and a pull request that adds a known vulnerability fails. "Zero" means zero that the scanners can match; a few components in the backend images are compiled from source and invisible to them, see What the image scan cannot see.

What is scanned​

WorkflowScannerWhatWhen
scan-dependencies.ymlosv-scannerEvery lockfile and requirements file in the repository (package-lock.json, the yarn.lock files, Cargo.lock, bun.lock, requirements*.txt)Every pull request, every push to dev, daily, and on demand
scan-dependencies.ymlosv-scannerThe backend's resolved Python environment: what pip installs from requirements.txt, requirements.unified.txt and requirements.nodeps.txt on Linux with Python 3.14, transitive packages includedSame
scan-images.ymlTrivyThe frontend and proxy images, built from the pull request and not pushedPull requests that change deploy/docker/frontend/, deploy/docker/proxy/ or .trivyignore.yaml
image-backend-check.ymlTrivylibrephotos-base and librephotos, the images this workflow already builds from the pull request on linux/amd64 and linux/arm64 (nothing is pushed)Pull requests that change deploy/docker/backend/, requirements.txt, requirements.nodeps.txt, requirements.unified.txt or .trivyignore.yaml
scan-images.ymlTrivyThe published :dev of all five images (reallibrephotos/librephotos-frontend, -proxy, -base, reallibrephotos/librephotos and -unified), on linux/amd64 and linux/arm64Daily, and on demand

The image workflows that publish (image-frontend.yml, image-proxy.yml, image-backend-base.yml, image-backend.yml, image-unified.yml) do not scan. A vulnerability disclosed after a merge must not block a dev build or a release; the daily scan of the published images is the alarm, and a failed scheduled run notifies the maintainers.

No pull request builds librephotos-unified. It is librephotos-base with the same requirements.txt and requirements.nodeps.txt as librephotos, plus requirements.unified.txt (WhiteNoise, which osv-scanner checks on every pull request) and the frontend's static files, so the pull request scans cover what it contains; the daily scan checks the published image itself.

Why --no-resolve​

osv-scanner reads requirements*.txt as manifests and by default asks deps.dev to resolve their transitive dependencies. That resolver compares Python versions as strings and reports old versions nobody installs, and it would add the dependencies of the packages in requirements.nodeps.txt, which are installed with --no-deps and never pulled in. So the workflow scans the files with --no-resolve, which checks exactly the pinned lines, and covers the transitive packages with the second scan: pip install --dry-run --report resolves the environment as the images install it, without installing it, and osv-scanner checks every package pip would take from PyPI. The wheels LibrePhotos builds itself (exiftool-bin, ffmpeg-bin, opencv-lp-headless) come from GitHub releases and are not looked up on PyPI.

Running the scans locally​

Use the versions the workflows pin (OSV_SCANNER_VERSION in scan-dependencies.yml, TRIVY_VERSION in scan-images.yml and image-backend-check.yml). From the repository root:

osv-scanner scan source --recursive --no-resolve --config osv-scanner.toml .

The resolved Python environment, from apps/backend (on Linux with Python 3.14, as in the workflow, or in a python:3.14-slim container on other systems):

python -m pip install --dry-run --ignore-installed --quiet --report /tmp/full.json \
-r requirements.txt -r requirements.unified.txt
python -m pip install --dry-run --ignore-installed --quiet --no-deps --report /tmp/nodeps.json \
-r requirements.nodeps.txt

Then write the name==version of every installed item whose download_info.url is on files.pythonhosted.org into a file named requirements.txt (the workflow does it with a few lines of Python) and scan it with osv-scanner scan source --no-resolve --config ../../osv-scanner.toml --lockfile <dir>/requirements.txt.

An image, built from the repository root:

docker build -f deploy/docker/proxy/Dockerfile -t librephotos-proxy:scan .
trivy image --scanners vuln --exit-code 1 --ignorefile .trivyignore.yaml librephotos-proxy:scan

The backend images build FROM reallibrephotos/librephotos-base:${BASE_TAG}, so build the base first and pass its tag:

docker build -t reallibrephotos/librephotos-base:scan deploy/docker/backend/base
docker build -f deploy/docker/backend/Dockerfile --build-arg BASE_TAG=scan -t librephotos-backend:scan .
trivy image --scanners vuln --exit-code 1 --ignorefile .trivyignore.yaml librephotos-backend:scan

The base compiles Mesa, which takes about 20 minutes on 12 threads the first time; later builds reuse the cached stages as long as the ARGs of those stages do not change.

A published image, without pulling it:

trivy image --scanners vuln --image-src remote --platform linux/arm64 \
--ignorefile .trivyignore.yaml reallibrephotos/librephotos-frontend:dev

When a scan fails​

  1. Update. Most findings have a fixed version: take the Renovate pull request, or bump the package by hand (in a lockfile, an override or resolution, or an exact pin in requirements.txt for a Python package that is only a transitive dependency). Do not raise a severity threshold or skip unfixed findings to get green.
  2. Rebuild the image. When the published :dev image fails but the Dockerfile is fine, the fix has usually been released in Alpine or Go since the image was built. Run image-frontend or image-proxy from the Actions tab (Run workflow on dev): the proxy build runs apk upgrade, and the frontend build compiles its file server with the current Go of the golang image it names. For the backend images the fix is usually a newer Wolfi package: run image-backend-base, wait for it to finish, then run image-backend and image-unified, which build on the new librephotos-base:dev. The base build reuses its cached Mesa, SPIRV-LLVM-Translator and Brotli stages but always rebuilds its final runtime stage, so apk add takes the current Wolfi packages.
  3. Ignore, with an expiry, only what cannot be fixed yet. When no fixed version exists, or the fix is blocked upstream, add the finding to the scanner's ignore file with a date at most six months away and a reason that names the upstream blocker (the issue or pull request to wait for). An expired entry fails the scan again, so the decision gets made again. apps/backend/api/tests/infra/test_web_images.py fails on an entry without an expiry, with one more than six months away, or without a reason.

For osv-scanner, in osv-scanner.toml at the repository root:

[[IgnoredVulns]]
id = "RUSTSEC-2024-0429"
effectiveUntil = 2027-03-01T00:00:00Z
reason = "glib 0.18.5 comes from tauri 2.12's gtk 0.18 stack. Blocked until tauri ships tauri-apps/tauri#16170 (tauri 2.13)."

For Trivy, in .trivyignore.yaml at the repository root:

vulnerabilities:
- id: CVE-2026-12345
statement: "No fixed zlib in Alpine 3.24 yet; waiting for the aports issue that tracks it (link it here)."
expired_at: 2027-03-01

osv-scanner prints the ignores it no longer needs as "unused ignores". Remove them when the blocker is gone.

The ignores in osv-scanner.toml today are all notices against apps/desktop/src-tauri/Cargo.lock, waiting for tauri and its plugins:

IdsCrateBlocked by
RUSTSEC-2024-0429, RUSTSEC-2024-0370glib 0.18, proc-macro-errortauri 2.12 is on gtk-rs 0.18; tauri-apps/tauri#16170 moves it to 0.19 (tauri 2.13)
RUSTSEC-2026-0370, RUSTSEC-2026-0371, RUSTSEC-2026-0372zvariant, zbus_names, zvariant_derivetauri-plugin-single-instance needs zbus 5; tauri-apps/plugins-workspace#3759 moves it to zbus 6
RUSTSEC-2026-0543chronoAn optional dependency of serde_with that nothing enables: it is in the lockfile but never compiled (cargo tree -i chrono --target all -e all prints nothing)

Updating the scanners​

The workflows download osv-scanner and Trivy from their GitHub releases and check them against a SHA-256 written next to the version, so a replaced release asset cannot run in CI. Renovate opens a pull request for a new release of either, outside the github-actions group and never automerged, but it only moves the version: copy the new checksums in by hand from the release's checksum file (osv-scanner_SHA256SUMS, line osv-scanner_linux_amd64, into OSV_SCANNER_SHA256; trivy_<version>_checksums.txt, line trivy_<version>_Linux-64bit.tar.gz into TRIVY_SHA256 of both scan-images.yml and image-backend-check.yml, and line trivy_<version>_Linux-ARM64.tar.gz into TRIVY_ARM64_SHA256 of image-backend-check.yml, whose arm64 job runs Trivy on an arm64 runner). Until then the scan fails at its install step. test_web_images.py fails while the two workflows pin different Trivy releases.

What the image scan cannot see​

Trivy matches what an image records about itself: the Wolfi or Alpine package database (apk), Python packages by their *.dist-info name and version, and Go binaries by their embedded module list. A file that none of these describes is invisible to it, and so are its vulnerabilities. "Zero in Trivy" therefore says nothing about:

  • Mesa (MESA_VERSION in deploy/docker/backend/base/Dockerfile). The mesa-vulkan stage compiles the Intel (intel, intel_hasvk), virtio and asahi Vulkan drivers, which Wolfi's mesa package leaves out, and copies the installed files (/usr/lib/libvulkan_*.so of those four drivers and their ICD files in /usr/share/vulkan/icd.d) into the image. No package owns them. The AMD and lavapipe drivers come from Wolfi's mesa package and are scanned as usual.
  • SPIRV-LLVM-Translator (SPIRV_LLVM_TRANSLATOR_VERSION). A build-time tool of the mesa-vulkan stage, built as static libraries into /opt/spirv of that stage only; nothing of it ships as a file of its own.
  • IO::Compress::Brotli (IO_COMPRESS_BROTLI_VERSION), the Perl module ExifTool needs for JPEG XL brob boxes, built from its CPAN release in the perl-brotli stage. Its release bundles the Brotli C library, so a Brotli fix reaches the image through a new release of the module, not through Wolfi's brotli package.
  • Native libraries inside Python wheels. Trivy checks the wheel's own name and version (pyvips-binary, rawpy, onnxruntime, psycopg[binary], pillow-heif and so on), not the C libraries vendored into it. The wheels LibrePhotos builds itself (exiftool-bin, ffmpeg-bin, opencv-lp-headless) are not on PyPI, so neither scanner knows them; they are rebuilt by prebuilt-wheels.yml and ffmpeg-wheel.yml.

Keeping the source-built components current​

Renovate watches the three version ARGs of the base Dockerfile: Mesa through the mesa-N.N.N tags of mesa/mesa on gitlab.freedesktop.org (release candidates and branchpoint tags are skipped), SPIRV-LLVM-Translator through its GitHub tags, and IO::Compress::Brotli through CPAN. They come as one pull request, backend base sources, never automerged, because Renovate moves the version but not the *_SHA256 ARG under it: until the checksum is copied in by hand, image-backend-check fails at the download. Take the checksum from the upstream release, not from a file you downloaded yourself:

  • Mesa: the SHA-256 line of mesa-<version>.tar.xz under "SHA checksums" in the release notes (https://docs.mesa3d.org/relnotes/<version>.html), into MESA_SHA256. archive.mesa3d.org has only a GPG signature (.sig) next to the tarball.
  • SPIRV-LLVM-Translator: GitHub publishes no checksum for its tag archives, so compute it from the tag tarball (curl -fsSL https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/refs/tags/v<version>.tar.gz | sha256sum) into SPIRV_LLVM_TRANSLATOR_SHA256, and let the pull request build confirm it.
  • IO::Compress::Brotli: the CHECKSUMS file in the uploader's CPAN directory (https://cpan.metacpan.org/authors/id/T/TI/TIMLEGGE/CHECKSUMS, entry sha256 of the tarball), into IO_COMPRESS_BROTLI_SHA256.

SPIRV-LLVM-Translator keeps one release branch per LLVM major and must match the llvm-23 packages of the mesa-vulkan stage, so Renovate only offers 23.x; moving to the next major means changing the llvm-NN, llvm-NN-dev, clang-NN and libclang-cpp-NN package names in the same pull request. A Mesa or translator bump rebuilds the mesa-vulkan stage, about an hour per architecture on a GitHub runner; image-backend-check allows 120 minutes. The FROM lines of every stage pin cgr.dev/chainguard/wolfi-base:latest by digest, and Renovate opens that digest update as its own pull request (backend base image digest), never automerged and refreshed once a week, since it too rebuilds every stage. image-backend-check then also checks that every Vulkan driver in the base resolves all its libraries and that every ICD file names a driver that exists.

The frontend and proxy images​

Not released yet (comes after 1.6.0) Up to 1.6.0 the frontend image was halverneus/static-file-server:v1.8.12, whose server is built with Go 1.24 (out of support, 44 known vulnerabilities in its standard library), and the proxy was the Debian nginx:1.30 image (571 known vulnerabilities in its Debian packages). Both now scan clean.

Frontend (deploy/docker/frontend/Dockerfile). The same static-file-server release, STATIC_FILE_SERVER_VERSION, is built from source with go install and the current Go (golang:1.27-alpine), statically (CGO_ENABLED=0), and copied onto scratch. It behaves as before: /serve serves /web on port 3000 as user static (uid 1000), and its environment variables (PORT, FOLDER, SHOW_LISTING, CORS, URL_PREFIX, TLS_CERT, ...) work as documented upstream. The image has no shell and no OS packages, so an image extending it cannot RUN anything; add files with COPY (FROM reallibrephotos/librephotos-frontend:<tag> then COPY my-file /web/), or build your own stage and copy /serve out of it. It no longer declares the upstream's unused EXPOSE 8080.

Proxy (deploy/docker/proxy/Dockerfile). nginx:1.30-alpine-slim, plus apk upgrade --no-cache at build time so fixes Alpine released after the base image are in. It is the same nginx build from nginx.org as the Debian image (same version, configure options, paths, nginx user with uid 101, /docker-entrypoint.sh with its /docker-entrypoint.d scripts and /etc/nginx/templates envsubst support, logs to stdout and stderr), and it runs deploy/docker/proxy/nginx.conf the same way, also non-root with a read-only root file system as in deploy/k8s. What differs for an image or healthcheck built on it:

  • Alpine instead of Debian: apk add, not apt-get install, and sh (BusyBox), not bash.
  • No curl. Use BusyBox wget in a healthcheck, against 127.0.0.1: wget -q -O /dev/null http://127.0.0.1/. localhost resolves to ::1 first and the proxy listens on IPv4 only. deploy/compose/docker-compose.e2e.yml does this.
  • No dynamic modules: the Debian image shipped njs, image-filter, xslt and geoip as loadable modules. nginx.conf loads none of them; a custom configuration that does needs the nginx:1.30-alpine image.