Skip to content

About

Scan coverage that attributes each scan to the device holding the IP at scan time via DHCP leases, and counts a host with zero findings as clean only when that scan authenticated.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

provenclean

CI

provenclean

provenclean measures vulnerability-scan coverage on a network where IP addresses change hands. It attributes each scan to the device that held the target address for the whole scan, using DHCP leases and static assignments, and it counts a host with zero findings as clean only when that scan authenticated. A host whose scan could not log in is reported as unknown. All data in this repository is synthetic: a seeded generator writes the inputs together with the ground truth the analysis has to recover.

The problem

A university security office scans about 1,200 office, lab and server hosts every week. DHCP leases churn daily, and the report joins scan results to the CMDB by each host's current IP. That produces four errors:

  • After a lease change, findings land on whichever machine holds the address now, not the one that was scanned.
  • Hosts whose scan failed to authenticate report zero local findings and are counted as clean.
  • Retired machines still marked active inflate the denominator.
  • Devices that never reached the CMDB do not appear at all.

How it works

flowchart LR
    L[DHCP leases] --> I["Per-IP interval index<br/>bisect, [start, end)"]
    S[Static assignments] --> I
    I --> W[Overlapping leases:<br/>later start wins, warning]
    W --> A[Attribute each scan<br/>to the MAC holding the IP<br/>for the whole scan]
    R[Scanner results] --> A
    A --> X[Scanner-observed MAC differs:<br/>mac-conflict, observed MAC used]
    A --> Y[Scan spans a lease change<br/>or has no lease:<br/>ambiguous or unattributed, set aside]
    A --> M{MAC in CMDB?}
    C[CMDB] --> M
    M -->|yes| AS[Asset]
    M -->|no| SH[Shadow device]
    E[EDR agents] --> ST[Coverage states]
    L --> ST
    AS --> ST
    SH --> ST
    ST --> D[Per department: authenticated,<br/>unauthenticated-only, unscanned,<br/>verified-clean, unknown]
    D --> CMP[Compare with the naive<br/>current-IP join]
Loading

Each command reads the five CSVs from a directory and takes the as-of date as an argument; nothing reads the wall clock.

  • leases builds a sorted segment list per IP. Overlaps are resolved by the latest start and reported as warnings. Back-to-back leases held by the same MAC are merged, so a renewal is not a change of holder.
  • attribute finds the segment that contains both the scan start and the scan end. The scanner-observed MAC, recorded when the scanner shares the subnet, overrides the lease log and the disagreement is flagged mac-conflict. A scan that starts in one lease and ends in another is ambiguous. A scan with no covering record is unattributed. Leases are [start, end), so a scan that ends exactly at a lease end is ambiguous, even when no later lease follows.
  • coverage gives each device one state over the window: retired, authenticated (an attributed scan with auth success), unauthenticated-only (scanned, never authenticated), unscanned (seen in DHCP or EDR in the 90 days before the window end, or in the window, but with no attributed scan in it) or stale-cmdb (active in the CMDB, no sighting for 90 days). A sighting is a DHCP lease, an EDR check-in or an attributed scan; a static assignment is configuration and does not count, so an active static-IP server that is neither scanned nor running EDR is stale-cmdb. The denominator is active, non-stale assets plus shadow devices.
  • shadow lists devices seen in DHCP, EDR or an attributed scan in the window with no CMDB record, with first and last sighting and the IPs they held.
  • compare recomputes findings and coverage with the naive current-IP join (the latest record per address starting before the end of the window) and puts the two side by side.

Quick start

python -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/provenclean generate --seed 3 --out data/
.venv/bin/provenclean attribute --data data/
.venv/bin/provenclean coverage --data data/ --as-of 2026-11-20 --window-days 30
.venv/bin/provenclean shadow --data data/ --as-of 2026-11-20 --window-days 30
.venv/bin/provenclean compare --data data/ --as-of 2026-11-20 --window-days 30

Every analysis command accepts --format md|json and --output FILE. To use real data, supply the same five CSVs (cmdb.csv, dhcp_leases.csv, static_assignments.csv, scans.csv, edr_agents.csv) with UTC ISO 8601 timestamps; the columns are listed in src/provenclean/dataio.py. Generating the campus takes from a few seconds to about half a minute depending on the machine.

Example output

Synthetic data from provenclean generate --seed 3. The command's own top-level heading is shown one level down so that it fits this README's outline. provenclean coverage --data data/ --as-of 2026-11-20 --window-days 30:

Coverage as of 2026-11-20 (30-day window)

Department Assets Authenticated Unauth-only Unscanned Verified clean Unknown Shadow Stale CMDB Retired Authenticated %
Administration 265 241 13 11 53 24 5 13 19 90.9%
Computer Labs 440 310 117 13 97 130 10 0 22 70.5%
Engineering 225 211 10 4 51 14 5 14 20 93.8%
Library 175 156 6 13 35 19 5 13 19 89.1%
Total 1105 918 146 41 236 187 25 40 80 83.1%

Assets = active, non-stale CMDB assets plus shadow devices. Stale CMDB and retired records are excluded. Verified clean = authenticated with zero findings; unknown = zero findings without an authenticated scan.

provenclean compare --data data/ --as-of 2026-11-20 --window-days 30:

Naive join vs attribution, as of 2026-11-20 (30-day window)

Findings in the window:

Measure Findings
All scans in window 30954
Attributed to a device 30883
Naive join put on a different device 16118
of which on another CMDB asset 15616
of which on no CMDB asset (dropped) 502
Set aside (ambiguous or unattributed) 71
of which the naive join credits to an asset 71

Coverage and clean figures per department:

Department Naive scanned Authenticated Naive clean (as reported) Naive clean (same denominator) Verified clean Naive minus verified clean, same denominator (pts)
Administration 97.0% 90.9% 15.0% 15.5% 20.0% -4.5
Computer Labs 97.7% 70.5% 28.8% 28.2% 22.0% +6.2
Engineering 97.3% 93.8% 12.4% 12.9% 22.7% -9.8
Library 93.1% 89.1% 12.0% 12.6% 20.0% -7.4

"As reported" is what the naive join gives when it divides by every active CMDB asset, stale ones included. The other naive columns, and the last column, use the verified denominator (active, non-stale assets plus shadow devices) with only the naive join's own asset counts in the numerator, so the last column is the like-for-like difference. It is signed: negative means the naive join reports fewer clean assets than the verified view. That happens where misattributed findings land on assets that are really clean, and because the naive join cannot see shadow devices.

Computer Labs is the one department where the naive join is clearly too optimistic, by 6.2 points on the same denominator (28.2% against 22.0%). 100 lab hosts sit on the subnet whose scan credential expired: every scan of it fails to authenticate and reports zero findings, and the naive report counts those hosts as clean, where the verified view files them under unknown. That effect is partly offset by findings the naive join pins on the wrong assets and by shadow devices it cannot count, so the net gap is smaller than the credential problem alone. Switching to the verified denominator moves Computer Labs only from 28.8% to 28.2%, so the denominator change explains little of it.

provenclean shadow --data data/ --as-of 2026-11-20 --window-days 30:

Shadow devices as of 2026-11-20 (30-day window)

25 devices seen with no CMDB record.

MAC Department First seen Last seen IPs held Seen in
00:25:1a:5e:02:00 Administration 2026-10-07T00:00:00Z 2026-11-20T13:00:00Z 10.30.2.71 dhcp+edr+scan
3c:f5:6e:d9:1d:18 Administration 2026-10-07T00:00:00Z 2026-11-20T14:00:00Z 10.30.2.128 dhcp+edr+scan
ac:bf:a4:e9:4b:77 Administration 2026-10-07T00:00:00Z 2026-11-20T19:00:00Z 10.30.2.48, 10.30.2.64, 10.30.2.156, 10.30.2.221 dhcp+edr+scan
d8:07:66:5f:34:f5 Administration 2026-10-07T00:00:00Z 2026-11-20T18:00:00Z 10.30.2.5, 10.30.2.164, 10.30.2.172, 10.30.2.253 dhcp+edr+scan
...

Design decisions

  • Interval join, not a point lookup. A scan is attributed only when one lease segment contains both its start and its end. Guessing from the start time would hand a straddling scan to a device that may not have been on the wire for most of it. The cost is that a few real scans are set aside; the data keeps them visible as ambiguous.
  • Scanner MAC beats the lease log. The scanner's own ARP answer is direct evidence, the lease log is a record of intent. The disagreement is kept as mac-conflict rather than silently resolved, so a bad lease feed can be found.
  • Zero findings means clean only after authentication. An unauthenticated scan sees no local vulnerabilities, so its zero is absence of evidence. Such hosts are split into unknown, which shows up as a large share in the lab subnet with the expired credential.
  • Overlaps resolve to the later start. When two lease records cover one IP, the newer record reflects the most recent DHCP decision. It is reported as a warning so that the overlap can be fixed at source.
  • Shadow devices are in the denominator. A device on the network that the CMDB does not know is still a host the office is responsible for, so it counts towards coverage and, if scanned, towards findings.
  • Pandas for loading, plain Python for the join. Inputs are validated and sorted with pandas; the interval index and attribution use sorted lists and bisect, which keeps tie-breaking explicit. All sorts end in a unique key, so shuffling input rows changes no output byte.

Testing

.venv/bin/pytest

54 tests pass. The suite covers the interval index (including the boundary at exactly the lease change), hand-made attribution and coverage cases, input validation, and the seeded campus checked against truth.json: attribution accuracy, the 6 straddling scans, the 3 scanner-MAC conflicts, per-department coverage counts, the expired-credential subnet, the 40 stale entries, the 25 shadow devices, the naive join's misattributed findings, the 2 overlapping leases, byte-identical output after shuffling every input, and the CLI.

Project layout

src/provenclean/
  cli.py          Typer commands
  analysis.py     loads data and builds each command's result
  dataio.py       CSV loading and validation
  leases.py       per-IP interval index
  attribute.py    scan attribution and CMDB lookup
  coverage.py     coverage state per device and per department
  shadow.py       devices missing from the CMDB
  compare.py      naive current-IP join versus attribution
  report.py       Markdown and JSON rendering
  generate.py     seeded synthetic campus and truth.json
  normalize.py    MAC, hostname and IP helpers
  timeutil.py     UTC helpers and the analysis window
tests/            pytest suite

License

MIT. See LICENSE.

About

Scan coverage that attributes each scan to the device holding the IP at scan time via DHCP leases, and counts a host with zero findings as clean only when that scan authenticated.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages