175 lines
14 KiB
Plaintext
175 lines
14 KiB
Plaintext
# Container hardening and dependency/image scan evidence
|
|
|
|
Date: 2026-11-27
|
|
Stand: local Docker Desktop, compose project hla-lab7, Windows host, Java 23 toolchain
|
|
Scope: README level 4 hardening/scan criterion. No secret values are recorded.
|
|
|
|
## 1. Reproducible commands
|
|
|
|
Compose hardening:
|
|
|
|
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\check-compose-hardening.ps1
|
|
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\test-container-secret-boundaries.ps1
|
|
|
|
Dependency scan (OSV querybatch + per-advisory detail over resolved Gradle runtimeClasspath):
|
|
|
|
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\scan-dependencies.ps1 -JsonPath "%TEMP%\osv-findings-before.json"
|
|
# after applying the fixes below
|
|
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\scan-dependencies.ps1 -FailOnHigh -JsonPath "%TEMP%\osv-findings-after.json"
|
|
|
|
Image build and scan (Docker Scout needs a Docker account login and was not used):
|
|
|
|
docker compose --env-file .env build api
|
|
mkdir "%TEMP%\trivy-out"
|
|
docker run --rm -v //var/run/docker.sock:/var/run/docker.sock -v "%TEMP%\trivy-out:/out" aquasec/trivy:0.62.1 image --scanners vuln --no-progress --timeout 20m --format json --output /out/trivy-app-before.json hla-lab7-app:local
|
|
docker run --rm -v //var/run/docker.sock:/var/run/docker.sock -v "%TEMP%\trivy-out:/out" aquasec/trivy:0.62.1 image --scanners vuln --no-progress --timeout 20m --format json --output /out/trivy-app-after.json hla-lab7-app:local
|
|
|
|
Runtime verification and application check after recreating containers:
|
|
|
|
docker compose --env-file .env up -d --no-deps --force-recreate --scale api=2 api worker
|
|
docker compose --env-file .env up -d --no-deps --force-recreate postgres redis rabbitmq minio
|
|
docker compose --env-file .env run --rm rabbitmq-init
|
|
python tests/smoke.py --base-url https://localhost:8443 --ca-file secrets/pki/public-ca/ca.crt
|
|
|
|
No curl -k / --insecure is used; the Python check loads the explicit public CA file.
|
|
OSV/Trivy outputs contain advisory data only, not credentials.
|
|
|
|
## 2. Container hardening and explained exceptions
|
|
|
|
Observed check output:
|
|
|
|
PASS: every service has no-new-privileges, a capability drop policy, private tmpfs and resource limits.
|
|
PASS: non-stateful services use a read-only root and drop ALL capabilities.
|
|
EXCEPTION minio writable root: Bitnami entrypoint prepares /bitnami/minio/data and the /certs links
|
|
EXCEPTION postgres writable root: entrypoint chown/chmod of /var/lib/postgresql/data before dropping to the postgres user
|
|
EXCEPTION rabbitmq writable root: entrypoint prepares /var/lib/rabbitmq and the Erlang cookie
|
|
EXCEPTION redis writable root: entrypoint writes /tmp/users.acl and persists RDB snapshots to the /data volume
|
|
|
|
PASS: runtime isolation, non-root app/worker, resource and port boundaries, Git/image/log secret isolation, and telemetry redaction are enforced. Checked 14 local secret values without printing them.
|
|
|
|
Runtime `docker inspect` for the app and four stateful exceptions (ReadonlyRootfs | Tmpfs | SecurityOpt | CapDrop):
|
|
|
|
hla-lab7-api-2 true | {"/tmp":"size=128m,mode=1777"} | no-new-privileges:true | ALL
|
|
hla-lab7-worker-1 true | {"/tmp":"size=192m,mode=1777","/tmp/native":"size=64m,mode=1777,exec"} | no-new-privileges:true | ALL
|
|
hla-lab7-postgres-1 false | {"/tmp":"size=64m,mode=1777"} | no-new-privileges:true | AUDIT_WRITE,MKNOD,NET_RAW,SETFCAP,SETPCAP,SYS_CHROOT
|
|
hla-lab7-redis-1 false | {"/tmp":"size=16m,mode=1777"} | no-new-privileges:true | AUDIT_WRITE,MKNOD,NET_RAW,SETFCAP,SETPCAP,SYS_CHROOT
|
|
hla-lab7-rabbitmq-1 false | {"/tmp":"size=64m,mode=1777"} | no-new-privileges:true | AUDIT_WRITE,MKNOD,NET_RAW,SETFCAP,SETPCAP,SYS_CHROOT
|
|
hla-lab7-minio-1 false | {"/tmp":"size=32m,mode=1777"} | no-new-privileges:true | AUDIT_WRITE,MKNOD,NET_RAW,SETFCAP,SETPCAP,SYS_CHROOT
|
|
|
|
Why only these four keep a writable root: each stock entrypoint must create/chown a
|
|
persistent named volume before it drops to its unprivileged runtime user. Setting
|
|
`read_only: true` there breaks first startup/permission setup. The exceptions are
|
|
not generic: the check requires the exact data volume and exact six-capability drop
|
|
profile, and still requires `no-new-privileges`, tmpfs and resource limits. All other
|
|
services have `read_only: true` and `cap_drop: ALL`.
|
|
|
|
Post-recreate smoke: `PASS: lab7 public API scenario; infrastructure and grading evidence remain separate.`
|
|
RabbitMQ users are created by the `rabbitmq-init` one-shot; this was rerun after the
|
|
broker container was recreated so the mTLS role identities continued to work.
|
|
|
|
## 3. OSV dependency scan and applicability triage
|
|
|
|
Baseline command on the pre-fix `build.gradle`:
|
|
|
|
Resolved OSV Maven dependencies: 139
|
|
Packages with findings: 9
|
|
Findings by severity: CRITICAL=5 HIGH=18 MODERATE=10 LOW=1
|
|
|
|
Grouped baseline findings (package@installed version, findings, severities, fixed versions from advisory data):
|
|
|
|
com.fasterxml.jackson.core:jackson-core@2.21.5 2 HIGH2 2.18.11, 2.21.7, 2.22.3, 3.1.7, 3.2.2, 3.2.3
|
|
com.fasterxml.jackson.core:jackson-databind@2.21.5 5 HIGH3/MODERATE2 up to 2.21.7 / 2.22.3 / 3.1.7 / 3.2.3
|
|
tools.jackson.core:jackson-core@3.1.5 2 HIGH2 2.18.11, 2.21.7, 2.22.3, 3.1.7, 3.2.2, 3.2.3
|
|
tools.jackson.core:jackson-databind@3.1.5 5 HIGH3/MODERATE2 up to 2.21.7 / 2.22.3 / 3.1.7 / 3.2.3
|
|
com.google.guava:guava@33.4.8-jre 1 HIGH1 33.7.2
|
|
com.rabbitmq:amqp-client@5.30.0 10 HIGH4/MODERATE5/LOW1 5.31.0, 5.33.0, 5.33.1, 5.34.0, 5.35.0, 5.36.0, 5.36.1
|
|
org.apache.tomcat.embed:tomcat-embed-core@11.0.24 4 CRITICAL4 10.1.58, 10.1.59, 11.0.25, 9.0.121
|
|
org.bouncycastle:bcprov-jdk18on@1.84 2 CRITICAL1/HIGH1 1.85 (and other incompatible lines)
|
|
org.xerial.snappy:snappy-java@1.1.10.7 3 HIGH2/MODERATE1 1.1.10.9
|
|
|
|
Representative HIGH/CRITICAL advisory IDs:
|
|
|
|
jackson-core/databind 2.x and 3.x: GHSA-7hhh-6rmp-j9qf / CVE-2026-89425,
|
|
GHSA-p6pp-m3f8-5c89 / CVE-2026-89407, GHSA-cxp5-3px4-pw24 / CVE-2026-91777,
|
|
GHSA-q4xh-88c3-wmh7 / CVE-2026-68497, GHSA-wv8q-qhhj-9h54 / CVE-2026-91776
|
|
amqp-client: GHSA-6g32-pxv4-2wfj / CVE-2026-63337,
|
|
GHSA-68mj-5wr7-6fgg / CVE-2026-69219, GHSA-93j5-89vc-pph4 / CVE-2026-69220,
|
|
GHSA-jh4v-gfqj-7rhx / CVE-2026-75516
|
|
tomcat-embed-core: GHSA-gcx9-497g-6cp6 / CVE-2026-65182,
|
|
GHSA-f525-44xv-f2qj / CVE-2026-65637, GHSA-9xv2-5v5q-p794 / CVE-2026-65905,
|
|
GHSA-h3x4-894j-xpx5 / CVE-2026-68525
|
|
bcprov: GHSA-9pwp-9qqc-pr26 / CVE-2026-8763, GHSA-qp49-qgx5-5m26 / CVE-2026-13506
|
|
guava: GHSA-xxph-c9ww-hj94 / CVE-2026-102554
|
|
snappy-java: GHSA-gwq9-9ffj-mvrv / CVE-2026-93451,
|
|
GHSA-q233-g92q-qxp6 / CVE-2026-108106
|
|
|
|
Applicability, fix and control per package:
|
|
|
|
Package / version | Reachability in this configuration | Fix availability | Temporary control before fix / final state
|
|
Jackson 2.x and 3.x | Reachable: Spring Boot MVC uses Jackson for public JSON request/response binding; malformed input reaches the parser. Both the 2.x and 3.x coordinate sets were on the runtime classpath. | Fixed in 2.21.7 and 3.1.7; BOM overrides applied. | Before fix: 10 MiB request-body limit and mTLS at ingress, but not a substitute for parser limits. After fix: upgraded; OSV reports no finding.
|
|
tomcat-embed-core 11.0.24 | Reachable: embedded Tomcat serves the public HTTPS API through nginx; DIGEST/FORM paths are not enabled here, but the core parser/host handling is on the request path. | Fixed in 11.0.25; BOM override applied. | Before fix: mTLS identity check, body/rate limits and no exposed admin endpoints. After fix: upgraded; startup log shows Apache Tomcat/11.0.25.
|
|
amqp-client 5.30.0 | Reachable: API publishes attachment jobs and worker consumes them through mTLS broker gateways. Broker is trusted and role ACLs are narrow, but untrusted frame content would still be parsed by the client. | OSV lists 5.33.0/5.33.1/5.34.0/5.36.1; Maven Central has no 5.36.1 artifact, so 5.37.1 was selected. BOM override applied. | Before fix: mTLS gateways, exact role CN, ACLs and backend bypass denial. After fix: upgraded; OSV query for 5.37.1 returns no findings.
|
|
bcprov-jdk18on 1.84 | Transitive from MinIO; no direct BouncyCastle API use in application code. Reachable only through MinIO client TLS/signature internals against a fixed internal endpoint. | Fixed in 1.85; direct pin applied. | Before fix: internal-only MinIO endpoint, verify-full TLS and scoped credentials. After fix: upgraded; no direct ASN.1 parsing from untrusted input in app code.
|
|
guava 33.4.8-jre | Transitive from MinIO 8.6.0; reachable through its client internals, especially attachment I/O. | Fixed in 33.7.2; direct pin applied. | Before fix: 10 MiB attachment limit, staging prefix restrictions and mTLS. After fix: upgraded.
|
|
snappy-java 1.1.10.7 | Transitive from MinIO 8.6.0; only relevant if compressed object data is decoded. | Fixed in 1.1.10.9; direct pin applied. | Before fix: size/pixel bounds and internal endpoint. After fix: upgraded.
|
|
|
|
Result after the fixes:
|
|
|
|
Resolved OSV Maven dependencies: 139
|
|
Packages with findings: 0
|
|
Findings by severity:
|
|
osv_final_exit=0
|
|
|
|
The fix is `jackson-2-bom.version=2.21.7`, `jackson-bom.version=3.1.7`,
|
|
`rabbit-amqp-client.version=5.37.1`, `tomcat.version=11.0.25`, plus direct pins
|
|
`bcprov-jdk18on:1.85`, `guava:33.7.2-jre`, `snappy-java:1.1.10.9` in `build.gradle`.
|
|
|
|
## 4. Trivy image scan and applicability triage
|
|
|
|
Both scans used `aquasec/trivy:0.62.1`, `--scanners vuln`, Docker socket access and a
|
|
persistent `trivy-cache` volume. The Java DB was refreshed during the runs; each
|
|
scan completed with exit 0.
|
|
|
|
Image before dependency fix: sha256:56362acf75313be92f91ffd8735bd8683c882402139b25d4298dbc85e3c7d095
|
|
Image after dependency fix: sha256:73470b278aa115dabe8ba84f5202feeab41859744e929f73790f285200a1c1eb
|
|
|
|
Before: ubuntu 24.04 os-pkgs 442 findings (HIGH=16, MEDIUM=329, LOW=97)
|
|
Java jar 34 findings (CRITICAL=5, HIGH=18, MODERATE=10, LOW=1)
|
|
After: ubuntu 24.04 os-pkgs 442 findings (HIGH=16, MEDIUM=329, LOW=97)
|
|
Java jar 0 findings
|
|
|
|
The Java result independently confirms the OSV result: all HIGH/CRITICAL library
|
|
findings were removed by the version upgrades. The rebuilt image ID changed because
|
|
of this dependency work; the earlier rotation evidence recorded the previous image
|
|
ID at rotation time and is not contradicted by that later rebuild.
|
|
|
|
OS HIGH findings are base-image packages, not application libraries. All have fixed
|
|
versions in the Ubuntu tracker; applicability at runtime:
|
|
|
|
Package(s) / installed -> fixed | Reachability | Temporary control
|
|
apt 2.7.14build2 -> 2.8.4ubuntu0.1 | Package-manager code. The final entrypoint never invokes apt; there is no install/upgrade step in the running container. | Runtime user is non-root, rootfs is read-only, capabilities are ALL-dropped, and no shell/package-manager step exists in the entrypoint. Fix is available via base-image refresh.
|
|
libapt-pkg6.0t64 2.7.14build2 -> 2.8.4ubuntu0.1 | Library used by apt only; not linked into the JVM path used by the app. | Same runtime controls; base-image refresh tracked separately.
|
|
gnupg suite 2.4.4-2ubuntu17 -> 2.4.4-2ubuntu17.4 | dirmngr/gpg/gpg-agent/keyboxd etc. No key import, signing or verification is invoked by the final image entrypoint. | Same runtime controls; no untrusted key material is processed at runtime. Fix available in Ubuntu updates.
|
|
libbrotli1 1.1.0-2build2 -> 1.1.0-2ubuntu0.1 | Decoder library that could be loaded by the installed curl; curl is used only during image build to fetch the OTel agent, not by the runtime entrypoint. | Java TLS does not load this decoder for the app request path; non-root/read-only/no-new-privileges/cap-drop ALL remain in force. Fix available via base-image refresh.
|
|
openssl/libssl3t64 3.0.13-0ubuntu3.4 -> ...3.11/...3.16 | Used by system tools such as curl; the Java app uses the JDK TLS stack, not the system OpenSSL library. No runtime process in the entrypoint invokes openssl/curl. | Same runtime controls; base-image refresh tracked separately.
|
|
|
|
This is applicability analysis rather than dismissal by port state: the conclusion is
|
|
based on the actual final-stage entrypoint (`infra/otel/docker-entrypoint.sh`: wait
|
|
for rendered env, import service CA with `keytool`, then `exec java ...`) and on the
|
|
runtime user/filesystem/capability settings. The OS findings are still recorded with
|
|
fixed versions; patching the base image is the remaining supply-chain follow-up.
|
|
|
|
## 5. Regression checks after upgrades
|
|
|
|
.\gradlew.bat test --tests com.example.mtusi_messenger.security.DatabaseAuthenticationProviderTest --tests com.example.mtusi_messenger.security.LoginRateLimiterTest --tests com.example.mtusi_messenger.config.PasswordConfigTest --tests com.example.mtusi_messenger.cache.UserCacheTest --tests com.example.mtusi_messenger.queue.RetryPolicyTest --no-daemon --console=plain
|
|
BUILD SUCCESSFUL
|
|
|
|
python tests/smoke.py --base-url https://localhost:8443 --ca-file secrets/pki/public-ca/ca.crt
|
|
PASS: lab7 public API scenario; infrastructure and grading evidence remain separate.
|
|
|
|
The full `gradlew test` run also includes `MtusiMessengerApplicationTests`, which
|
|
requires PostgreSQL/Redis on localhost; those ports are deliberately not published
|
|
by this Compose profile, so that integration class returns 503 in this host setup.
|
|
This limitation is already documented in `REPORT.md`; the relevant unit tests and
|
|
black-box HTTPS checks above pass.
|