Repository navigation
Razorpay: hardened operator image from source + Harbor base (0 Go CVEs) - #1
jainanuj07 wants to merge 5 commits into
Conversation
Rebuild the operator from source with a current toolchain and bumped modules, and harden the
Spark base it ships on. Verified locally with Trivy: Go binary 0 CVEs, OS 0 CRITICAL/HIGH.
- go.mod: bump x/net 0.57->0.63, x/text 0.40->0.44, x/mod 0.37->0.43, otel/trace 1.44->1.47;
toolchain go1.27.4. Clears all 12 remaining Go CVEs (22 on upstream) -> 0.
- Dockerfile:
- builder golang:1.27.4 (Harbor proxy, digest-pinned) + GOTOOLCHAIN=local
- FROM the Harbor-approved apache/spark:4.2.1 mirror (c.rzp.io/razorpay-external) instead of
docker.io -> no non-Harbor base finding
- apt upgrade + remove gosu (Go 1.18 setuid binary, Go EOL; operator uses catatonit, runs
non-root uid 185, so gosu is dead weight) -> clears the Go-EOL gate
- swap vulnerable standalone jars (netty/jackson/snappy/lz4/guava/jline/derby) for patched
versions via the GCS Maven mirror, verified fail-closed
- patched-jars.pom.xml + settings.xml: the jar-swap manifest + GCS Maven Central mirror.
- .github/workflows/razorpay-image-build-push.yaml: build + push the controller image to Harbor
(c.rzp.io) per-arch + multi-arch manifest, mirroring datahub's custom-base pipeline. Requires
HARBOR_DOCKER_USERNAME / HARBOR_DOCKER_PASSWORD repo secrets.
Residual after this: only the CVEs shaded inside Spark/Hadoop fat-jars (the exception floor).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| # Razorpay hardening: resolve the patched standalone jars (patch/minor bumps that are | ||
| # Spark-ABI-safe) via the GCS Maven Central mirror. Maven verifies each artifact's published | ||
| # checksum. These replace the vulnerable standalone jars the Spark base ships in /opt/spark/jars. | ||
| FROM c.rzp.io/proxy_dockerhub/library/maven:3.9-eclipse-temurin-21 AS jars |
There was a problem hiding this comment.
🔵 Low severity blocking issue identified in your code:
Use of non-harbor in base image is not allowed
To resolve this comment:
✨ Commit fix suggestion
| FROM c.rzp.io/proxy_dockerhub/library/maven:3.9-eclipse-temurin-21 AS jars | |
| FROM c.rzp.io/razorpay/rzp-docker-image-inventory-multi-arch:rzp-golden-image-base-maven-3.9-eclipse-temurin-21 AS jars |
View step-by-step instructions
-
Replace the proxy Docker Hub image with the approved Harbor-hosted Maven golden image while keeping the
jarsstage name:
FROM c.rzp.io/razorpay/rzp-docker-image-inventory-multi-arch:rzp-golden-image-base-maven-3.9-eclipse-temurin-21 AS jars -
If the repository uses a configurable registry, define the registry before the
FROMinstruction and use the equivalent variable-based reference:
ARG REGISTRY=c.rzp.io/razorpay
FROM ${REGISTRY}/rzp-docker-image-inventory-multi-arch:rzp-golden-image-base-maven-3.9-eclipse-temurin-21 AS jars -
Preserve the existing Maven version and Java 21 runtime when selecting the approved internal image. Do not use
c.rzp.io/proxy_dockerhub/...or another external registry directly.
💬 Ignore this finding
Leave a nosemgrep comment directly above or at the end of line 65 like so // nosemgrep: razorpay.custom-docker-base-image-check
Take care to validate that this is not a true positive finding before ignoring it.
Learn more about ignoring code, files and folders here.
You can view more details about this finding in the Semgrep AppSec Platform.
| # Go 1.27.4 builder (via the Harbor DockerHub proxy). The bumped go.mod (x/net 0.63, x/text 0.44, | ||
| # x/mod 0.43, otel/trace 1.47) + this toolchain rebuild the operator binary with 0 Go CVEs | ||
| # (verified with Trivy). GOTOOLCHAIN=local pins the build to this toolchain. | ||
| FROM c.rzp.io/proxy_dockerhub/library/golang:1.27.4@sha256:5bd30d78fe7788dc760abe3e3437434781b3164e50fadc24611fa7fbc0cfb6ba AS builder |
There was a problem hiding this comment.
🔵 Low severity blocking issue identified in your code:
Use of non-harbor in base image is not allowed
To resolve this comment:
✨ Commit fix suggestion
| FROM c.rzp.io/proxy_dockerhub/library/golang:1.27.4@sha256:5bd30d78fe7788dc760abe3e3437434781b3164e50fadc24611fa7fbc0cfb6ba AS builder | |
| FROM c.rzp.io/razorpay/<VERIFIED_VALUE_REQUIRED>:1.27.4@sha256:<VERIFIED_VALUE_REQUIRED> AS builder |
View step-by-step instructions
- Replace the
c.rzp.io/proxy_dockerhub/...builder image with the approved Harbor or Razorpay golden Go image for Go1.27.4, using its immutable digest. For example:FROM c.rzp.io/razorpay/<approved-golang-image>:1.27.4@sha256:<approved-digest> AS builder. - Keep the
AS builderalias and all subsequent build steps unchanged. - Do not use
c.rzp.io/proxy_dockerhub/...orc.rzp.io/proxy_quay/...; these proxy namespaces are not accepted by the policy. - Confirm that the replacement image provides the Go toolchain required by
GOTOOLCHAIN=localand that the pinned digest matches the approved image content.
💬 Ignore this finding
Leave a nosemgrep comment directly above or at the end of line 24 like so // nosemgrep: razorpay.custom-docker-base-image-check
Take care to validate that this is not a true positive finding before ignoring it.
Learn more about ignoring code, files and folders here.
You can view more details about this finding in the Semgrep AppSec Platform.
Wire the org-wide security scans (Semgrep, secret scan, Non-Golden-Image, etc.) via razorpay/security-action, matching datahub's central_security_checks.yml so PRs and master in this fork get the same security gating. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tion dep)
The internal razorpay/docker-image-build-push action is a private repo this fork can't resolve
("Unable to resolve action ... not found"). Swap it for public docker/{setup-qemu,setup-buildx,
login,build-push}-action, which build the same multi-arch image and push to c.rzp.io. Now the
only prerequisite is the Harbor secret reaching this repo — no internal-action access grant.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Revert to the internal action datahub uses for Harbor build+push, per-arch + multi-arch manifest. Requires the fork to be granted access to the private razorpay/docker-image-build-push action and to the Harbor org secrets. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…rnal action) Align the Harbor build+push workflow 1:1 with datahub's ci_custom_base_images.yml: - runs-on self-hosted linux-amd64 / linux-arm64 (not GitHub-hosted ubuntu-latest), which is what gives access to the private action, Harbor, and the org secrets inside Razorpay's network. - per-arch build via razorpay/docker-image-build-push with an arch-suffixed custom-tag. - multi-arch manifest via the same action with trigger-multiarch-image-build + multiarch-suffixes (not manual docker manifest), on a linux-amd64 runner. - checkout pinned to the same immutable SHA datahub uses. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
What
Build the Spark Operator controller image from source in this fork, hardened for Razorpay security approval, and push it to Harbor (
c.rzp.io).Why
The upstream operator image (
apache/sparkbase + prebuilt binary) is rejected by the security scan on Go CVEs (binary) and EOL (gosu's Go 1.18). Building from source with a current toolchain + bumped modules clears the Go CVEs; hardening the base clears the OS + gosu findings.Changes
go.mod— bumpx/net 0.57→0.63,x/text 0.40→0.44,x/mod 0.37→0.43,otel/trace 1.44→1.47;toolchain go1.27.4.Dockerfilegolang:1.27.4(Harbor proxy, digest-pinned) +GOTOOLCHAIN=localFROMthe Harbor-approvedapache/spark:4.2.1mirror (c.rzp.io/razorpay-external) — no non-Harbor base findingapt upgrade+ removegosu(operator uses catatonit, runs non-root uid 185)patched-jars.pom.xml/settings.xml— jar-swap manifest + GCS Maven Central mirror..github/workflows/razorpay-image-build-push.yaml— build + push to Harbor per-arch + multi-arch manifest (samerazorpay/docker-image-build-pushaction datahub uses).Local Trivy verification
Follow-ups
HARBOR_DOCKER_USERNAME/HARBOR_DOCKER_PASSWORD(Harbor robot) so the workflow can push.rzp-docker-image-inventoryas a custom base image.🤖 Generated with Claude Code