Kuboid
Open Luck·Kuboid.in
Security BSides2025
Open in YouTube ↗

Compliance Without the Chaos: Building It Right Into Your DevOps Pipeline

Security BSides San Francisco191 views33:1210 months ago

This talk demonstrates how to integrate automated compliance checks directly into a DevOps pipeline to reduce the manual burden of GRC audits. It focuses on leveraging Kubernetes admission controllers and Open Policy Agent (OPA) to enforce security policies and generate audit logs automatically. The speaker highlights the importance of mapping technical controls to compliance requirements to streamline the audit process. The presentation provides a practical framework for using existing DevOps tooling to achieve continuous compliance.

Automating Compliance: How to Turn Kubernetes Admission Controllers into Security Guardrails

TLDR: Compliance audits are often a manual, soul-crushing exercise that distracts from actual security work. By shifting compliance into the CI/CD pipeline using Open Policy Agent (OPA) and Kubernetes admission controllers, you can enforce security guardrails automatically. This approach turns abstract GRC requirements into machine-readable code, ensuring that only compliant infrastructure reaches production.

Security teams often treat compliance as a post-hoc activity, a box-ticking exercise that happens once every six months. For a pentester or a researcher, this is a massive blind spot. While the compliance team is busy reviewing spreadsheets, the engineering team is pushing code that might violate the very policies they claim to follow. The gap between "what is documented" and "what is actually running in the cluster" is where the most interesting vulnerabilities live.

The Problem with Manual GRC

Most organizations rely on periodic audits to verify their security posture. They pull logs, take screenshots, and hope the auditor doesn't look too closely at the production environment. This is not just inefficient; it is fundamentally broken. If your security controls are not enforced at the point of deployment, they are merely suggestions.

When you are performing a red team engagement or a penetration test, you aren't looking for compliance documentation. You are looking for misconfigurations. You are looking for pods running as root, containers pulling images from untrusted registries, or services that lack proper network policies. These are the OWASP A05:2021 - Security Misconfiguration issues that lead to full cluster compromise.

Shifting Compliance Left

The goal is to move compliance from a manual audit to an automated gate. By integrating OPA Gatekeeper into your Kubernetes cluster, you can intercept every request to the API server. If a developer tries to deploy a container that violates a policy, the admission controller rejects the request before it ever hits the etcd database.

Consider the common requirement of only using authorized container images. Instead of relying on a developer to remember the internal registry URL, you write a policy that enforces it. When a kubectl apply or a helm install command is executed, the admission controller checks the image source against your whitelist.

package kubernetes.admission

deny[msg] {
  input.request.kind.kind == "Pod"
  image := input.request.object.spec.containers[_].image
  not startswith(image, "myregistry.com/")
  msg := sprintf("Container %v is pulled from an unapproved registry", [image])
}

This is not just a defensive measure. For a researcher, this is a signal. If you are testing an environment and you find that your attempts to deploy a malicious sidecar are being rejected with a specific error message, you have just mapped out the organization's security policy.

Bridging the Gap Between DevOps and Compliance

The real power of this approach lies in the audit trail. Every time a policy is enforced, the admission controller generates a decision log. This log is the "evidence" that compliance teams spend weeks gathering manually. By centralizing these logs in a data lake or a SIEM, you can query the state of your infrastructure in real-time.

You don't need to ask the DevOps team for a list of all running pods and their configurations. You can query your compliance data store to see exactly how many pods were blocked, why they were blocked, and who tried to deploy them. This is the difference between a static, outdated audit and a continuous, real-time security posture.

Real-World Applicability for Pentesters

When you are on an engagement, look for the presence of admission controllers. If you can identify the policies in place, you can tailor your payloads to avoid triggering them. Conversely, if you find a way to bypass these controllers—perhaps through a misconfigured MutatingAdmissionWebhook—you have found a path to persistence that most defenders won't see in their standard logs.

The impact of these controls is significant. They prevent the "low-hanging fruit" of misconfigurations that often serve as the initial access vector for attackers. If you are a bug bounty hunter, look for environments that use these tools but fail to secure the webhook configurations themselves. A misconfigured webhook can often be manipulated to allow unauthorized actions, effectively turning the security tool into a weapon for the attacker.

Building Your Own Audit Engine

If you are working with a blue team, encourage them to stop treating compliance as a separate entity. The tools they need are already in the hands of the DevOps team. Spinnaker and Jenkins are not just for deployment; they are the perfect places to inject compliance checks.

Start by identifying the top three risks in your environment. Is it public S3 buckets? Is it containers running as root? Is it lack of resource limits? Write a single policy for each, deploy it as an admission controller, and watch the logs. You will quickly find that the "chaos" of compliance disappears when it becomes a natural part of the development lifecycle.

Security is not about the absence of risk; it is about the presence of visibility and control. By automating your compliance, you aren't just making the auditors happy. You are building a system that is inherently more difficult to compromise, and that is the only kind of security that matters.

Premium Security Audit

We break your app before they do.

Professional penetration testing and vulnerability assessments by the Kuboid Secure Layer team. Securing your infrastructure at every layer.

Get in Touch
Official Security Partner
kuboid.in