Harden pricing image (zlib fix, drop pip) and add time-limited Trivy exceptions after build #1 triage (refs #16)

This commit is contained in:
2026-11-12 13:05:08 -05:00
parent 12621dadde
commit e69ac37974
4 changed files with 74 additions and 2 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ pipeline {
[ -s pricing/security/trivyignore.yaml ] && IGNORE="--ignorefile pricing/security/trivyignore.yaml"
# Policy gate: any HIGH or CRITICAL vulnerability blocks (fixed or not) unless a
# documented, time-limited exception exists in pricing/security/trivyignore.yaml.
trivy image --scanners vuln --severity HIGH,CRITICAL --exit-code 1 --no-progress $IGNORE \
trivy image --scanners vuln --severity HIGH,CRITICAL --exit-code 1 --no-progress --show-suppressed $IGNORE \
"$IMAGE:$COMMIT" 2>&1 | tee reports/trivy-image-gate.log
# Full report of all severities for the record (does not gate).
trivy image --scanners vuln --no-progress --skip-db-update --format json \
+18
View File
@@ -32,3 +32,21 @@ Ansible to two Compose projects on the team Droplet.
Trivy 0.69.3 (checksum-verified; known-safe release after the March 2026 Trivy
supply-chain incident, GHSA-69fq-xp46-6x23), ansible-core 2.19.15 with
community.docker 5.2.2 (venv `/opt/ansible-venv`), pip-audit 2.10.1 (`/opt/pip-audit-venv`).
## Security gate policy
| Gate | Tool | Blocks when |
|---|---|---|
| Unit tests | `python -m unittest` | any test fails |
| Dependency audit | pip-audit 2.10.1 (`--strict`, hash-locked) | any known vulnerability, or a package cannot be audited |
| Secret scan | Trivy `fs --scanners secret` (whole repository) | any detected secret |
| Image scan | Trivy `image --severity HIGH,CRITICAL` | any HIGH/CRITICAL not covered by an unexpired entry in `security/trivyignore.yaml` |
A scanner error or an unavailable vulnerability database exits non-zero and fails the build;
a failed scan is never treated as clean. Fixable findings are fixed (pin the fixed package or
remove the component) and rebuilt. Findings without a published fix may be accepted only as
time-limited exceptions in `security/trivyignore.yaml`, each with a statement and an
`expired_at` date; the gate output lists suppressed findings (`--show-suppressed`), and the
full all-severity report is archived as `reports/trivy-image-all.json`. False positives are
handled the same way, with the reason in the statement. Exceptions are reviewed in a pull
request and are pending instructor acceptance.
+9 -1
View File
@@ -2,6 +2,11 @@
# Base image pinned by digest: python:3.13-slim, linux/amd64 compatible (Droplet is x86_64).
# Record of selection: see pricing/README.md. Rebuild and rescan when this digest changes.
FROM python:3.13-slim@sha256:e48f59cdba69a3cbd9ed2cf0f348d90d45a8d350d98134cf1070bc106ee9ed90
# Security fix (Trivy, 2026-11-12): zlib1g fixed in the Debian 13 point update
# (CVE-2026-76844, CVE-2026-85091). Exact version, so the build stays reproducible.
RUN apt-get update \
&& apt-get install -y --no-install-recommends --only-upgrade 'zlib1g=1:1.3.dfsg+really1.3.1-1+deb13u1' \
&& rm -rf /var/lib/apt/lists/*
ARG APP_COMMIT=development
ENV APP_COMMIT=$APP_COMMIT PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
LABEL org.opencontainers.image.source="https://git.ssw590.abrdns.com/StartupTeam/Strartup-product" \
@@ -9,7 +14,10 @@ LABEL org.opencontainers.image.source="https://git.ssw590.abrdns.com/StartupTeam
WORKDIR /app
COPY requirements.txt .
# Exact, hash-locked direct and transitive dependencies (generated by pip-compile from requirements.in).
RUN pip install --no-cache-dir --require-hashes -r requirements.txt
# pip is not needed at runtime; removing it also removes its vendored msgpack, urllib3
# and pkg_resources (setuptools), which Trivy reported as HIGH.
RUN pip install --no-cache-dir --require-hashes -r requirements.txt \
&& python -m pip uninstall -y pip
COPY app.py .
USER 10001:10001
EXPOSE 8000
+46
View File
@@ -0,0 +1,46 @@
# Time-limited exceptions to the image-scan gate (HIGH/CRITICAL blocks the release).
# Policy (pricing/README.md, "Security gate policy"):
# * Only findings with NO fixed version in Debian 13 may be listed here, each with a statement.
# * Every entry expires; after expiry the gate fails again until the finding is re-triaged.
# * Fixable findings are fixed (see app/Dockerfile), never listed here.
# Triage: SB, 2026-11-12, from Jenkins pricing-delivery #1 (image 12621da), Trivy 0.69.3.
# Compensating controls for all entries: the service runs as UID 10001, read-only root FS,
# cap_drop ALL, no-new-privileges, no shell access path, no host mounts, private network only.
# Approval: requested from the instructor as a time-limited exception (Chapter 6.4.5).
vulnerabilities:
# util-linux family (bsdutils, libblkid1, liblastlog2-2, libmount1, libsmartcols1, libuuid1,
# login, mount, util-linux): mount helpers / nsenter. Not invoked by the service; mounting
# and nsenter need privileges the container does not have.
- id: CVE-2026-76642
statement: "util-linux mount post-hooks; status affected, no Debian 13 fix; mount not used, no CAP_SYS_ADMIN"
expired_at: 2026-12-15
- id: CVE-2026-78408
statement: "util-linux nsenter cgroup; status affected, no fix; nsenter not used, all capabilities dropped"
expired_at: 2026-12-15
- id: CVE-2026-78409
statement: "util-linux X-mount.subdir; status affected, no fix; mount not used"
expired_at: 2026-12-15
- id: CVE-2026-78410
statement: "util-linux restricted bind mounts; status affected, no fix; mount not used"
expired_at: 2026-12-15
- id: CVE-2026-54369
statement: "libacl symlink traversal; status affected, no fix; app does not call ACL functions, read-only FS"
expired_at: 2026-12-15
- id: CVE-2025-69720
statement: "ncurses buffer overflow; status affected, no fix; no terminal UI in the service"
expired_at: 2026-12-15
- id: CVE-2026-119373
statement: "sqlite FTS5 DoS; status affected, no fix; the service does not use sqlite"
expired_at: 2026-12-15
- id: CVE-2026-119374
statement: "sqlite FTS5 corrupted index; status affected, no fix; the service does not use sqlite"
expired_at: 2026-12-15
- id: CVE-2026-119379
statement: "sqlite session changesets; status affected, no fix; the service does not use sqlite"
expired_at: 2026-12-15
- id: CVE-2026-16742
statement: "systemd-homed (libsystemd0, libudev1); status affected, no fix; no systemd in the container"
expired_at: 2026-12-15
- id: CVE-2026-9538
statement: "perl Archive::Tar DoS (perl-base); Debian status fix_deferred; perl not used by the service"
expired_at: 2026-12-15