-
Notifications
You must be signed in to change notification settings - Fork 686
feat: hardening of containers #3328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
d14c852
ed488e0
70fa831
755f670
f62169e
6a00153
a417e7a
02deadf
7f9b08f
794acfd
52a78b2
4498432
a0b19e4
93efc43
b1d5fcb
76d6b52
83dc567
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ if [ ! -n "$DJANGO_SETTINGS_MODULE" ]; then | |
| fi | ||
| if [ ! -n "$DJANGO_SECRET_KEY" ]; then | ||
| if [ ! -f db/django_secret_key ]; then | ||
| cat /proc/sys/kernel/random/uuid >db/django_secret_key | ||
| install -m 600 <(cat /proc/sys/kernel/random/uuid) db/django_secret_key | ||
|
||
| echo "generating initial Django secret key" | ||
| fi | ||
| export DJANGO_SECRET_KEY=$(<db/django_secret_key) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,10 @@ services: | |
| - CISO_ASSISTANT_URL=https://{{ fqdn }}:{{ port }} | ||
| - DJANGO_DEBUG={{ enable_debug }} | ||
| - AUTH_TOKEN_TTL=7200 | ||
| - HOME=/tmp | ||
| - XDG_CACHE_HOME=/tmp/.cache | ||
| - XDG_CONFIG_HOME=/tmp/.config | ||
| - XDG_DATA_HOME=/tmp/.local/share | ||
|
Comment on lines
+35
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Backend is missing The environment variables were added, but the runtime hardening block that every other compose file applies to backend is absent here. Compare with Proposed fix — add the missing hardening block to backend - XDG_DATA_HOME=/tmp/.local/share
- POSTGRES_NAME={{ postgres.name }}
...
+ read_only: true
+ cap_drop:
+ - ALL
+ security_opt:
+ - no-new-privileges:true
+ tmpfs:
+ - /tmp:rw,noexec,nosuid,nodev
volumes:
- ./db:/code/db
+ user: "1001:1001"
healthcheck:🤖 Prompt for AI Agents |
||
| - POSTGRES_NAME={{ postgres.name }} | ||
| - POSTGRES_USER={{ postgres.user }} | ||
| {% if postgres.password is defined %} | ||
|
|
@@ -75,6 +79,10 @@ services: | |
| - CISO_ASSISTANT_URL=https://{{ fqdn }}:{{ port }} | ||
| - DJANGO_DEBUG=False | ||
| - AUTH_TOKEN_TTL=7200 | ||
| - HOME=/tmp | ||
| - XDG_CACHE_HOME=/tmp/.cache | ||
| - XDG_CONFIG_HOME=/tmp/.config | ||
| - XDG_DATA_HOME=/tmp/.local/share | ||
| - POSTGRES_NAME={{ postgres.name }} | ||
| - POSTGRES_USER={{ postgres.user }} | ||
| {% if postgres.password is defined %} | ||
|
|
@@ -89,8 +97,16 @@ services: | |
| - EMAIL_HOST_PASSWORD={{ email.password }} | ||
| - DEFAULT_FROM_EMAIL={{ email.from_email }} | ||
| {% endif %} | ||
| read_only: true | ||
| cap_drop: | ||
| - ALL | ||
| security_opt: | ||
| - no-new-privileges:true | ||
| tmpfs: | ||
| - /tmp:rw,noexec,nosuid,nodev | ||
| volumes: | ||
| - ./db:/code/db | ||
| user: "1001:1001" | ||
| entrypoint: | ||
| - /bin/sh | ||
| - -c | ||
|
|
@@ -104,11 +120,16 @@ services: | |
| - PUBLIC_BACKEND_API_EXPOSED_URL=https://{{ fqdn }}:{{ port }}/api | ||
| - PROTOCOL_HEADER=x-forwarded-proto | ||
| - HOST_HEADER=x-forwarded-host | ||
| - HOME=/tmp | ||
| - XDG_CACHE_HOME=/tmp/.cache | ||
| - XDG_CONFIG_HOME=/tmp/.config | ||
| - XDG_DATA_HOME=/tmp/.local/share | ||
| image: ghcr.io/intuitem/ciso-assistant-community/frontend:latest | ||
| pull_policy: always | ||
| depends_on: | ||
| backend: | ||
| condition: service_healthy | ||
| user: "1001:1001" | ||
| labels: | ||
| - "traefik.enable=true" | ||
| - "traefik.http.routers.frontend.rule=Host(`{{ fqdn }}`) && PathPrefix(`/`)" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,10 @@ services: | |
| - CISO_ASSISTANT_URL=https://{{ fqdn }}:{{ port }} | ||
| - DJANGO_DEBUG={{ enable_debug }} | ||
| - AUTH_TOKEN_TTL=7200 | ||
| - HOME=/tmp | ||
| - XDG_CACHE_HOME=/tmp/.cache | ||
| - XDG_CONFIG_HOME=/tmp/.config | ||
| - XDG_DATA_HOME=/tmp/.local/share | ||
|
Comment on lines
+12
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, verify the file exists and check its overall structure
fd -e yml -e j2 'docker-compose-sqlite-caddy' && echo "File found"Repository: intuitem/ciso-assistant-community Length of output: 202 🏁 Script executed: # Check backend, huey, and frontend services for hardening markers
file_path=$(fd -e yml -e j2 'docker-compose-sqlite-caddy')
if [ -n "$file_path" ]; then
echo "=== File structure and service locations ==="
cat -n "$file_path" | head -100
fiRepository: intuitem/ciso-assistant-community Length of output: 293 🏁 Script executed: # Check for hardening markers in each service section
file_path=$(fd -e yml -e j2 'docker-compose-sqlite-caddy')
if [ -n "$file_path" ]; then
echo "=== Backend hardening check ==="
awk '/^ backend:/,/^ [a-z_]/ {print NR": "$0}' "$file_path" | head -30
echo ""
echo "=== Huey hardening check ==="
awk '/^ huey:/,/^ [a-z_]/ {print NR": "$0}' "$file_path" | head -50
echo ""
echo "=== Frontend hardening check ==="
awk '/^ frontend:/,/^ [a-z_]/ {print NR": "$0}' "$file_path" | head -30
fiRepository: intuitem/ciso-assistant-community Length of output: 744 🏁 Script executed: # Also check docker-compose-build.yml for backend hardening
echo "=== Checking docker-compose-build.yml backend hardening ==="
if fd -e yml 'docker-compose-build' > /dev/null; then
build_file=$(fd -e yml 'docker-compose-build')
awk '/^ backend:/,/^ [a-z_]/ {print NR": "$0}' "$build_file" | grep -E '(read_only|cap_drop|user:|security_opt|tmpfs)' || echo "No hardening markers found in docker-compose-build.yml backend"
fiRepository: intuitem/ciso-assistant-community Length of output: 347 🏁 Script executed: # Read the main config file with proper newline handling
file_path=$(fd -e yml -e j2 'docker-compose-sqlite-caddy' | head -1)
echo "Reading: $file_path"
wc -l "$file_path"Repository: intuitem/ciso-assistant-community Length of output: 193 🏁 Script executed: # Read the full file to see structure
file_path=$(fd -e yml -e j2 'docker-compose-sqlite-caddy' | head -1)
cat -n "$file_path"Repository: intuitem/ciso-assistant-community Length of output: 6449 🏁 Script executed: # Find and read docker-compose-build.yml
build_file=$(fd -e yml 'docker-compose-build' | head -1)
if [ -n "$build_file" ]; then
echo "Found: $build_file"
wc -l "$build_file"
echo "=== Backend service section ==="
awk '/^ backend:/,/^ [a-z_]/ {print NR": "$0}' "$build_file"
fiRepository: intuitem/ciso-assistant-community Length of output: 182 🏁 Script executed: # Read the entire docker-compose-build.yml file
build_file=$(fd -e yml 'docker-compose-build' | head -1)
cat -n "$build_file"Repository: intuitem/ciso-assistant-community Length of output: 3147 Backend service is missing runtime hardening that's applied to huey and frontend. The backend gets the HOME/XDG env vars but lacks If this is intentional (e.g., backend needs write access for migrations at startup), document it inline with a comment. Otherwise, align the backend hardening with the other services. 🤖 Prompt for AI Agents |
||
| {% if need_mailer %} | ||
| - EMAIL_HOST={{ email.host }} | ||
| - EMAIL_PORT={{ email.port }} | ||
|
|
@@ -39,6 +43,10 @@ services: | |
| - CISO_ASSISTANT_URL=https://{{ fqdn }}:{{ port }} | ||
| - DJANGO_DEBUG=False | ||
| - AUTH_TOKEN_TTL=7200 | ||
| - HOME=/tmp | ||
| - XDG_CACHE_HOME=/tmp/.cache | ||
| - XDG_CONFIG_HOME=/tmp/.config | ||
| - XDG_DATA_HOME=/tmp/.local/share | ||
| {% if need_mailer %} | ||
| - EMAIL_HOST={{ email.host }} | ||
| - EMAIL_PORT={{ email.port }} | ||
|
|
@@ -47,8 +55,16 @@ services: | |
| - EMAIL_HOST_PASSWORD={{ email.password }} | ||
| - DEFAULT_FROM_EMAIL={{ email.from_email }} | ||
| {% endif %} | ||
| read_only: true | ||
| cap_drop: | ||
| - ALL | ||
| security_opt: | ||
| - no-new-privileges:true | ||
| tmpfs: | ||
| - /tmp:rw,noexec,nosuid,nodev | ||
| volumes: | ||
| - ./db:/code/db | ||
| user: "1001:1001" | ||
| entrypoint: | ||
| - /bin/sh | ||
| - -c | ||
|
|
@@ -62,11 +78,23 @@ services: | |
| - PUBLIC_BACKEND_API_EXPOSED_URL=https://{{ fqdn }}:{{ port }}/api | ||
| - PROTOCOL_HEADER=x-forwarded-proto | ||
| - HOST_HEADER=x-forwarded-host | ||
| - HOME=/tmp | ||
| - XDG_CACHE_HOME=/tmp/.cache | ||
| - XDG_CONFIG_HOME=/tmp/.config | ||
| - XDG_DATA_HOME=/tmp/.local/share | ||
| image: ghcr.io/intuitem/ciso-assistant-community/frontend:latest | ||
| pull_policy: always | ||
| read_only: true | ||
| cap_drop: | ||
| - ALL | ||
| security_opt: | ||
| - no-new-privileges:true | ||
| tmpfs: | ||
| - /tmp:rw,noexec,nosuid,nodev | ||
| depends_on: | ||
| backend: | ||
| condition: service_healthy | ||
| user: "1001:1001" | ||
|
|
||
| caddy: | ||
| container_name: caddy | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.