GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - SlateGitOrg/kbchain: Decides which Windows hosts still miss a fix by walking update supersedence and per-branch build revisions, so a host on a later cumulative update is never flagged for an older KB.

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
assets
assets
 
 
data
data
 
 
src/kbchain
src/kbchain
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 
uv.lock
uv.lock
 
 

Repository files navigation

kbchain

CI

kbchain

kbchain decides which Windows hosts still miss a fix. It reads an update catalog and a host inventory, walks the supersedence graph and compares build revisions, so a host on a later cumulative update is not flagged for an older KB, and a host whose update is installed but not yet running, or was rolled back, is not counted as patched. It ships a Typer command line (generate, lint-catalog, status, host, plan) and runs on synthetic data only; no network is used.

The problem

A retail chain reports patch compliance for about 2,500 store PCs and back-office servers on Windows 10 22H2, Windows 11 23H2 and 24H2, and Server 2022. The report checks whether the exact update named in each advisory is on the installed list. Cumulative updates replace each other every month, so a host on the November update is flagged as missing the September KB it no longer lists. In the other direction, a host where the update installed but the reboot is pending, or where the install rolled back, shows the update in the installed list and is counted as patched. Both errors waste analyst time and hide real exposure.

How it works

flowchart LR
    CAT["Update catalog<br/>JSON"] --> GRAPH["Per-branch supersedence graph<br/>transitive closure"]
    GRAPH --> CHECK["Fix-inclusion check<br/>cycles, cross-branch edges,<br/>revision order, dropped fixes"]
    CHECK -->|"trusted edges only"| ENGINE["Status engine"]
    INV["Host inventory<br/>JSON lines"] -->|"running revision,<br/>installed updates"| ENGINE
    ENGINE --> VERDICT["Per host and vulnerability<br/>remediated, pending-reboot,<br/>inconsistent, missing,<br/>unknown, not-applicable"]
    VERDICT --> PLAN["Minimal install plan<br/>prerequisites first, then reboot"]
    VERDICT --> NAIVE["Naive exact-match report<br/>false positives and negatives"]
Loading
  1. kbchain.catalog builds one supersedence graph per Windows branch and lints it. An edge U' supersedes U is trusted only if every fix of U appears in U' or in something U' supersedes by another route.
  2. kbchain.status treats the running build revision as ground truth for cumulative updates: an LCU is in effect when its revision is at or below the host's. Other updates (servicing stack, .NET, out-of-band) are in effect when installed. A fix is present when an update in effect fixes it or supersedes, over trusted edges, an update that does.
  3. When no update in effect fixes a vulnerability but the installed list holds a cumulative update that does, the host is pending-reboot if a reboot is pending and inconsistent (failed or rolled back) otherwise.
  4. kbchain.fleet counts verdicts per vulnerability and branch and compares them with the naive check, which only asks whether the exact advisory KB is installed.
  5. kbchain.plan picks the latest cumulative update when any cumulative fix is missing, adds non-cumulative updates for the rest, prunes any step that is not needed, orders prerequisites first and ends with a reboot.

Quick start

python3 -m venv .venv   # Python 3.12 or newer
.venv/bin/pip install -e ".[dev]"
.venv/bin/kbchain generate --seed 5 --out data
.venv/bin/kbchain lint-catalog data/broken-catalog.json
.venv/bin/kbchain status --as-of 2026-11-20
.venv/bin/kbchain host MGR0006 --as-of 2026-11-20
.venv/bin/kbchain plan --as-of 2026-11-20 --host POS0143
.venv/bin/pytest

Every command accepts --format json. status, host and plan read data/catalog.json and data/hosts.jsonl unless --catalog and --hosts say otherwise. The inventory may list hosts in any order. lint-catalog exits 1 when it finds a problem.

The data is synthetic: advisory ids are DEMO-2026-NNNN, update ids are KB9xxxxxx, and hosts are POS, WKS, MGR and SRV names. data/ holds the output of generate --seed 5 (catalog, 600 hosts, truth.json) and a small broken-catalog.json.

Example output

kbchain lint-catalog data/broken-catalog.json (exit code 1):

# Catalog lint: data/broken-catalog.json

8 updates checked.

3 finding(s).

| Kind | Members | Detail |
|---|---|---|
| cycle | KB9000010, KB9000011, KB9000012 | supersedence cycle among KB9000010, KB9000011, KB9000012 |
| cross-branch | KB9000003, KB9000002 | KB9000003 (win11-24h2) supersedes KB9000002 (win11-23h2) |
| fix-dropping | KB9000021, KB9000020 | KB9000021 supersedes KB9000020 but does not carry forward DEMO-2026-0006 |

kbchain status --as-of 2026-11-20 on the seeded fleet:

# Patch compliance as of 2026-11-20

600 hosts, 60 vulnerabilities, 72 catalog updates released by that date.

## Host states

| State | Hosts |
|---|---|
| unknown | 10 |
| inconsistent | 6 |
| pending-reboot | 12 |
| missing | 461 |
| compliant | 111 |

## Status by branch

| Branch | remediated | pending-reboot | inconsistent | missing | unknown | n/a |
|---|---|---|---|---|---|---|
| server2022 | 2225 | 3 | 0 | 266 | 86 | 1020 |
| win10-22h2 | 7471 | 21 | 9 | 927 | 172 | 3400 |
| win11-23h2 | 7249 | 9 | 22 | 1135 | 135 | 2850 |
| win11-24h2 | 5677 | 6 | 0 | 873 | 44 | 2400 |
| all | 22622 | 39 | 31 | 3201 | 437 | 9670 |

## Naive exact-update match against kbchain

The naive check marks a pair patched only when the exact update named in the advisory is on the installed list. Over 25893 comparable (host, vulnerability) pairs it calls 21914 missing, of which 18710 are remediated (false positives), and 3979 patched, of which 67 are pending-reboot, inconsistent or missing (false negatives). "The update named in the advisory" is, by convention, the earliest update on the host's branch that fixes the vulnerability. This convention is hard on the naive check: most hosts run a later update, so about 85% of its missing calls are false positives here, and an advisory that names a later update would score better.

## Per vulnerability

| Vulnerability | remediated | pending-reboot | inconsistent | missing | unknown | n/a | naive missing | naive FP | naive FN |
|---|---|---|---|---|---|---|---|---|---|
| DEMO-2026-0001 | 590 | 0 | 0 | 0 | 10 | 0 | 577 | 577 | 0 |
| DEMO-2026-0002 | 525 | 0 | 0 | 7 | 8 | 60 | 518 | 511 | 0 |
| DEMO-2026-0003 | 430 | 0 | 0 | 11 | 9 | 150 | 432 | 421 | 0 |
| DEMO-2026-0004 | 390 | 0 | 0 | 13 | 7 | 190 | 398 | 385 | 0 |
| DEMO-2026-0005 | 368 | 0 | 0 | 26 | 6 | 200 | 391 | 365 | 0 |
| DEMO-2026-0006 | 556 | 0 | 0 | 34 | 10 | 0 | 583 | 549 | 0 |
| DEMO-2026-0007 | 498 | 0 | 0 | 34 | 8 | 60 | 517 | 483 | 0 |
| DEMO-2026-0008 | 412 | 0 | 0 | 29 | 9 | 150 | 401 | 372 | 0 |

...

kbchain host MGR0006 --as-of 2026-11-20, a host with a pending reboot (44 rows in full; ... marks skipped rows):

# Host MGR0006 (win11-24h2)

Running revision 26100.3725, inventory 2026-11-14 (6 days old at 2026-11-20), pending reboot: yes.

Installed updates: KB9001170 (2026-06-15), KB9001279 (2026-09-08), KB9001348 (2026-11-14)

Verdicts: 41 remediated, 3 pending-reboot, 16 n/a.

| Vulnerability | Status | Evidence |
|---|---|---|
| DEMO-2026-0001 | remediated | running revision 26100.3725 >= 26100.2328 (KB9000926) and fixes DEMO-2026-0001 |
| DEMO-2026-0002 | remediated | running revision 26100.3725 >= 26100.2481 (KB9000965) and fixes DEMO-2026-0002 |
| ... | ... | ... |
| DEMO-2026-0010 | remediated | running revision 26100.3725 >= 26100.3602 (KB9001313) and fixes DEMO-2026-0010 |
| DEMO-2026-0011 | remediated | running revision 26100.3725 >= 26100.3725 (KB9001329) and fixes DEMO-2026-0011 |
| DEMO-2026-0012 | pending-reboot | KB9001348 (26100.3857) is installed but running revision is 26100.3725 and a reboot is pending |
| ... | ... | ... |
| DEMO-2026-0024 | pending-reboot | KB9001348 (26100.3857) is installed but running revision is 26100.3725 and a reboot is pending |
| ... | ... | ... |
| DEMO-2026-0036 | pending-reboot | KB9001348 (26100.3857) is installed but running revision is 26100.3725 and a reboot is pending |
| ... | ... | ... |

kbchain plan --as-of 2026-11-20 --host POS0143, a host four months behind:

# Install plans as of 2026-11-20

1 host: 1 need action, 0 are compliant, 0 have stale inventory and cannot be planned.

## POS0143 (win10-22h2)

Resolves: 14 missing.

1. install KB9000449 (ssu): required before KB9000496
2. install KB9000300 (dotnet): fixes 1 outstanding: DEMO-2026-0053
3. install KB9000496 (lcu): fixes 13 outstanding: DEMO-2026-0009, DEMO-2026-0011, DEMO-2026-0012, ...
4. reboot

Design decisions

  • Revision over list. For cumulative updates the running build revision decides, and the installed list only explains a gap. This is what separates pending-reboot and rolled-back hosts from patched ones. The cost is that the inventory must carry the running revision; a collector that only exports the hotfix list cannot use kbchain.
  • Supersedence is trusted only where the fix carries forward. An edge that drops a fix, crosses branches, inverts revision order or sits inside a cycle is ignored and reported as a warning. This can under-report remediation when a catalog has a wrong edge, which is the safer direction; lint-catalog shows what to repair.
  • Non-cumulative updates count when installed. A .NET or out-of-band update that requires a reboot is treated as in effect once listed, because the inventory has no per-update reboot state. A pending reboot is therefore only attributed to cumulative updates, and it cannot be tied to one of them: a host with a pending reboot and an older rolled-back cumulative update listed is reported pending-reboot for that update's fixes.
  • Stale inventory is unknown, not missing. A host last inventoried more than 14 days before --as-of is not judged; plan asks for a fresh inventory instead of guessing.
  • Plans are irredundant, not provably smallest. After choosing the latest cumulative update, a greedy cover handles the remaining fixes and a pruning pass drops any step whose removal leaves everything covered. Tests check that every kept step is needed on every actionable host, but a smaller set could exist for exotic catalogs.
  • An independent oracle for the data. The generator derives truth.json from month arithmetic about each planted host, without the graph or revision comparison the engine uses, so the engine is checked against a different computation.

Testing

GITHUB_ACTIONS=true CI=true COLUMNS=80 .venv/bin/pytest

87 tests pass. They cover:

  • the broken catalog's exact findings and a clean generated catalog;
  • hand fixtures: a host on a later LCU is remediated while the naive check calls it missing, pending-reboot becomes remediated after a simulated reboot, a rolled-back install stays inconsistent even after a reboot, the superseded out-of-band case, and the .NET vulnerability that LCUs never fix;
  • status counts, planted host names and the naive false-positive and false-negative counts equal to truth.json on the seeded fleet;
  • two hypothesis properties: installing any update never enlarges a host's missing set, and a plan leaves nothing outstanding after simulation, after which a second plan is empty;
  • plan minimality on every actionable host (removing any single non-reboot step leaves something outstanding) and servicing stack updates ordered before the LCUs that need them;
  • supersedence edges with two problems, a fix carried only over an untrusted route, the pending-reboot limit for rolled-back updates, prerequisite cycles, and committed data/ equal to generate --seed 5;
  • identical output across runs and when the host file's lines are shuffled.

Project layout

src/kbchain/
  model.py      update and host types, revisions, JSON loading
  catalog.py    supersedence graph, fix-inclusion check, lint, closure
  status.py     per host and vulnerability verdicts with evidence
  fleet.py      fleet counts and the naive exact-match comparison
  plan.py       minimal ordered install plans and a plan simulator
  generate.py   seeded catalog, inventory, truth and broken catalog
  render.py     Markdown and JSON output
  cli.py        Typer commands
data/           seeded sample data and broken-catalog.json
tests/          pytest and hypothesis tests

License

MIT. See LICENSE.

About

Decides which Windows hosts still miss a fix by walking update supersedence and per-branch build revisions, so a host on a later cumulative update is never flagged for an older KB.

Topics

endpoint-securitygraph-algorithmspatch-compliancesupersedencevulnerability-managementwindows

Resources

Readme
MIT license
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.