Strengthening the food environment
Strengthening the production environment
1) Purpose and frame
Hardening is a systematic set of practices that reduces the likelihood of incidents and the damage caused by them. Focus: API perimeter, customer/payment data, CI/CD, container platform, accesses, change control, observability and compliance.
Key principles:- Security by Design & Default: minimum required privileges, secure defaults.
- Zero Trust: Trust neither network nor identities without verification.
- Defense-in-Depth: multi-level protection (network → service → application → data).
- Immutability of artifacts: "build once, run many."
- E2E traces and auditability: who, when, what changed - and why.
2) Threat model and critical assets
Assets: accounts and payment tokens, PII/passport data, RNG/game balances, encryption keys, integration secrets, deploy pipelines, container images.
Vectors: dependency vulnerabilities, token leaks, cloud misconfiguration/K8s, SSRF/RCE in API, supply chain (CI/CD/repository compromise), insider access, DDoS/bot traffic.
Scenarios: withdrawal of funds by an unauthorized entity, substitution of coefficients/balances, base drain, pipeline capture, manual edits in the product.
3) Network architecture and isolation
Segmentation: separate VPC/VNet for prod/stage/dev. Inside prod - subnets for edge (LB/WAF), API, database, analytics, admin services.
Policy "explicitly allowed": deny-all between subnets, open only the necessary ports/directions.
mTLS between services, certificate rotation is automated.
yaml apiVersion: networking. k8s. io/v1 kind: NetworkPolicy metadata:
name: default-deny namespace: prod spec:
podSelector: {}
policyTypes: ["Ingress","Egress"]
apiVersion: networking. k8s. io/v1 kind: NetworkPolicy metadata:
name: allow-api-to-db namespace: prod spec:
podSelector:
matchLabels: {app: db}
ingress:
- from:
- podSelector: {matchLabels: {app: api}}
ports: [{protocol: TCP, port: 5432}]
4) Identities and Access (PAM/JIT)
SSO + MFA for all human accesses.
RBAC&ABAC - Roles at cloud, cluster, namespace, and application level.
PAM: jump/bastion, JIT access (limited time), session recording.
Break-glass: sealed accounts with a hardware key, log issuance.
Regular scans of "who has access to what," review once every 30 days.
5) Secrets and keys
Vault/KMS/Secrets Manager, exclude secrets from Git.
KMS/HSM for master keys; KEK/DEK, automatic rotation.
TTL policies: short-lived tokens (OIDC/JWT), temporary accounts for CI.
Encryption: at rest (AES-256/GCM), in flight (TLS 1. 2 +/mTLS), PII/card data columns - with a separate key.
6) Supply chain и CI/CD hardening
Isolation of runners for prod (self-hosted in a private network).
Signature of artifacts (Sigstore/cosign), verification of signature on depla.
SBOM (CycloneDX/SPDX), SCA/VA on each commit and before release.
"no tag latest" policies, only immutable tags.
4-eye principle: mandatory code review and change approval.
Infrastructure as Code: Terraform/Helm с policy-as-code (OPA/Conftest).
rego package iac. guardrails
deny[msg] {
input. resource. type == "storage_bucket"
input. resource. acl == "public-read"
msg:= sprintf("Public bucket forbidden: %s", [input. resource. name])
}
7) Containers and Kubernetes
Minimum image base (distroless), rootless, read-only FS, drop CAPs.
Admission control: deny privileged, hostPath, hostNetwork.
Pod Security Standards: baseline/restricted для prod ns.
ImagePolicyWebhook - skipping only signed images.
Runtime policies (Falco/eBPF): alerts to abnormal syscalls.
Quota/LimitRange: protecting nodes from "noisy neighbors."
8) API perimeter: WAF, Rate Limits, Bot/DDoS
Gateway API: authentication (OAuth2/JWT/HMAC), normalization, mTLS, schema validation.
WAF: basic rules + caste for business metrics.
Rate limits: global/by IP/by client key; "tokens" and burst.
nginx limit_req_zone $binary_remote_addr zone=api:20m rate=10r/s;
server {
location /api/ {
limit_req zone=api burst=30 nodelay;
proxy_pass http://api_backend;
}
}
Bot management: behavioral signals, device fingerprint, challenge.
DDoS: CDN/edge scrubbing, autoscaling, "dark-launch" for hot features.
9) Configuration policies and secure defaults
Feature flags/kill-switches to quickly disable risky features.
Config-as-Code with circuit validation, canary/blue-green for configs.
Time-to-Revoke as KPI when revoking configs/keys.
10) Data and privacy
Classification: PII/finance/operating logs/telemetry.
Minimization: store only what you need, anonymization/pseudonymization.
Backups: separate account/project, encryption, regular DR rehearsals.
Withdrawal rules: same-method, velocity-limits, risk-scoring, 4-eyes.
Legal Hold/retention: storage schedules, managed disposal.
11) Observability, alerts and response
Triad: logs (not containing secrets), metrics (SLO/SLA), trails (W3C).
Security signals: success/failure of inputs, escalation of privileges, changes in secrets, traffic deviations.
SIEM + SOAR: correlation and semi-automatic playbooks.
Incident playbooks: DDoS, leak of secrets, compromise of runner, rollback of release, "freezing" of payments.
MTTD/MTTR as primary metrics of responsiveness.
12) Change and Release Management
Change Advisory Board (lightweight) for high-risk changes.
Pre-prod gates: tests, security, perf, database migrations.
Canary/Blue-Green/Shadow depley, automatic rollback by SLO.
Prohibit direct edits in the prod: changes only through the pipeline.
13) Vulnerabilities and patches
Patch policy: critical - ASAP; high - for N days.
Rescan after the fix; CVE-exposure weighting.
Chaos-security: periodic table-top exercises and red command attacks in the highlighted windows.
14) Compliance and audit
Control frameworks: PCI DSS (payments), SOC 2, ISO 27001.
Artifacts: control matrix, change logs, scan reports, DR test results, access-review.
Continuous availability: "evidence as code" - artifacts are collected automatically from pipelines and systems.
15) Economics and reliability
Guardrails by cost: quotas, budgets, alerts, automatic shutdown of unused resources.
Capacity: SLO-oriented planning, load tests, "days of chaos."
Recovery priorities: RTO/RPO by service, dependency map.
16) Anti-patterns
Secrets of v.env in Git, common "admin" for everyone, "direct SSH in prod," manual fixes in containers, "latest" tags, one common cluster for everything, public buckets, CI-runner with outbound Internet in prod-network, logs with PII, no kill-switch for "hot" features.
17) Fast start checklist (90 days)
0-30 days
Enable MFA/SSO, access review; deny-all network policies; Secrets Manager/KMS; forbidden privileged in K8s; Enable WAF/Rate-limit basic entry/escalation alerts.
31-60 days
Image signature + ImagePolicy; SBOM + SCA в CI; canary/rollback; SIEM correlations; IR playbooks; JIT/PAM; backup with DR test.
61-90 days
OPA-guardrails for IaC; eBPF/Falco; bot management; periodic access-review; chaos-security exercise; audit of configs and cost-guardrails.
18) Maturity metrics
Accesses:% of accounts with MFA, average age of tokens, recall time.
Pipeline:% signed/SBOM images, SAST/DAST coverage.
Platform: share of pods with read-only FS, PSS-restricted, NetworkPolicy coverage.
Perimeter:% API with rate-limit/WAF rules, average response to DDoS.
IR: MTTD/MTTR, table-top frequency, percentage of successful DR rehearsals.
Compliance: proportion of controls with automatic evidence.
19) Appendix: Policy Templates
AWS SCP (Public Bucket Ban)
json
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "DenyPublicS3",
"Effect": "Deny",
"Action": ["s3:PutBucketAcl","s3:PutBucketPolicy"],
"Resource": "",
"Condition": {"StringEquals": {"s3:x-amz-acl": "public-read"}}
}]
}
Kubernetes PodSecurity (namespace-label)
yaml apiVersion: v1 kind: Namespace metadata:
name: prod labels:
pod-security. kubernetes. io/enforce: restricted pod-security. kubernetes. io/audit: restricted
OPA for containers (forbidden privileged)
rego package k8s. admission deny[msg] {
input. request. object. spec. containers[_].securityContext. privileged == true msg:= "Privileged containers are not allowed in prod"
}
20) Conclusion
Strengthening the food environment is an ongoing process. Prioritize risk mitigation measures: access and secrets, network isolation, artifact signing and pipeline control, API perimeter protection, observability and change discipline. Build up the rest iteratively, capturing maturity metrics and control economics.