Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

ci: add config and deployment security scanning (#85)

Tanner Kocher130a68b20f7a
diff --git a/.github/workflows/config-security.yml b/.github/workflows/config-security.yml
new file mode 100644
index 00000000..ec315491
--- /dev/null
+++ b/.github/workflows/config-security.yml
@@ -0,0 +1,35 @@
+name: Config Security
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+ branches: [main]
+
+permissions:
+ contents: read
+
+jobs:
+ trivy-misconfig:
+ name: Trivy config scan
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+
+ - name: Run Trivy misconfig scanner
+ uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
+ with:
+ scan-type: fs
+ scanners: misconfig
+ severity: HIGH,CRITICAL
+ exit-code: 1
+ hide-progress: true
+
+ policy-checks:
+ name: Deployment policy checks
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+
+ - name: Run config security checks
+ run: bash scripts/ci/check-config-security.sh
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8f55808e..b1bc125f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -117,8 +117,9 @@ PRs and pushes to `main` run automated security checks:
- **Dependency review** — flags new dependencies with known vulnerabilities (PRs only)
- **Trivy scanning** — scans the repo filesystem and Docker image for vulnerabilities and misconfigurations
+- **Config security** — scans Docker Compose and deployment configs for unsafe exposure (e.g., auth disabled with public port bindings, `0.0.0.0` bindings). Local-only configs that bind to `127.0.0.1` are allowed.
-Both checks fail on CRITICAL or HIGH severity findings. If a check fails on your PR, inspect the output and either fix the vulnerability or document why it's a false positive.
+All checks fail on CRITICAL or HIGH severity findings. If a check fails on your PR, inspect the output and either fix the vulnerability or document why it's a false positive.
## OSS vs Pro Boundary
diff --git a/scripts/ci/check-config-security.sh b/scripts/ci/check-config-security.sh
new file mode 100755
index 00000000..80033551
--- /dev/null
+++ b/scripts/ci/check-config-security.sh
@@ -0,0 +1,96 @@
+#!/usr/bin/env bash
+# Config Security Policy Checks
+#
+# Enforces deployment safety invariants for Docker Compose files:
+# - If auth is disabled (ARANGO_NO_AUTH), all ports must bind to 127.0.0.1
+# - If database password is empty, all ports must bind to 127.0.0.1
+# - No port bindings to 0.0.0.0 in compose files
+#
+# Exit 0 = all checks pass, Exit 1 = policy violation found.
+
+set -euo pipefail
+
+ERRORS=0
+CHECKED=0
+
+err() { printf " \033[31m[FAIL]\033[0m %s\n" "$*" >&2; ERRORS=$((ERRORS + 1)); }
+ok() { printf " \033[32m[PASS]\033[0m %s\n" "$*"; }
+info() { printf " \033[36m[INFO]\033[0m %s\n" "$*"; }
+
+# Find all docker-compose files
+COMPOSE_FILES=$(find . -maxdepth 3 -name 'docker-compose*.yml' -o -name 'docker-compose*.yaml' | grep -v node_modules | grep -v '.git/' | sort)
+
+if [ -z "$COMPOSE_FILES" ]; then
+ info "No docker-compose files found — skipping"
+ exit 0
+fi
+
+for file in $COMPOSE_FILES; do
+ info "Checking $file"
+ CHECKED=$((CHECKED + 1))
+
+ # Check for auth-disabled patterns
+ has_no_auth=false
+ has_empty_password=false
+
+ if grep -qE 'ARANGO_NO_AUTH.*["\x27]?1["\x27]?' "$file" 2>/dev/null; then
+ has_no_auth=true
+ fi
+
+ if grep -qE 'ARANGO_PASSWORD:\s*["\x27]{2}' "$file" 2>/dev/null || \
+ grep -qE 'ARANGO_PASSWORD:\s*$' "$file" 2>/dev/null; then
+ has_empty_password=true
+ fi
+
+ # Extract port bindings (lines matching "- <host>:<container>" pattern)
+ # Valid: "127.0.0.1:8529:8529" Invalid: "0.0.0.0:8529:8529" or "8529:8529"
+ port_lines=$(grep -nE '^\s*-\s*["\x27]?[0-9]' "$file" 2>/dev/null || true)
+
+ if [ -n "$port_lines" ]; then
+ # Check for 0.0.0.0 bindings (always bad in compose files)
+ if echo "$port_lines" | grep -qE '0\.0\.0\.0:'; then
+ err "$file: port binding to 0.0.0.0 — must use 127.0.0.1 for local-only services"
+ fi
+
+ # Check for unqualified port bindings (e.g., "8529:8529" without IP)
+ # These bind to all interfaces by default
+ while IFS= read -r line; do
+ [ -z "$line" ] && continue
+ # Strip grep line number prefix, leading whitespace, dash, and quotes
+ port_val=$(echo "$line" | sed "s/^[0-9]*://; s/^[[:space:]]*-[[:space:]]*//; s/[\"']//g")
+ # If it's just port:port (no IP prefix), it binds to all interfaces
+ if echo "$port_val" | grep -qE '^[0-9]+:[0-9]+$'; then
+ if [ "$has_no_auth" = true ] || [ "$has_empty_password" = true ]; then
+ err "$file: unqualified port binding '$port_val' with auth disabled — must prefix with 127.0.0.1:"
+ fi
+ fi
+ done <<< "$port_lines"
+ fi
+
+ # If auth is disabled, verify ALL port bindings are localhost-only
+ if [ "$has_no_auth" = true ] || [ "$has_empty_password" = true ]; then
+ reason=""
+ [ "$has_no_auth" = true ] && reason="ARANGO_NO_AUTH=1"
+ [ "$has_empty_password" = true ] && reason="${reason:+$reason, }empty ARANGO_PASSWORD"
+
+ # Check that every port binding starts with 127.0.0.1
+ non_local=$(echo "$port_lines" | grep -vE '127\.0\.0\.1:' | grep -vE '^\s*$' || true)
+ if [ -z "$non_local" ]; then
+ ok "$file: auth relaxed ($reason) but all ports bound to 127.0.0.1"
+ fi
+ else
+ ok "$file: auth configuration looks safe"
+ fi
+done
+
+echo ""
+info "Checked $CHECKED compose file(s)"
+
+if [ "$ERRORS" -gt 0 ]; then
+ echo ""
+ err "Found $ERRORS policy violation(s)"
+ exit 1
+fi
+
+ok "All config security checks passed"
+exit 0