Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ jobs:
build-args: |
BUILD_PACKAGE_NAME=tyk-gateway-fips
BASE_IMAGE=tykio/dhi-busybox:1.37-fips
NONROOT_CHOWN=true
- name: Docker metadata for fips tag push
id: tag_metadata_fips
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
Expand Down Expand Up @@ -276,6 +277,7 @@ jobs:
build-args: |
BUILD_PACKAGE_NAME=tyk-gateway-fips
BASE_IMAGE=tykio/dhi-busybox:1.37-fips
NONROOT_CHOWN=true
- name: Attach base image VEX to fips
if: ${{ matrix.golang_cross == '1.25-bullseye' && startsWith(github.ref, 'refs/tags') }}
run: |
Expand Down
7 changes: 5 additions & 2 deletions ci/Dockerfile.distroless
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@

# The _ after the pkg name is to match tyk-gateway strictly and not tyk-gateway-fips (for example)
COPY ${BUILD_PACKAGE_NAME}_*${TARGETARCH}.deb /
RUN dpkg -i /${BUILD_PACKAGE_NAME}_*${TARGETARCH}.deb && rm /*.deb
ARG NONROOT_CHOWN=false
RUN dpkg -i /${BUILD_PACKAGE_NAME}_*${TARGETARCH}.deb && rm /*.deb \
&& chmod -R a+rX /opt/tyk-gateway/ \

Check warning on line 15 in ci/Dockerfile.distroless

View check run for this annotation

probelabs / Visor: security

security Issue

The command `chmod -R a+rX /opt/tyk-gateway/` recursively makes all files in the gateway's installation directory world-readable. If this directory contains any sensitive files with intentionally restrictive permissions (e.g., private keys with permissions `0600`), this change will expose them to any user within the container. This could lead to sensitive data exposure if another vulnerability allows code execution as a different user within the container, or if the application itself has a file disclosure vulnerability.
Raw output
Instead of making all files world-readable, adopt a more granular permission model based on the principle of least privilege. If specific non-root users need access, consider using group permissions. For example, create a dedicated group and set group-read permissions on the files (`chmod -R g+rX`). This avoids exposing potentially sensitive files to all users in the container. If the goal is to support arbitrary user IDs (as is common in some container platforms), ensure that no sensitive files with secrets are packaged within the image with overly permissive file modes.
&& if [ "$NONROOT_CHOWN" = "true" ]; then chown -R 65532:65532 /opt/tyk-gateway/; fi

Check warning on line 16 in ci/Dockerfile.distroless

View check run for this annotation

probelabs / Visor: performance

performance Issue

The `RUN` instruction introduces `chmod -R` and conditional `chown -R` operations. These recursive commands traverse the entire `/opt/tyk-gateway` directory, which can be time-consuming and slow down the image build process. This is less performant than the previous `COPY --chown` approach, which is handled more efficiently by the Docker daemon. While this change fixes an ownership issue, it comes at the cost of build performance.
Raw output
The most performant solution would be to define the correct file modes and ownership within the `.deb` package itself, eliminating the need for these `RUN` commands during the image build. If modifying the package is not feasible, be aware of the potential impact on build duration.

FROM ${BASE_IMAGE}

COPY --chown=65532:65532 --from=deb /opt/tyk-gateway /opt/tyk-gateway
COPY --from=deb /opt/tyk-gateway /opt/tyk-gateway

ARG PORTS
EXPOSE $PORTS
Expand Down
Loading