Request icon
Script icon
Process icon
Write icon
If icon
SlackIncomingWebhook icon
Pause icon
Log icon
Commands icon
Set icon
Schedule icon

Copacetic Container Vulnerability Hotpatch Engine

Automated Kestra workflow auditing container CVEs and executing CNCF Copacetic in-place hotpatching with human approval and verification.

Categories
CloudInfrastructure

How it works

  1. A schedule trigger initiates the container image vulnerability audit every 6 hours.
  2. A native HTTP request task pulls real-time vulnerability metrics from the scanner endpoint.
  3. A Python script evaluates critical and high CVE counts against defined enterprise thresholds with strict loud failure on invalid data.
  4. Kestra internal storage captures the structured audit manifest as a persistent JSON artifact.
  5. When security thresholds are breached, a Slack alert notifies SecOps and execution pauses for human-in-the-loop signoff.
  6. Upon approval, the workflow invokes the CNCF Copacetic CLI to execute real in-place package patching without rebuilding images.
  7. A post-patch verification task audits the remediated container artifact and confirms elimination of target vulnerabilities.
  8. The verified compliance receipt is recorded in the Kestra KV store and announced to SecOps via Slack.

Architecture diagram

graph TD
    Trigger[Schedule Trigger: 6h] --> FetchReport[HTTP Request: Query Scanner Metrics]
    FetchReport --> AnalyzePlan[Python Script: Parse CVEs & Build Plan]
    AnalyzePlan --> WriteManifest[Storage Write: Save Patch Manifest]
    WriteManifest --> CheckThreshold{Remediation Required?}
    CheckThreshold -- Yes --> SlackReq[Slack: Request Signoff]
    SlackReq --> AwaitApproval[Pause Task: Await SecOps Signoff]
    AwaitApproval --> CheckApproved{Approved?}
    CheckApproved -- Yes --> RunCopa[Shell: Run copa patch CLI]
    RunCopa --> VerifyPost[Python Script: Verify Patched Image]
    VerifyPost --> StoreKV[KV Set: Record Audit Receipt]
    StoreKV --> SlackSuccess[Slack: Announce Verified Patch]
    CheckApproved -- No --> LogDeclined[Log: Remediation Declined]
    CheckThreshold -- No --> NominalLog[Log: Posture Compliant]
    SlackSuccess --> FinalLog[Log: Workflow Concluded]
    LogDeclined --> FinalLog
    NominalLog --> FinalLog

What you get

  • Elimination of multi-hour container rebuild pipelines by enabling direct in-place OS package patching with Copacetic.
  • Human-in-the-loop operational safety preventing unauthorized container alterations via Kestra Pause tasks.
  • Concrete CLI execution applying real upstream security updates to container layers.
  • Post-remediation verification confirming that target vulnerabilities were eradicated.
  • Persistent KV store tracking of verified compliance receipts with approver change records.

Who it's for

  • DevSecOps Engineers accelerating container vulnerability remediation cycles.
  • Security Operations (SecOps) teams enforcing zero-critical CVE compliance across container registries.
  • Platform Engineers seeking to eliminate unnecessary container layer rebuild churn.
  • Site Reliability Engineers ensuring production containers maintain patched security baselines.

Why orchestrate this with Kestra

  • Human-in-the-Loop Governance: Halts destructive changes until authorized engineers provide explicit approval with ticket tracking.
  • Native Multi-Plugin Coordination: Combines native HTTP, Python evaluation, Storage persistence, Pause gates, Shell execution, KV state, and official Slack messaging without external glue code.
  • Automated Security Surveillance: Evaluates container CVE metrics continuously on a schedule.
  • Centralized Secrets Governance: Protects sensitive Slack webhooks using encrypted namespace secrets.
  • Declarative YAML Workflows: Manages vulnerability remediation workflows as versioned code in Git repositories.

Use cases

  • Emergency Zero-Day Hotpatching: Fast-tracks urgent Linux package security updates directly into image layers using Copacetic.
  • Production CVE SLA Enforcement: Detects when published container images violate security baselines.
  • Controlled Remediation Gates: Requires formal SecOps change approval before modifying container images.

Inputs

Name Type Default Description
target_image STRING docker.io/library/alpine:3.18.0 Container image repository evaluated for hotpatching.
scanner_api_url STRING http://trivy-scanner.security.svc.cluster.local:8080/v1/metrics Internal HTTP endpoint exposing vulnerability scanner metrics.
max_critical_cves INT 0 Maximum allowable critical severity vulnerabilities.
max_high_cves INT 3 Maximum allowable high severity vulnerabilities.
patched_image_tag_suffix STRING -copa-patched Tag suffix appended to the target image repository.

Expected outputs

  • {{ outputs.analyze_cve_remediation_plan.vars.status }}: Overall security compliance status.
  • {{ outputs.analyze_cve_remediation_plan.vars.critical_cves }}: Total number of critical CVEs detected.
  • {{ outputs.analyze_cve_remediation_plan.vars.high_cves }}: Total number of high severity CVEs detected.
  • {{ outputs.persist_patch_manifest.uri }}: Kestra internal storage URI for the audit manifest.
  • {{ outputs.post_patch_verification.vars.patched_image }}: Verified patched container image tag.
  • {{ outputs.post_patch_verification.vars.verification_status }}: Final post-patch verification verdict.

Prerequisites

  • Container vulnerability scanner (such as Trivy or Grype) exposing metrics on port 8080.
  • Copacetic CLI (copa) installed on the build runner or container registry agent.
  • Network connectivity from the Kestra worker to the vulnerability scanner endpoint.
  • Slack incoming webhook URL configured in Kestra secrets under SLACK_WEBHOOK_URL.

Secrets

  • SLACK_WEBHOOK_URL: Secure webhook URL for routing security alerts to SecOps channels.

Quick start

  1. Confirm that your container scanner is actively indexing registry images.
  2. Add the SLACK_WEBHOOK_URL secret within your Kestra namespace settings.
  3. Specify your target container image repository in target_image.
  4. Trigger a manual execution via the Kestra UI to validate CVE evaluation and review the approval gate.
  5. Enable the periodic_vulnerability_audit schedule trigger to establish automated surveillance.

Common pitfalls and troubleshooting

  • Approval Gate Timeout: The approval step times out after 4 hours; ensure on-call SecOps engineers are alerted via Slack.
  • Distro Compatibility: Copacetic supports Debian, Ubuntu, Alpine, and Red Hat/CentOS package managers; confirm base image compatibility.
  • Registry Push Permissions: When executing copa patch, verify that credentials permit pushing the resulting tagged image.
  • Firewall Egress: Ensure build runners have outbound network access to official Linux package mirrors during patching.

How to extend

  • Canary Promotion: Automatically deploy the patched container into a staging cluster for automated regression testing.
  • Jira Ticket Creation: Automatically file a tracking issue with CVE identifiers for compliance auditing.
  • Multi-Arch Support: Expand the hotpatch command to generate multi-architecture container manifests.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.