What it does. Patch management is the systematic process of identifying, testing, deploying, Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).
Install
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill implementing-patch-management-workflow, or copy the skill folder into ~/.claude/skills/implementing-patch-management-workflow/.
- Raw file:
curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/implementing-patch-management-workflow/SKILL.md
SKILL.md (verbatim)
name: implementing-patch-management-workflow
description: Patch management is the systematic process of identifying, testing, deploying,
and verifying software updates to remediate vulnerabilities across an organization's
IT infrastructure. An effective patc
domain: cybersecurity
subdomain: vulnerability-management
tags:
- vulnerability-management
- patch-management
- wsus
- sccm
- ansible
- risk
version: '1.0'
author: mahipal
license: Apache-2.0
nist_csf:
- ID.RA-01
- ID.RA-02
- ID.IM-02
- ID.RA-06
mitre_attack:
- T1190
- T1203
- T1068
Implementing Patch Management Workflow
Overview
Patch management is the systematic process of identifying, testing, deploying, and verifying software updates to remediate vulnerabilities across an organization's IT infrastructure. An effective patch management workflow reduces the attack surface while minimizing operational disruption through structured testing, approval gates, and phased rollouts.
When to Use
- When deploying or configuring implementing patch management workflow capabilities in your environment
- When establishing security controls aligned to compliance requirements
- When building or improving security architecture for this domain
- When conducting security assessments that require this implementation
Prerequisites
- Vulnerability scan results identifying missing patches
- Patch management tools (WSUS, SCCM/MECM, Ansible, Intune, Jamf)
- Test environment mirroring production
- Change management process (ITIL or equivalent)
- Asset inventory with OS and application versions
Core Concepts
Patch Lifecycle Phases
- Discovery: Identify available patches from vendors and vulnerability scans
- Assessment: Evaluate patch applicability and risk
- Prioritization: Rank patches by severity, exploitability, and asset criticality
- Testing: Validate patches in non-production environment
- Approval: Change advisory board (CAB) review and approval
- Deployment: Phased rollout to production systems
- Verification: Confirm successful installation and no regressions
- Reporting: Document compliance metrics and exceptions
Patch Categories
- Security Patches: Address CVEs and security vulnerabilities
- Critical Updates: Non-security bug fixes affecting stability
- Service Packs: Cumulative update collections
- Feature Updates: New functionality (Windows feature updates, etc.)
- Firmware Updates: BIOS/UEFI, NIC, storage controller firmware
- Third-Party Patches: Adobe, Java, Chrome, Firefox, etc.
Deployment Rings (Phased Rollout)
| Ring |
Environment |
% of Fleet |
Soak Time |
Purpose |
| Ring 0 |
Lab/Test |
N/A |
24-48 hrs |
Functional validation |
| Ring 1 |
IT Early Adopters |
5% |
48-72 hrs |
Real-world pilot |
| Ring 2 |
Business Pilot |
15% |
5-7 days |
Broader compatibility |
| Ring 3 |
General Deployment |
50% |
7-14 days |
Main rollout |
| Ring 4 |
Mission Critical |
30% |
After Ring 3 |
Final deployment |
Workflow
# WSUS (Windows Server Update Services)
# Configure WSUS server to sync with Microsoft Update
# Via PowerShell on WSUS server:
Install-WindowsFeature -Name UpdateServices -IncludeManagementTools
& "C:\Program Files\Update Services\Tools\WsusUtil.exe" postinstall CONTENT_DIR=D:\WSUS
# Configure GPO for WSUS clients
# Computer Configuration > Administrative Templates > Windows Components > Windows Update
# Specify intranet Microsoft update service location: http://wsus-server:8530
# Ansible: Configure patch repositories for Linux
# roles/patch-management/tasks/configure_repos.yml
---
- name: Configure RHEL patch repository
yum_repository:
name: rhel-patches
description: RHEL Security Patches
baseurl: https://satellite.corp.local/pulp/repos/patches
gpgcheck: yes
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
enabled: yes
- name: Configure Ubuntu patch sources
apt_repository:
repo: "deb https://apt-mirror.corp.local/ubuntu {{ ansible_distribution_release }}-security main"
state: present
when: ansible_os_family == "Debian"
Step 2: Automated Patch Assessment
# patch_assessment.py - Correlate vulnerability scans with available patches
import subprocess
import platform
import json
def get_windows_pending_patches():
"""Query Windows Update for pending patches via PowerShell."""
ps_cmd = """
$Session = New-Object -ComObject Microsoft.Update.Session
$Searcher = $Session.CreateUpdateSearcher()
$Results = $Searcher.Search("IsInstalled=0 AND Type='Software'")
$Results.Updates | ForEach-Object {
[PSCustomObject]@{
Title = $_.Title
KB = ($_.KBArticleIDs -join ',')
Severity = $_.MsrcSeverity
Size = [math]::Round($_.MaxDownloadSize / 1MB, 2)
Published = $_.LastDeploymentChangeTime.ToString('yyyy-MM-dd')
CVE = ($_.CveIDs -join ',')
}
} | ConvertTo-Json
"""
result = subprocess.run(
["powershell", "-Command", ps_cmd],
capture_output=True, text=True, timeout=120
)
return json.loads(result.stdout) if result.stdout.strip() else []
def get_linux_pending_patches():
"""Query package manager for available security updates."""
if platform.system() != "Linux":
return []
# Try apt (Debian/Ubuntu)
try:
result = subprocess.run(
["apt", "list", "--upgradable"],
capture_output=True, text=True, timeout=60
)
packages = []
for line in result.stdout.strip().split("\n")[1:]:
if line:
parts = line.split("/")
packages.append({
"package": parts[0],
"available_version": parts[1].split()[0] if len(parts) > 1 else "",
"source": "apt"
})
return packages
except FileNotFoundError:
pass
# Try yum/dnf (RHEL/CentOS)
try:
result = subprocess.run(
["dnf", "updateinfo", "list", "security", "--available"],
capture_output=True, text=True, timeout=60
)
packages = []
for line in result.stdout.strip().split("\n"):
parts = line.split()
if len(parts) >= 3:
packages.append({
"advisory": parts[0],
"severity": parts[1],
"package": parts[2],
"source": "dnf"
})
return packages
except FileNotFoundError:
return []
Step 3: Patch Testing Automation
# Ansible playbook: test_patches.yml
---
- name: Test Patches in Lab Environment
hosts: test_servers
become: yes
vars:
rollback_snapshot: "pre-patch-{{ ansible_date_time.date }}"
tasks:
- name: Create VM snapshot before patching
community.vmware.vmware_guest_snapshot:
hostname: "{{ vcenter_host }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
datacenter: "{{ datacenter }}"
name: "{{ inventory_hostname }}"
snapshot_name: "{{ rollback_snapshot }}"
state: present
delegate_to: localhost
- name: Apply security patches (RHEL/CentOS)
dnf:
name: "*"
state: latest
security: yes
update_cache: yes
when: ansible_os_family == "RedHat"
register: patch_result
- name: Apply security patches (Ubuntu/Debian)
apt:
upgrade: dist
update_cache: yes
only_upgrade: yes
when: ansible_os_family == "Debian"
register: patch_result
- name: Reboot if required
reboot:
reboot_timeout: 600
msg: "Rebooting for patch installation"
when: patch_result.changed
- name: Run post-patch validation
include_tasks: validate_services.yml
- name: Report patch results
debug:
msg: "Patching {{ 'succeeded' if patch_result.changed else 'no updates' }} on {{ inventory_hostname }}"
Step 4: Production Deployment
# deploy_patches.yml - Phased production rollout
---
- name: Ring 1 - IT Early Adopters
hosts: ring1_hosts
serial: "25%"
max_fail_percentage: 10
become: yes
tasks:
- import_tasks: apply_patches.yml
- import_tasks: validate_services.yml
- name: Wait for soak period
pause:
hours: 48
run_once: true
- name: Ring 2 - Business Pilot
hosts: ring2_hosts
serial: "20%"
max_fail_percentage: 5
become: yes
tasks:
- import_tasks: apply_patches.yml
- import_tasks: validate_services.yml
- name: Ring 3 - General Deployment
hosts: ring3_hosts
serial: "10%"
max_fail_percentage: 3
become: yes
tasks:
- import_tasks: apply_patches.yml
- import_tasks: validate_services.yml
Step 5: Verification and Reporting
Run a post-patch vulnerability scan to confirm patch installation:
# Trigger post-patch verification scan
curl -k -X POST "https://nessus:8834/scans/$VERIFY_SCAN_ID/launch" \
-H "X-Cookie: token=$TOKEN"
# Compare pre-patch and post-patch results
# Expecting reduction in vulnerabilities matching deployed patches
Patch Management SLAs
| Severity |
SLA (Internet-Facing) |
SLA (Internal) |
SLA (Air-Gapped) |
| Critical (CVSS 9+) |
48 hours |
7 days |
14 days |
| High (CVSS 7-8.9) |
7 days |
14 days |
30 days |
| Medium (CVSS 4-6.9) |
30 days |
30 days |
60 days |
| Low (CVSS 0.1-3.9) |
90 days |
90 days |
90 days |
Best Practices
- Maintain current asset inventory to ensure complete patch coverage
- Test all patches in a non-production environment before deployment
- Use phased rollouts with automatic rollback capabilities
- Coordinate patch windows with change management process
- Track patch compliance metrics and report to leadership
- Automate where possible to reduce manual effort and human error
- Maintain exception documentation for systems that cannot be patched
- Include third-party application patching (not just OS patches)
Common Pitfalls
- Patching only operating systems and ignoring third-party applications
- No rollback plan if patches cause service disruption
- Treating all patches with equal urgency (no risk-based prioritization)
- Manual patch processes that cannot scale
- No post-patch verification to confirm successful installation
- Ignoring firmware and BIOS updates
- prioritizing-vulnerabilities-with-cvss-scoring
- implementing-vulnerability-remediation-sla
- implementing-continuous-vulnerability-monitoring
Other files in this skill
assets/template.md (verbatim)
Patch Management Report Template
Patch Cycle Summary
| Field |
Value |
| Patch Cycle |
[Month Year] |
| Deployment Window |
[Start] to [End] |
| Patches Deployed |
[N] security, [N] critical, [N] feature |
Compliance Metrics
| Metric |
Value |
Target |
Status |
| Overall Compliance |
[%] |
95% |
[Met/Not Met] |
| Critical Patch Compliance |
[%] |
100% |
[Met/Not Met] |
| Mean Time to Patch (Critical) |
[N days] |
48 hours |
[Met/Not Met] |
| Mean Time to Patch (High) |
[N days] |
7 days |
[Met/Not Met] |
| Rollback Rate |
[%] |
<2% |
[Met/Not Met] |
Deployment Results by Ring
| Ring |
Hosts |
Success |
Failed |
Rollback |
Duration |
| Ring 0 (Lab) |
[N] |
[N] |
[N] |
[N] |
[Nh] |
| Ring 1 (Pilot) |
[N] |
[N] |
[N] |
[N] |
[Nh] |
| Ring 2 (General) |
[N] |
[N] |
[N] |
[N] |
[Nh] |
| Ring 3 (Critical) |
[N] |
[N] |
[N] |
[N] |
[Nh] |
Exceptions and Deferrals
| Host/Group |
Patch |
Reason |
Approved By |
Expiry |
| [host] |
[KB/CVE] |
[reason] |
[approver] |
[date] |
references/api-reference.md (verbatim)
API Reference: Patch Management Workflow Automation
Libraries Used
| Library |
Purpose |
requests |
HTTP client for Tenable.io, Qualys, and WSUS APIs |
json |
Parse scan and patch compliance data |
csv |
Export remediation plans to CSV |
subprocess |
Execute PowerShell WSUS commands |
os |
Read API credentials from environment |
Installation
pip install requests
Tenable.io API
Authentication
import requests
import os
TENABLE_URL = "https://cloud.tenable.com"
tenable_headers = {
"X-ApiKeys": f"accessKey={os.environ['TENABLE_ACCESS_KEY']};secretKey={os.environ['TENABLE_SECRET_KEY']}",
"Content-Type": "application/json",
}
Key Endpoints
| Method |
Endpoint |
Description |
| GET |
/scans |
List vulnerability scans |
| GET |
/scans/{id} |
Get scan results |
| POST |
/scans |
Create a new scan |
| POST |
/scans/{id}/launch |
Launch a scan |
| GET |
/workbenches/vulnerabilities |
List vulnerabilities |
| GET |
/workbenches/assets |
List assets |
Get Scan Results with Missing Patches
def get_tenable_missing_patches(scan_id):
resp = requests.get(
f"{TENABLE_URL}/scans/{scan_id}",
headers=tenable_headers,
timeout=60,
)
resp.raise_for_status()
vulns = resp.json().get("vulnerabilities", [])
patches_needed = [
v for v in vulns
if v.get("plugin_family") == "Windows : Microsoft Bulletins"
or "patch" in v.get("plugin_name", "").lower()
]
return sorted(patches_needed, key=lambda v: v.get("severity", 0), reverse=True)
Qualys API
Authentication
QUALYS_URL = os.environ.get("QUALYS_URL", "https://qualysapi.qualys.com")
qualys_auth = (os.environ["QUALYS_USER"], os.environ["QUALYS_PASS"])
qualys_headers = {"X-Requested-With": "Python"}
Key Endpoints
| Method |
Endpoint |
Description |
| GET |
/api/2.0/fo/scan/ |
List scans |
| POST |
/api/2.0/fo/scan/ |
Launch a scan |
| GET |
/api/2.0/fo/asset/host/ |
List host assets |
| POST |
/api/2.0/fo/knowledge_base/vuln/ |
Query vulnerability KB |
| GET |
/api/2.0/fo/report/ |
List reports |
Get Missing Patches by Host
def get_qualys_patches(scan_ref):
resp = requests.get(
f"{QUALYS_URL}/api/2.0/fo/scan/",
params={"action": "fetch", "scan_ref": scan_ref, "output_format": "json"},
auth=qualys_auth,
headers=qualys_headers,
timeout=120,
)
resp.raise_for_status()
return resp.json()
WSUS (Windows Server Update Services) via PowerShell
Check Patch Compliance
def check_wsus_compliance(server=None):
cmd = ["powershell", "-Command"]
ps_script = """
Get-WsusUpdate -Approval Approved -Status FailedOrNeeded |
Select-Object Title, Classification, KnowledgebaseArticles, ArrivalDate |
ConvertTo-Json
"""
if server:
ps_script = f"Invoke-Command -ComputerName {server} -ScriptBlock {{{ps_script}}}"
cmd.append(ps_script)
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
return json.loads(result.stdout) if result.stdout else []
List Installed Updates
def list_installed_patches():
cmd = [
"powershell", "-Command",
"Get-HotFix | Select-Object HotFixID, Description, InstalledOn | ConvertTo-Json"
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=60)
return json.loads(result.stdout) if result.stdout else []
Patch Prioritization
def prioritize_patches(vulnerabilities, kev_cves=None):
"""Prioritize patches using CVSS + KEV + age."""
kev_set = set(kev_cves or [])
for vuln in vulnerabilities:
score = vuln.get("cvss_score", 0)
if vuln.get("cve") in kev_set:
score += 3 # KEV bonus
if vuln.get("exploit_available"):
score += 2
vuln["priority_score"] = min(score, 10)
return sorted(vulnerabilities, key=lambda v: v["priority_score"], reverse=True)
{
"scan_date": "2025-01-15T10:30:00Z",
"total_hosts": 250,
"patches_required": 145,
"critical_patches": 12,
"kev_matches": 5,
"compliance_rate": 78.5,
"remediation_plan": [
{
"kb": "KB5034441",
"title": "Windows Security Update",
"severity": "critical",
"affected_hosts": 45,
"cve": "CVE-2024-21345",
"kev_listed": true
}
]
}
references/standards.md (verbatim)
Standards and References - Patch Management Workflow
Industry Standards
- NIST SP 800-40 Rev 4: Guide to Enterprise Patch Management Planning
- NIST SP 800-53 SI-2: Flaw Remediation control
- CIS Controls v8 Control 7.3: Perform automated patch management
- PCI DSS v4.0 Req 6.3: Identify and address security vulnerabilities
- ISO 27001:2022 A.8.8: Management of technical vulnerabilities
| Tool |
Platform |
Type |
License |
| WSUS |
Windows |
Microsoft native |
Free with Windows Server |
| SCCM/MECM |
Windows/Linux |
Enterprise endpoint management |
Microsoft licensing |
| Ansible |
Linux/Windows |
Agentless automation |
Open source / Red Hat |
| Intune |
Windows/macOS/iOS/Android |
Cloud MDM/MAM |
Microsoft 365 |
| Jamf Pro |
macOS/iOS |
Apple device management |
Commercial |
| Ivanti Patch |
Multi-platform |
Enterprise patching |
Commercial |
| ManageEngine |
Multi-platform |
IT management suite |
Commercial |
Vendor Patch Schedules
references/workflows.md (verbatim)
Workflows - Patch Management
Workflow 1: End-to-End Patch Lifecycle
┌────────────┐ ┌──────────┐ ┌──────────────┐ ┌──────────┐
│ Discover │──>│ Assess │──>│ Prioritize │──>│ Test │
│ (Vendor │ │ (CVE │ │ (CVSS+EPSS │ │ (Lab │
│ Feeds) │ │ Match) │ │ Scoring) │ │ Ring 0) │
└────────────┘ └──────────┘ └──────────────┘ └──────────┘
│
┌───────────────────────────────────────────────────┘
v
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Approve │──>│ Deploy │──>│ Verify │──>│ Report │
│ (CAB / │ │ (Phased │ │ (Re-scan │ │ (Metrics │
│ Change) │ │ Rings) │ │ Confirm)│ │ + KPIs) │
└──────────┘ └──────────┘ └──────────┘ └──────────┘
Workflow 2: Emergency Patch Process
For critical zero-day or actively exploited vulnerabilities:
- Alert (T+0h): Vendor advisory or threat intel notification
- Triage (T+1h): Assess applicability and impact
- Fast-track Test (T+4h): Rapid testing on critical systems
- Emergency CAB (T+6h): Expedited approval
- Deploy (T+8h): Direct to production (skip pilot rings)
- Verify (T+12h): Post-patch scan verification
- Post-mortem (T+48h): Review process effectiveness
Workflow 3: Rollback Procedure
Patch Deployment Fails
│
├──> Application Not Starting
│ └──> Restore from snapshot/backup
│
├──> Performance Degradation
│ └──> Uninstall patch (wusa /uninstall /kb:NNNNN)
│
├──> Blue Screen / Kernel Panic
│ └──> Boot to safe mode, remove update
│
└──> Network Connectivity Lost
└──> Console access, rollback patch
Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.