# How virtual patching works

Canonical: https://remediationvsmitigation.com/guides/how-virtual-patching-works/

A virtual patch is a rule in a WAF, IPS or web server module that blocks matching traffic to a known flaw without changing the vulnerable code. OWASP's method has six phases and starts rules in log-only mode. This page carries one rule through them for CVE-2026-40217, KEV due 2 Dec 2026.

## What counts as a virtual patch

OWASP defines it as "A security policy enforcement layer that detects and blocks matching exploitation attempts against a known vulnerability without changing the vulnerable code." It adds that a virtual patch "does not remove the underlying vulnerability" and reduces exposure only for traffic the layer inspects. OWASP names three places for the layer: an intermediary device such as a WAF or IPS appliance, a web server plugin such as ModSecurity, or an application layer filter ([OWASP Virtual Patching Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Virtual_Patching_Cheat_Sheet.html)).

## The six phases, with owner and record

Phases and aims from the OWASP Virtual Patching Cheat Sheet, read 19 Nov 2026. The owner and failure columns are this site's summary of where the work lands.

| Phase | Who usually does it | What is done | Record left | Where it usually fails |
|---|---|---|---|---|
| 1. Preparation | Security operations with the change board | Vendor alert subscriptions, a pre-authorized expedited rollout, the tool installed before it is needed, audit logging configured | Standing change authorization; logging standard | Approval sought during the incident, so the rule waits days |
| 2. Identification | Vulnerability management | Flaw found by assessment or code review (proactive), or by vendor notice, public disclosure or an incident (reactive) | Ticket with source and date | Notice arrives with the application team, not the WAF team |
| 3. Analysis | Application owner and WAF engineer | Confirm the CVE or internal ID, affected versions and the exact route or parameter; decide whether a rule can express it (OWASP: ideally suited to injection-type flaws) | Affected-asset list; rule design note | Flaw is in logic or authorization, which a pattern cannot see |
| 4. Rule creation | WAF engineer | Write the rule. OWASP's two aims: no false positives, no false negatives. Prefer an allow-list on the route to a copy of one sample request | Rule text and rule ID in the ticket | Rule written for one exploit sample, which OWASP says has low long-term value |
| 5. Implementation and testing | WAF engineer, then the assessor or a second engineer | Deploy in log-only mode first, review hits, switch to blocking, request a retest; if the retest finds evasions, return to analysis | Test log; retest result; date blocking began | Tested with one request, not alternate encodings or a direct path that skips the WAF |
| 6. Recovery and follow-up | Application owner | Record the change, review periodically, remove the rule after the code fix, run reports on when the rule fired | Removal date and reason; hit report | No removal date, so the rule outlives its reason |

## Worked example: LiteLLM CVE-2026-40217

The flaw and the vendor workaround are real; the team, host names and test results are invented for illustration. The BerriAI advisory GHSA-wxxx-gvqv-xp7p, published 7 May 2026, says the POST /guardrails/test_custom_code endpoint runs user-supplied code in a sandbox that can be escaped, that reaching the endpoint "requires a proxy-admin credential in default configurations", and that the fix is to upgrade to 1.83.11 or later. Its workaround reads: "If upgrading is not immediately possible, block POST /guardrails/test_custom_code at your reverse proxy or API gateway." CISA added the CVE to the KEV catalog on 18 Nov 2026 with a due date of 2 Dec 2026 (14 days).

A rule for that route carries no payload, so it is a route block and not an exploit-specific pattern. Step one, log only. It matches the path after URL decoding and normalization, so encoded and dotted variants of the path are seen, and it logs without blocking:

# Rule 9100001, CVE-2026-40217 LiteLLM, stage 1: log only
SecRule REQUEST_FILENAME "@rx ^/guardrails/test_custom_code/*$" \
  "id:9100001,phase:1,t:none,t:urlDecodeUni,t:normalizePath,t:lowercase,pass,log,auditlog,msg:'VP CVE-2026-40217 LiteLLM test_custom_code, log only'"

# Stage 2, enforcement: same rule with the action changed
#   ...,deny,status:403,log,auditlog,msg:'VP CVE-2026-40217 LiteLLM test_custom_code, blocked'

Advisory and KEV dates read 19 Nov 2026; every other row is a worked plan, not an observed result.

| Date | Step | Record |
|---|---|---|
| 19 Nov 2026 | Stage 1 deployed on the reverse proxy in front of the LiteLLM proxy | Change ticket with rule ID 9100001; removal review set for 8 Dec 2026 |
| 19 to 23 Nov 2026 | Hits reviewed daily. Expected: none, since the route needs a proxy-admin credential. Any hit is matched to a named admin session | Hit report attached to the ticket |
| 24 Nov 2026 | Stage 2 enabled. Retest by a second engineer: the path with a trailing slash, with percent-encoded characters and with doubled slashes returns 403; a request straight to the service port from the internal network is not blocked | Retest result. The direct-port result is the rule's gap, so the service port is closed to all but the proxy |
| 1 Dec 2026 | Upgrade to 1.83.11 completed, one day before the KEV due date | Version before and after in the ticket |
| 8 Dec 2026 | Rule removed after a week of no hits on the upgraded service | Removal date and reason closed in the ticket |

The rule matches all methods, not only POST. That is wider than the vendor text and costs nothing unless admins use the route; if they do, restrict the route by source network instead. The vendor's advisory is a workaround for the period before the upgrade, which is why the plan ends in the fix and a removal date.

## What the log should hold

OWASP asks for the rule ID, timestamp, affected endpoint, enforcement outcome and a correlation identifier. It warns against capturing query strings, headers, cookies and bodies indiscriminately because "WAF alerts can expose passwords and payment data"; sensitive fields should be excluded or redacted. The test record doubles as the evidence for the [WAF rule entry in the register](https://remediationvsmitigation.com/compensating-controls/waf-rule/), and the same checks apply to an [IPS signature](https://remediationvsmitigation.com/compensating-controls/ips-signature/).

## Where a rule is silently off

- Cloudflare's documentation says "Some rules in the Cloudflare Managed Ruleset are disabled by default" ([vendor documentation](https://developers.cloudflare.com/waf/managed-rules/reference/cloudflare-managed-ruleset/), vendor claim). Check that the rule for your flaw is on.
- Check Point's IPS page describes an optional detect-only mode that "sets all protections to only detect" ([vendor page](https://www.checkpoint.com/quantum/intrusion-prevention-system-ips/), vendor claim). A detect-only sensor logs and does not block.
- ModSecurity's engine setting has a DetectionOnly value, which the v3 reference manual describes as passive: "the intent is to be totally passive and not take any disruptive actions". A deny action in a rule then does nothing ([reference manual](https://github.com/owasp-modsecurity/ModSecurity/wiki/Reference-Manual-(v3.x))).

OWASP: "A passing test for one payload does not establish complete protection." Test alternate encodings and every other path that reaches the same component.

## Keeping it tied to a fix

OWASP's author notes that many teams leave virtual patches in place after the code fix because the logging is better than the application's own. That is a choice to record, not a default. A virtual patch with no removal date is the pattern the [maximum durations page](https://remediationvsmitigation.com/risk-acceptance-form/maximum-durations/) warns about. For checking that a rule stays in force see [verifying a mitigation](https://remediationvsmitigation.com/guides/verifying-a-mitigation-works/).

## Sources

- OWASP Virtual Patching Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Virtual_Patching_Cheat_Sheet.html (read 19 Nov 2026)
- BerriAI LiteLLM advisory GHSA-wxxx-gvqv-xp7p, published 7 May 2026: https://github.com/BerriAI/litellm/security/advisories/GHSA-wxxx-gvqv-xp7p (read 19 Nov 2026)
- CISA KEV JSON feed, catalogVersion 2026.11.18, entry CVE-2026-40217: https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json (read 19 Nov 2026)
- ModSecurity v3 Reference Manual, transformations and SecRuleEngine: https://github.com/owasp-modsecurity/ModSecurity/wiki/Reference-Manual-(v3.x) (read 19 Nov 2026)
- Cloudflare, Managed Ruleset reference (vendor): https://developers.cloudflare.com/waf/managed-rules/reference/cloudflare-managed-ruleset/ (read 19 Nov 2026)
- Check Point, IPS page (vendor): https://www.checkpoint.com/quantum/intrusion-prevention-system-ips/ (read 19 Nov 2026)

Last reviewed 19 Nov 2026

## Related

- [When Virtual Patching Is Enough, and When It Is Not](https://remediationvsmitigation.com/guides/virtual-patching-and-when-it-is-enough/index.md)
- [WAF Rule as a Virtual Patch: Atlassian Case and Limits](https://remediationvsmitigation.com/compensating-controls/waf-rule/index.md)
- [IPS Signature as a Mitigation: When It Counts](https://remediationvsmitigation.com/compensating-controls/ips-signature/index.md)
- [Maximum Duration of a Risk Acceptance: 9 Sources](https://remediationvsmitigation.com/risk-acceptance-form/maximum-durations/index.md)
- [How to Verify a Mitigation Works: Checks for 5 Real CVEs](https://remediationvsmitigation.com/guides/verifying-a-mitigation-works/index.md)
- [Mitigation vs Remediation Wording in Vendor Advisories](https://remediationvsmitigation.com/guides/mitigation-vs-remediation-in-vendor-advisories/index.md)
