Skip to content

fix: remediate all 24 security vulnerabilities#2

Open
gadaugherty wants to merge 10 commits intomain-insecurefrom
main-secure
Open

fix: remediate all 24 security vulnerabilities#2
gadaugherty wants to merge 10 commits intomain-insecurefrom
main-secure

Conversation

@gadaugherty
Copy link
Copy Markdown
Owner

Security Remediation

Fixes all 24 vulnerabilities identified in the security audit.

Pipeline Results

  • main-secure: All 12 jobs passing, Security Gate ALL CLEAR
  • main-insecure: Pipeline catches hardcoded secrets, dependency CVEs, SQL injection

Changes

Application (auth-api, payments):

  • Parameterized SQL queries (fixes SQLi)
  • JWT secret + DB credentials from environment variables
  • PBKDF2 password hashing with per-user salt
  • Authentication middleware, authorization checks
  • Generic error messages, debug mode disabled

Infrastructure (terraform):

  • S3: public access block, KMS encryption, versioning
  • RDS: private subnet, encryption at rest
  • IAM: least-privilege policies
  • EKS: private endpoint, secrets encryption

Containers (Dockerfiles):

  • Non-root users, multi-stage builds, distroless bases
  • Pinned images, removed chmod 777

Kubernetes:

  • Secrets via secretKeyRef, security contexts
  • Resource limits, network policies, ClusterIP services

See VULNERABILITIES.md for the complete catalog of 24 vulnerabilities.

- README.md: Architecture, 11 ADRs, pipeline enforcement policy
- VULNERABILITIES.md: 24 planted vulnerabilities with CWE refs
- .gitleaks.toml: Secret detection config with doc allowlist
- .trivyignore: Dependency vulnerability exception template
- .github/pull_request_template.md: Security checklist
- Pipeline: replaced broken actions with CLI installs
  (gitleaks, semgrep, gosec all use direct CLI now)
Application Layer:
- VULN-001: Parameterized SQL queries (auth-api + payments)
- VULN-002: JWT secret from environment variable
- VULN-003: DB credentials from environment variables
- VULN-004: PBKDF2-HMAC-SHA256 password hashing with per-user salt
- VULN-005: JWT authentication middleware on sensitive endpoints
- VULN-006: Authorization checks prevent IDOR
- VULN-007: Removed dangerouslySetInnerHTML, use text content
- VULN-008: Generic error messages, detailed logging server-side
- VULN-009: debug=False, gunicorn in production
- VULN-010: JWT exp claim (1 hour expiry)
- VULN-011: Redacted sensitive data from logs

Infrastructure Layer:
- VULN-012: S3 public access block, KMS encryption, versioning
- VULN-013: RDS private subnet, encryption at rest, deletion protection
- VULN-014: Restrictive security groups, VPC flow logs
- VULN-015: Least-privilege IAM policies
- VULN-016: EKS private endpoint, KMS secrets encryption, audit logging

Container Layer:
- VULN-017: Non-root users (appuser/65534/nginx-unprivileged)
- VULN-018: Removed chmod 777, restrictive permissions
- VULN-019: Pinned base images, multi-stage builds, distroless

Kubernetes Layer:
- VULN-020: Kubernetes Secrets with secretKeyRef
- VULN-021: Security context (privileged:false, drop ALL capabilities)
- VULN-022: CPU/memory requests and limits
- VULN-023: Default-deny NetworkPolicy with explicit allow rules
- VULN-024: ClusterIP services (removed LoadBalancer)

Dependencies:
- Python: pinned all deps, python:3.13-slim + apt-get upgrade
- Frontend: npm overrides for transitive CVEs, package-lock.json
- .trivyignore: PyJWT CVE-2026-32597 (no fix available)
.gitleaks.toml: allowlist docker-compose.yml and kubernetes/base/secrets.yml
  (local dev credentials and K8s secret placeholders)

.trivyignore: add CVE exceptions with justifications
  - CVE-2026-32597: PyJWT (no fix available, 2.12.0 unreleased)
  - GHSA-5c6j-r48x-rmvq: serialize-javascript (build-time only)
  - CVE-2026-27601: underscore (build-time only)
The aquasecurity/trivy-action does not pass .trivyignore to the scanner.
Replaced with direct Trivy CLI installation and execution for both
SCA (filesystem) and container scans.

SCA: trivy fs --ignorefile .trivyignore --exit-code 1 (blocks on CRITICAL/HIGH)
Container: trivy image --ignore-unfixed --exit-code 0 (warnings only)
v0.58.1 has an older vulnerability DB that doesn't match the CVE IDs
in .trivyignore. Using latest ensures DB compatibility with our
ignore entries.
- payments/go.sum: regenerated with go mod tidy (fixes checksum mismatch)
- frontend/package-lock.json: regenerated with npm ci (fixes build failure)
serialize-javascript>=7.0.3 requires the crypto global which is only
available in Node 20+. Node 18 throws ReferenceError: crypto is not defined.
- DB schema: account_number column, transactions use account numbers
- Auth API: returns account_number, generates on registration
- Payments: uses from_account/to_account with parameterized queries
- Frontend: same UI as insecure branch (account numbers, chatbot, settings)
- .gitignore: exclude .venv, node_modules, build artifacts
Comment thread auth-api/app.py
# VULNERABILITY: Debug mode enabled in production (CWE-489)
app.run(host="0.0.0.0", port=5000, debug=True)
# FIX: Debug mode disabled
app.run(host="0.0.0.0", port=5000, debug=False)
Comment thread terraform/eks.tf
Comment on lines +36 to +40
resource "aws_kms_key" "eks" {
description = "EKS cluster secrets encryption"
deletion_window_in_days = 7
enable_key_rotation = true
}
Comment thread terraform/eks.tf
Comment on lines +80 to +99
resource "aws_security_group" "eks_cluster" {
name = "vulnbank-eks-cluster"
description = "EKS cluster security group"
vpc_id = aws_vpc.main.id

# Only allow node group to communicate with control plane
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
security_groups = [aws_security_group.eks_nodes.id]
}

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [aws_vpc.main.cidr_block]
}
}
Comment thread terraform/eks.tf
Comment on lines +101 to +121
resource "aws_security_group" "eks_nodes" {
name = "vulnbank-eks-nodes"
description = "EKS node group security group"
vpc_id = aws_vpc.main.id

# Nodes communicate with each other
ingress {
from_port = 0
to_port = 0
protocol = "-1"
self = true
}

# Nodes communicate with control plane
egress {
from_port = 443
to_port = 443
protocol = "tcp"
security_groups = [aws_security_group.eks_cluster.id]
}
}
Comment thread terraform/eks.tf
Comment on lines +101 to +121
resource "aws_security_group" "eks_nodes" {
name = "vulnbank-eks-nodes"
description = "EKS node group security group"
vpc_id = aws_vpc.main.id

# Nodes communicate with each other
ingress {
from_port = 0
to_port = 0
protocol = "-1"
self = true
}

# Nodes communicate with control plane
egress {
from_port = 443
to_port = 443
protocol = "tcp"
security_groups = [aws_security_group.eks_cluster.id]
}
}
Comment thread terraform/network.tf
Comment on lines +22 to +25
resource "aws_cloudwatch_log_group" "flow_logs" {
name = "/vpc/vulnbank-flow-logs"
retention_in_days = 90
}
Comment thread terraform/s3.tf
Comment on lines +48 to +50
resource "aws_s3_bucket" "logs" {
bucket = "vulnbank-access-logs"
}
Comment thread terraform/s3.tf
Comment on lines +48 to +50
resource "aws_s3_bucket" "logs" {
bucket = "vulnbank-access-logs"
}
Comment thread terraform/s3.tf
Comment on lines +48 to +50
resource "aws_s3_bucket" "logs" {
bucket = "vulnbank-access-logs"
}
Comment thread terraform/s3.tf
Comment on lines +48 to +50
resource "aws_s3_bucket" "logs" {
bucket = "vulnbank-access-logs"
}
Comment thread terraform/s3.tf
Comment on lines +48 to +50
resource "aws_s3_bucket" "logs" {
bucket = "vulnbank-access-logs"
}
Resolves conflicts keeping secure backend code while adopting
the updated frontend UI (account numbers, chatbot, settings).
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.

2 participants