Skip to content

Conversation

fernandezcuesta
Copy link
Contributor

@fernandezcuesta fernandezcuesta commented Sep 17, 2025

Description

This is a complement of #12691 which addressed some Helm chart refactoring, but failed to allow securityContext as well as mounted volumes and resources for all containers and initContainers.

For example, when PSS policies are enforced, we may need to specify readOnlyRootFilesystem: false and mount tmpfs volues in all (init)containers. This PR closes the gaps left from #12691.

Test results

Tested in a production instance from a fork.

Documentation
n/a

@github-actions github-actions bot added the helm label Sep 17, 2025
@fernandezcuesta fernandezcuesta marked this pull request as ready for review September 17, 2025 20:20
Copy link

dryrunsecurity bot commented Sep 17, 2025

DryRun Security

This pull request introduces an insecure Helm chart change that writes untrusted .Values.localsettingspy directly into a ConfigMap mounted as /app/dojo/settings/local_settings.py for django, celery-beat, and celery-worker containers, allowing an attacker with Helm value injection permissions to execute arbitrary Python code on startup (RCE). The finding recommends removing direct injection of raw Python into a mounted settings file or otherwise validating/escaping values and using safer configuration patterns.

Arbitrary Content Injection (RCE) in helm/defectdojo/templates/configmap-local-settings-py.yaml
Vulnerability Arbitrary Content Injection (RCE)
Description The Helm chart allows arbitrary content from .Values.localsettingspy to be directly injected into a ConfigMap named {{ $fullName }}-localsettingspy. This ConfigMap is then mounted as /app/dojo/settings/local_settings.py in the celery-beat, celery-worker, and django application containers. In Django applications, local_settings.py is typically imported and executed as Python code during application startup. An attacker with permissions to set Helm values can inject malicious Python code into .Values.localsettingspy, which will be executed by the application, leading to Remote Code Execution (RCE).

{{ toYaml .Values.localsettingspy | indent 4 }}


All finding details can be found in the DryRun Security Dashboard.

@fernandezcuesta
Copy link
Contributor Author

@kiblik I came across some missing gaps from my last chart PR, should be quite straightforward and I hope I didn't miss anything this time

@mtesauro mtesauro requested review from kiblik and rossops September 18, 2025 02:11
Copy link
Contributor

@kiblik kiblik left a comment

Choose a reason for hiding this comment

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

Couple of comments

@kiblik
Copy link
Contributor

kiblik commented Sep 19, 2025

Now I'm thinking, there are Pod SecurityContext and Container SecurityContext. Some parts overlap (e.g., runAsNonRoot), but some are exclusive (e.g,. allowPrivilegeEscalation or fsGroup)

$ curl https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/master/securitycontext.json | jq '.properties | keys '
 [
  "allowPrivilegeEscalation",
  "appArmorProfile",
  "capabilities",
  "privileged",
  "procMount",
  "readOnlyRootFilesystem",
  "runAsGroup",
  "runAsNonRoot",
  "runAsUser",
  "seLinuxOptions",
  "seccompProfile",
  "windowsOptions"
]
$ curl https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/master/podsecuritycontext.json | jq '.properties | keys '
[
  "appArmorProfile",
  "fsGroup",
  "fsGroupChangePolicy",
  "runAsGroup",
  "runAsNonRoot",
  "runAsUser",
  "seLinuxChangePolicy",
  "seLinuxOptions",
  "seccompProfile",
  "supplementalGroups",
  "supplementalGroupsPolicy",
  "sysctls",
  "windowsOptions"
]

It would be good idea to separate them. I'm not sure how it is usually done in other projects.

@fernandezcuesta
Copy link
Contributor Author

fernandezcuesta commented Sep 22, 2025

okay, did some (not small) changes to split pod <> container security Contexts and some other changes (annotations -> extraAnnotations to align with labels, add them everywhere).

I'll need more time to see where I added a regression in the tests :rage1:

Also, release notes are pending but that will come later 🙏

@kiblik
Copy link
Contributor

kiblik commented Sep 24, 2025

@fernandezcuesta, can you please rebase from dev branch? Tests should stop failing.

Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@github-actions github-actions bot added the docs label Oct 1, 2025
Copy link
Contributor

@kiblik kiblik left a comment

Choose a reason for hiding this comment

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

Just one change ({} vs. nil).

@valentijnscholten valentijnscholten modified the milestones: 2.51.0, 2.52.0 Oct 6, 2025
Copy link
Contributor

@mtesauro mtesauro left a comment

Choose a reason for hiding this comment

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

Approved

@Maffooch Maffooch merged commit 4f38f2f into DefectDojo:dev Oct 7, 2025
149 checks passed
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.

6 participants