Skip to content

fix(helm): declare securityContext for fakeidp and keycloak (#2084) - #2085

Merged
Gregory91G merged 1 commit into
security-hardeningfrom
fix/securitycontext-fakeidp-keycloak
Aug 1, 2026
Merged

fix(helm): declare securityContext for fakeidp and keycloak (#2084)#2085
Gregory91G merged 1 commit into
security-hardeningfrom
fix/securitycontext-fakeidp-keycloak

Conversation

@Gregory91G

Copy link
Copy Markdown
Contributor

Closes #2084.

Both Deployments declared no securityContext, so their containers could escalate privileges and kept the full default capability set. Adopts the shape already used by src/backend/services/gateway/helm.

fakeidp keycloak
runAsNonRoot / UID / GID / fsGroup 1000 yes yes
allowPrivilegeEscalation: false yes yes
capabilities.drop: ["ALL"] yes yes
readOnlyRootFilesystem: true yes no — see below

Neither image's runtime user changes: fakeidp already carries USER 1000 and upstream quay.io/keycloak/keycloak ships non-root. The charts simply never asserted it.

readOnlyRootFilesystem is omitted for keycloak because start-dev re-augments Quarkus into /opt/keycloak/lib/quarkus on every boot. Making it work needs an initContainer that pre-populates that path from the image, which is not worth the failure mode on the component that owns login. AVD-KSV-0014 stays reported for keycloak; the misconfig scan is report-only, so nothing is suppressed and no waiver file is introduced.

Test plan

  • helm template renders both charts — 83 and 115 lines, no template errors
  • trivy fs --scanners misconfig --severity HIGH,CRITICAL on the rendered output: 6 HIGH → 1 HIGH. fakeidp fully clean (KSV-0014 + 2× KSV-0118 gone); keycloak keeps only KSV-0014
  • fakeidp under the full set, including read-only root FS (docker run --read-only --user 1000:1000 --cap-drop ALL --security-opt no-new-privileges): starts, /.well-known/openid-configuration → 200, jwks_uri → 200
  • keycloak under the set as shipped here: starts in 5.9s, /kc/realms/master/.well-known/openid-configuration → 200
  • keycloak with readOnlyRootFilesystem: true and no volumes: fails — ReadOnlyFileSystemException in Quarkus JarResultBuildStep
  • keycloak with readOnlyRootFilesystem: true + emptyDir on /opt/keycloak/data, /opt/keycloak/lib/quarkus, /tmp: fails — NoSuchFileException: /opt/keycloak/lib/quarkus/quarkus-application.dat
  • Both pods reach Ready in insight-dev after the chart rolls out

@Gregory91G
Gregory91G requested a review from a team as a code owner July 31, 2026 02:28
@Gregory91G Gregory91G self-assigned this Jul 31, 2026
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6b96ccdf-f846-4db8-b3ac-d2dbc3e0f0b5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Gregory91G
Gregory91G changed the base branch from main to security-hardening July 31, 2026 08:51
Both Deployments ran with the default context, so a container could escalate
privileges and kept the full capability set. Adopt the shape already used by
the gateway chart: non-root UID/GID 1000 at pod level, no privilege
escalation and all capabilities dropped at container level.

fakeidp additionally gets readOnlyRootFilesystem — it never writes to disk.
keycloak does not: start-dev re-augments Quarkus into /opt/keycloak/lib/quarkus
on every boot, and backing that path with an emptyDir hides the image's
quarkus-application.dat.

Signed-off-by: Gregory Gogin <grigoriy.gogin@constructor.tech>
@Gregory91G
Gregory91G force-pushed the fix/securitycontext-fakeidp-keycloak branch from f02c831 to 39341c5 Compare July 31, 2026 18:05
@Gregory91G
Gregory91G merged commit d0d389a into security-hardening Aug 1, 2026
2 checks passed
@Gregory91G
Gregory91G deleted the fix/securitycontext-fakeidp-keycloak branch August 1, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fakeidp and keycloak Deployments declare no securityContext

3 participants