APT-style DevSecOps security lab on GCP that demonstrates offensive paths and defensive controls in one reproducible environment.
Educational and authorized lab use only. This repo includes deliberately weak or vulnerable configurations (for example vulnerable-pool, demo node images, and proof-of-concept exploits under exploits/) to teach GKE security, WIF, Falco, Trivy, and detection pipelines. Use only in a disposable GCP project you control, with no production data and no traffic to third-party systems. Do not run scenarios against infrastructure you do not own or lack explicit written permission to test. You alone are responsible for legal compliance and organizational policy.
- Disclaimer (read first)
- Infographic: pipeline at a glance
- What This Project Is For
- Architecture at a Glance
- Case study:
parse_trivy_bq.py - How to Install and Use (3 commands)
- Repository Layout
- Prerequisites
- Quick Start
- Pipelines and Evidence Flow
- Security Scenarios Included
- CI Identity Model
- Troubleshooting
- Suggested GitHub Topics (Project Tags)
- Documentation Index
- References
- Contributing
This repository is built for technical assessment and training:
- Kubernetes security scenarios (
container escape,control-plane stress,CI/WIF abuse simulation) - Defensive stack (
Falco,NetworkPolicy, hardened WIF conditions, Shielded nodes) - Detection and analytics pipeline (
Cloud Logging -> BigQuery -> parser -> clean vulnerability table)
One-page flow for recruiters / README preview (same path is detailed below and in
docs/).
flowchart LR
GKE[GKE workloads]
TV[Trivy Operator]
LR[Log Router]
SK[Logging sink]
BQ[(BigQuery)]
PY[parse_trivy_bq.py]
GKE --> TV --> LR --> SK --> BQ --> PY
apt-defense-lab is an isolated, non-production lab for:
- demonstrating realistic attacker behavior in cloud-native environments
- validating detection and prevention controls
- proving traceability from runtime signals to structured evidence
- comparing intentionally vulnerable vs hardened CI identity flows
Do not run exploit scenarios outside disposable lab projects you own.
GitHub Actions (PR / push / dispatch)
| OIDC -> Workload Identity Federation (lab/prod pools)
v
GCP service accounts (cicd-lab / cicd-plan / cicd-apply)
v
GKE Standard (lab-cluster)
- vulnerable-pool (demo attack surface)
- hardened-pool (shielded/hardened baseline)
- trivy-operator (scan results in logs)
- falco (runtime detection)
- network policies (egress control)
Cloud Logging sink -> BigQuery dataset (trivy_logs)
v
scripts/parse_trivy_bq.py -> clean_vulnerabilities
flowchart TB
subgraph CI["GitHub Actions"]
A[Workflows: vulnerable / hardened / apply]
end
subgraph GCP["GCP"]
WIF[Workload Identity Federation]
SA[Service accounts: cicd-lab / plan / apply]
GKE[GKE lab-cluster]
subgraph Pools["Node pools"]
V[vulnerable-pool]
H[hardened-pool]
end
T[Trivy operator]
F[Falco]
NP[NetworkPolicy]
LOG[Cloud Logging]
BQ[(BigQuery: trivy_logs)]
P[parse_trivy_bq.py → clean_vulnerabilities]
end
CI --> WIF
WIF --> SA
SA --> GKE
GKE --> Pools
GKE --> T
GKE --> F
GKE --> NP
T --> LOG
LOG --> BQ
BQ --> P
flowchart LR
TR[Trivy Operator]
LG[Workload logs]
LR[Log Router]
SK[Logging sink]
BQ[(Dataset: trivy_logs)]
PY[scripts/parse_trivy_bq.py]
CV[Table: clean_vulnerabilities]
TR --> LG --> LR --> SK --> BQ --> PY --> CV
Extended narrative (sink fields, compression, queries): docs/logging_pipeline.md and docs/network-and-data-flow.md.
| Problem | Raw scan telemetry in Cloud Logging / BigQuery is noisy and inconsistent — hard to trend CVEs, build executive summaries, or join with asset inventory. |
| What we built | A managed sink into trivy_logs plus scripts/parse_trivy_bq.py to read sink exports, normalize records, and populate a clean table for analytics (clean_vulnerabilities / pipeline in repo). |
| Outcome | Security-as-code evidence: repeatable ETL, simpler SQL for audits, and a pattern you can reuse for other log sources (Falco, custom scanners). |
From repo root, after installing gcloud, terraform, kubectl (see Prerequisites below):
git clone https://github.com/kiurakku/APT-SecureOps-Lab.git
cd APT-SecureOps-Lab/terraform && cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars (project_id, github_org, github_repo, state bucket), then:
terraform init -backend-config=backend.hcl && terraform applyFull kubectl, Helm, and GitHub secrets steps are in Quick Start below — the three commands above bootstrap infra; follow sections 3–4 there for cluster access and CI wiring.
| Path | Purpose |
|---|---|
terraform/ |
GCP infrastructure (GKE, IAM, WIF, BigQuery, logging sink) |
.github/workflows/ |
Vulnerable plan, hardened plan, controlled apply workflows |
k8s/ |
Helm values and Kubernetes manifests (Trivy, Falco, policies) |
cloudbuild/ |
Build/deploy/parser Cloud Build configs |
scripts/ |
Utility scripts (parser, sink inspection, policy apply, checks) |
exploits/ |
Controlled PoC scenarios for assignment-only lab use |
docs/ |
Runbooks, architecture notes, and implementation guidance |
- GCP project with billing enabled
gcloud,terraform >= 1.5,kubectl,helm- Python
3.11+ - GitHub repository with Actions enabled
Windows note (gcloud not found):
- install Google Cloud SDK
- ensure Cloud SDK
binis inPATH - reopen shell and verify with
gcloud --version
cd terraform
cp terraform.tfvars.example terraform.tfvarsSet values in terraform.tfvars:
project_idgithub_orggithub_repotf_state_bucket_name
PowerShell:
terraform init "-backend-config=backend.hcl"
terraform applyBash:
terraform init -backend-config=backend.hcl
terraform applyIf you cannot use remote state yet:
terraform init -backend=false
terraform applygcloud container clusters get-credentials lab-cluster --zone YOUR_ZONE --project YOUR_PROJECTUse Terraform outputs:
WIF_PROVIDER_LABWIF_PROVIDER_PRODCICD_LAB_SA_EMAILCICD_PLAN_SA_EMAILCICD_APPLY_SA_EMAILDEMO_IMPACT_BUCKET
Also set:
GCP_PROJECT_IDTF_STATE_BUCKET
Use pinned chart versions from file headers and deploy:
- Trivy Operator
- Falco
- network policies
Then enable compressed Trivy logs:
bash scripts/configure_trivy_log_compression.sh| Config | Outcome |
|---|---|
cloudbuild/cloudbuild.yaml |
Build/push lab-ci/ci-deploy image |
cloudbuild/deploy-gke-apps.yaml |
Deploy Trivy + Falco + NetworkPolicy |
cloudbuild/run-trivy-parser.yaml |
Parse sink rows into clean_vulnerabilities |
Terraform creates a managed Logging sink to trivy_logs.
Inspect sink tables:
python scripts/bq_sink_inspect.py --project YOUR_PROJECT --dataset trivy_logsParse sink data:
cd scripts
python parse_trivy_bq.py --project YOUR_PROJECT --dataset trivy_logs --from-sinkexploits/container_escape/: CVE-2022-0492 class mechanics (cgroup-dependent behavior)exploits/master_plane_crash/: API load stress via mass object creationexploits/github_action_steal/: WIF misuse simulation in CI context
All exploit paths are educational and must run only in isolated lab environments.
vulnerable-tf-plan.yml: PR-triggered broad lab WIF path ->cicd-lab-sahardened-tf-plan.yml: push-to-main strict WIF conditions ->cicd-plan-sahardened-tf-apply.yml: manual controlled write only ->demo-write-proof.txt
This split is intentional to demonstrate blast radius differences.
gcloudnot recognized (Windows): fix PATH and restart shellget-credentials404/403: verify exact--zone/--region, IAM permissions, active project- No sink evidence rows: wait for new scan job logs, inspect
stderr_*andstdout_* - No
clean_vulnerabilitiesrows: run parser and verify table/schema access - Falco shows only internal debug drops: trigger explicit test event (
/tmpwrite) and capture alert lines
Add these repository topics for discoverability:
devsecopsgkekubernetes-securityterraformworkload-identity-federationgithub-actionscloud-buildfalcotrivybigquerycloud-loggingthreat-detectionsecurity-labred-teamblue-team
Pull requests are welcome. Read CONTRIBUTING.md before you submit — especially the Disclaimer and rules for exploits/.
docs/README.md- documentation indexdocs/github_actions_runbook.md- end-to-end GitHub/GCP flowdocs/logging_pipeline.md- sink/parser data pathdocs/architecture_and_stack.md- architecture detaildocs/network-and-data-flow.md- network / logging / BigQuery flow (Mermaid)
