Skip to content

Razorpay: hardened operator image from source + Harbor base (0 Go CVEs) - #1

Open
jainanuj07 wants to merge 5 commits into
masterfrom
feature/razorpay-hardened-from-source
Open

jainanuj07 wants to merge 5 commits into
masterfrom
feature/razorpay-hardened-from-source

Conversation

@jainanuj07

Copy link
Copy Markdown

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/spark base + 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 — 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.
  • 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) — no non-Harbor base finding
    • apt upgrade + remove gosu (operator uses catatonit, runs non-root uid 185)
    • swap vulnerable standalone jars for patched versions (GCS Maven mirror), verified fail-closed
  • 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 (same razorpay/docker-image-build-push action datahub uses).

Local Trivy verification

Layer Result
Go operator binary 0 CVEs (was 22 upstream / 12 on fork's prior deps)
OS packages (ubuntu 22.04 + apt upgrade) 0 CRITICAL / 0 HIGH
Standalone jars (swapped) 0
gosu Go-EOL removed
Shaded fat-jars residual (exception floor — same as the Spark base)

Follow-ups

  • Add repo secrets HARBOR_DOCKER_USERNAME / HARBOR_DOCKER_PASSWORD (Harbor robot) so the workflow can push.
  • Whitelist the pushed image in rzp-docker-image-inventory as a custom base image.

🤖 Generated with Claude Code

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>
Comment thread Dockerfile
# 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

Suggested change
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
  1. Replace the proxy Docker Hub image with the approved Harbor-hosted Maven golden image while keeping the jars stage name:
    FROM c.rzp.io/razorpay/rzp-docker-image-inventory-multi-arch:rzp-golden-image-base-maven-3.9-eclipse-temurin-21 AS jars

  2. If the repository uses a configurable registry, define the registry before the FROM instruction 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

  3. 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.

Comment thread Dockerfile
# 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

Suggested change
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
  1. Replace the c.rzp.io/proxy_dockerhub/... builder image with the approved Harbor or Razorpay golden Go image for Go 1.27.4, using its immutable digest. For example: FROM c.rzp.io/razorpay/<approved-golang-image>:1.27.4@sha256:<approved-digest> AS builder.
  2. Keep the AS builder alias and all subsequent build steps unchanged.
  3. Do not use c.rzp.io/proxy_dockerhub/... or c.rzp.io/proxy_quay/...; these proxy namespaces are not accepted by the policy.
  4. Confirm that the replacement image provides the Go toolchain required by GOTOOLCHAIN=local and 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.

jainanuj07 and others added 4 commits November 25, 2026 18:59
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>
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.

1 participant