Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch base image to distroless #718

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

agologan
Copy link
Contributor

@agologan agologan commented Mar 15, 2024

This a conversation fueled by CVEs mainly.

Scanned the latest released with Trivy:

docker run --rm -it aquasec/trivy image ghcr.io/sosedoff/pgweb:0.15.0

And here's the overview:

ghcr.io/sosedoff/pgweb:0.15.0 (debian 11.9)
Total: 163 (UNKNOWN: 0, LOW: 91, MEDIUM: 28, HIGH: 40, CRITICAL: 4)

usr/bin/pgweb (gobinary)
Total: 5 (UNKNOWN: 0, LOW: 0, MEDIUM: 4, HIGH: 1, CRITICAL: 0)

Looking at the history of this project it was once alpine: bc4a907
Actually wanted to suggest it as a base image since it has decent developer experience compared to distroless, if you don't have to deal with musl specifically.

What follows is just a test I did on how hard it would be to make it distroless.
Not very, as it seems - though I don't know about those deps since I didn't need any in my testing.

Here are a few options for this conversation:

  • switching back to alpine, decent devx, small, almost no CVEs
  • switch to distroless, works as far as I can tell but it's a pain to build once you have to deal with deps
  • publish multiple versions, requires manging multiple Dockerfiles but shouldn't be too hard
  • upgrade base image to bookworm at least since some of the CVEs have already been resolved but are not scheduled to be backported
  • do nothing 馃構 interested parties can build their own variant fairly easily

@sosedoff
Copy link
Owner

What exactly are we trying to solve here? Security issues? It seems like most of those are stemming from the base image, but that's going to apply to anyone using said images.

I don't think Pgweb has enough test coverage to properly catch any issues related to OS (missing packages and tools). The project is also a bit slow moving at this point so switching the distro again will cause a bit of pain, at least on my end. I used binaries where possible and only fall back to docker/containers if i have to.

Im open to keep the conversation going though, as i get a bunch of mail accusing pgweb of being responsible for RCEs, but in reality its on users that should not expose such systems to public internet, especially with full access.

@agologan
Copy link
Contributor Author

agologan commented Mar 18, 2024

Sorry for not providing enough context.
Yes, I'm trying to reduce the number of CVEs associated with the container which mostly stem from the base image.
Most orgs including my own scan all containers and tend to avoid debian base images because the issues caused by extra packages distract from the actual application.

As for the packages, should've done my homework.
Only pg_dump (postresql/postgresql-client) is required for the dump db feature.

Built several versions here are the scan results depending on base images. (excluded the actual go/app list).

# distroless-debian12 (bookworm without postgres-client) (37.9MB)
Total: 13 (UNKNOWN: 0, LOW: 9, MEDIUM: 4, HIGH: 0, CRITICAL: 0)
# bookworm-slim (179MB)
Total: 118 (UNKNOWN: 0, LOW: 75, MEDIUM: 21, HIGH: 21, CRITICAL: 1)
# ubuntu:22.04 (204MB)
Total: 38 (UNKNOWN: 0, LOW: 23, MEDIUM: 15, HIGH: 0, CRITICAL: 0)
# alpine-3.19 (29.8MB)
Total: 6 (UNKNOWN: 0, LOW: 0, MEDIUM: 6, HIGH: 0, CRITICAL: 0)

Also bringing this up, because the history doesn't explain the switch from alpine to debian-slim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants