OSV Schema Ranges: introduced, fixed and last_affected

How OSV affected ranges work: introduced, fixed, last_affected and limit events, the IsVulnerable algorithm, and what 12,240 live 2026 GitHub-reviewed advisories actually use. Includes a tested Python evaluator for PyPI and npm.

A yellow tape measure, a translucent meter tape and a steel ruler laid side by side on a white surface, each with different markings
Photo by William Warby on Unsplash

Short answer: In an OSV record, each affected[].ranges[] entry is a timeline of events. A version is affected from an introduced event until a fixed event, where the fixed version is not affected. If the range uses last_affected instead, that version is affected and anything above it is assumed safe. "introduced": "0" means “from the first version”. In the GitHub Advisory Database, every range is type ECOSYSTEM and has exactly one introduced event. That means your matcher needs a real per-ecosystem version comparator, not string comparison.

OSV is the format behind osv.dev, the GitHub Advisory Database (GHSA), the Go vulnerability database, PyPA’s advisories and many Linux distributions. If you build or maintain anything that answers “is jupyterlab 4.6.3 affected?”, these few fields decide whether your answer is right. That includes a dependency scanner, an SBOM matcher or a script that turns Dependabot data into tickets. This guide covers the spec rules, what real GitHub records look like, and a tested evaluator. It complements the CVE JSON 5 affected-versions guide, which covers the equivalent fields in CVE records.

Method

  • Spec: docs/schema.md from ossf/osv-schema, fetched 2 December 2026. Its header reads “Version 1.9.3 (November 30, 2026)”.
  • Data: github/advisory-database, advisories/github-reviewed/2026/ at commit 11d8f435 (2 December 2026, 03:39 UTC). These are the GitHub-reviewed advisories filed under 2026: 12,918 JSON files, of which 678 carry withdrawn, leaving 12,240 live records.
  • Counts come from a Python script that reads every file. Counts of “ranges” and “affected entries” are the same here, because every GitHub affected entry in this set has at most one range.

The fields

"affected": [ {
  "package":  { "ecosystem": "PyPI", "name": "jupyterlab", "purl": "..." },
  "ranges":   [ { "type": "ECOSYSTEM", "events": [ {"introduced": "4.0.0"}, {"fixed": "4.5.11"} ] } ],
  "versions": [ "..." ],
  "database_specific": { }
} ]
FieldWhat the spec saysWhat it means for a matcher
package.ecosystem + nameIdentifies the packageMatch on both. Never match on name alone.
ranges[].typeSEMVER, ECOSYSTEM or GITPicks the comparator. GIT needs the commit graph.
introducedStart of a vulnerable stretch; "0" sorts before every versionAt least one is required per range
fixedFirst version that contains the fixThe fixed version is not affected
last_affected“the hard ceiling of the vulnerability at the time of publication”That version is affected; versions above are assumed unaffected
limitUpper limit; "*" means infinity, and an implicit "*" applies if absentMostly relevant to GIT ranges
versions[]Explicit list of affected versionsA version is affected if it is in this list or inside any range

Three rules from the spec trip up hand-written parsers:

  1. One key per event. “Only a single type (either introduced, fixed, last_affected, limit) is allowed in each event object.” So {"introduced": "1.0.0", "fixed": "1.0.2"} is invalid; it must be two objects.
  2. fixed or last_affected, not both. “Entries in the events array may be “last_affected” or “fixed” events, but not both.” The spec adds that it is “strongly recommended to use fixed instead of last_affected where possible.”
  3. ECOSYSTEM strings are not SemVer. They are “arbitrary, uninterpreted strings specific to the package ecosystem”. For these ranges the spec recommends also supplying an explicit versions list, “because ECOSYSTEM range inclusion queries may not be able to be answered without reference to the package ecosystem’s own logic”.

How evaluation works

The spec gives IsVulnerable as pseudocode. Per range, it sorts the events by version and walks them: introduced at or below v sets vulnerable, fixed at or below v clears it, and a last_affected strictly below v clears it. A version is affected if any range says so or if it is listed in versions.

Range1.0.11.0.22.1.2142.1.215
introduced 0, fixed 1.0.2affectednot affectednot affectednot affected
introduced 0, last_affected 2.1.214affectedaffectedaffectednot affected
introduced 0 (no closing event)affectedaffectedaffectedaffected

The middle row is the false-negative risk the spec warns about. last_affected records what was known at publication. If the maintainers never ship a fix, every later version still matches as “not affected”.

What GitHub’s 2026 records actually use

Measure (live 2026 GitHub-reviewed records)Count
Records12,240
affected entries23,877
Entries with a range23,747
Entries with only a versions list130
Ranges ending in fixed22,028
Ranges ending in last_affected1,603
Ranges with only introduced116
Ranges with more than one introduced0
Ranges with a limit event0

Across all 12,918 files, including withdrawn ones, every one of the 24,464 ranges is "type": "ECOSYSTEM". That holds even for npm and Go, which use SemVer-style versions. Every file declares "schema_version": "1.4.0", while the spec text is now at 1.9.3.

Ecosystems by affected entries (all 12,918 files): npm 5,721, NuGet 5,143, Go 3,415, PyPI 3,142, Maven 2,832, Packagist 2,643, crates.io 1,131, RubyGems 421, Hex 103, GitHub Actions 28, SwiftURL 25, Pub 2.

Practical consequences:

  • Multiple vulnerable branches show up as separate affected entries for the same package, each with its own range. They are not one range with several introduced events. GHSA-3325-v43h-43rv (JupyterLab, CVE-2026-102904) has two jupyterlab entries: introduced 4.0.0 → fixed 4.5.11 and introduced 4.6.0 → fixed 4.6.4. A matcher that stops at the first entry for a package misses the second branch.
  • Mixed fixed and last_affected in one advisory is normal. GHSA-62vg-58rm-qff7 (@angular/router, CVE-2026-111752) has four entries. Three branches have fixed versions (22.2.1, 21.2.25, 20.3.33). The oldest is introduced 0 → last_affected 19.2.25, so any 19.x above 19.2.25 evaluates as not affected, whether or not it contains a fix.

The database_specific trap

GitHub adds a range-level database_specific.last_known_affected_version_range string, such as "<= 16.3.0". The advisory-database README describes it as range information “that is not representable in OSV format”, and says that GitHub’s database_specific values “are subject to change without notice. Consuming systems should not rely on them for processing vulnerability information.”

The string is not always redundant with the OSV range:

Live 2026 rangesCountExample
fixed event + "<= X" string6,526mercurius: fixed 16.4.0, string <= 16.3.0
fixed event + "< X" string101netty-codec-http2 (CVE-2026-33871): fixed 4.2.11.Final, string < 4.2.10.Final
only introduced + "< X" string79frigate (CVE-2026-33125): range introduced 0, string < 0.16.3

In the last row, the OSV range has no closing event, so any OSV-native evaluator treats every version as affected, including the one the string implies is safe. Of the 79, 49 are Go modules, 10 Maven, 9 npm, 7 Packagist, 3 PyPI and 1 crates.io. Our evaluator below reports frigate 0.16.3 as affected, which is what the OSV data says. Following GitHub’s guidance, the safe reading is to trust the range and treat the string only as a hint for manual review. Resolving the disagreement means checking the vendor advisory.

Withdrawn records are the other trap. Of the 678 withdrawn 2026 files, 659 have summaries beginning “Duplicate Advisory”. In 210 of their ranges, there is only an introduced event. A matcher that ignores withdrawn will raise “all versions affected” alerts for advisories GitHub has retracted.

A tested evaluator

This is a port of the spec’s IsVulnerable pseudocode to Python 3. It supports PyPI (PEP 440, via packaging 26.3) and npm (SemVer 2.0 precedence). It refuses other ecosystems and GIT ranges rather than guessing. Treat it as a reference implementation for tests, not a production scanner: Maven, NuGet, Go pseudo-versions and Debian need their own comparators.

"""Evaluate whether a package version is affected by an OSV record.
Port of the IsVulnerable pseudocode in the OSV schema (ossf/osv-schema docs/schema.md).
Usage: python3 osv_affected.py <osv.json> <ecosystem> <package> <version>
"""
import json, re, sys
from functools import cmp_to_key
from packaging.version import Version

SEMVER = re.compile(r"^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$")

def semver_key(v):
    m = SEMVER.match(v)
    if not m:
        raise ValueError(f"not SemVer: {v}")
    core = tuple(int(x) for x in m.group(1, 2, 3))
    pre = m.group(4)
    if pre is None:
        return core, (1,)            # a release sorts after its prereleases
    ids = tuple((0, int(p), "") if p.isdigit() else (1, 0, p) for p in pre.split("."))
    return core, (0,) + ids

def compare(eco, a, b):
    if a == "0":                      # OSV special value: sorts before everything
        return 0 if b == "0" else -1
    if b == "0":
        return 1
    if eco == "PyPI":
        ka, kb = Version(a), Version(b)
    elif eco == "npm":
        ka, kb = semver_key(a), semver_key(b)
    else:
        raise NotImplementedError(f"no comparator for {eco}")
    return (ka > kb) - (ka < kb)

def event_value(evt):
    (k, v), = evt.items()            # the spec allows exactly one key per event
    return k, v

def included_in_range(eco, v, rng):
    if rng["type"] == "GIT":
        raise NotImplementedError("GIT ranges need the commit graph")
    events = [event_value(e) for e in rng["events"]]
    limits = [val for k, val in events if k == "limit"]
    if limits and not any("*" in l or compare(eco, v, l) < 0 for l in limits):
        return False                 # BeforeLimits(): no limit means an implicit "*"
    ordered = sorted((e for e in events if e[0] != "limit"),
                     key=cmp_to_key(lambda x, y: compare(eco, x[1], y[1])))
    vulnerable = False
    for k, val in ordered:
        c = compare(eco, v, val)
        if k == "introduced" and c >= 0:
            vulnerable = True
        elif k == "fixed" and c >= 0:
            vulnerable = False
        elif k == "last_affected" and c > 0:
            vulnerable = False
    return vulnerable

def is_affected(osv, eco, name, v):
    if osv.get("withdrawn"):
        return False, "record withdrawn " + osv["withdrawn"]
    for a in osv.get("affected", []):
        p = a["package"]
        if p["ecosystem"] != eco or p["name"] != name:
            continue
        if v in a.get("versions", []):
            return True, "listed in versions[]"
        for r in a.get("ranges", []):
            if included_in_range(eco, v, r):
                return True, "inside range " + json.dumps(r["events"])
    return False, "not inside any range or versions[]"

if __name__ == "__main__":
    path, eco, name, ver = sys.argv[1:5]
    osv = json.load(open(path))
    hit, why = is_affected(osv, eco, name, ver)
    print(f"{osv['id']} {name}@{ver}: {'AFFECTED' if hit else 'not affected'} ({why})")

We ran it on 2 December 2026 against the advisory-database files named above:

GHSA-3325-v43h-43rv [email protected]: AFFECTED (inside range [{"introduced": "4.0.0"}, {"fixed": "4.5.11"}])
GHSA-3325-v43h-43rv [email protected]: not affected (not inside any range or versions[])
GHSA-3325-v43h-43rv [email protected]: AFFECTED (inside range [{"introduced": "4.6.0"}, {"fixed": "4.6.4"}])
GHSA-3325-v43h-43rv [email protected]: not affected (not inside any range or versions[])
GHSA-3325-v43h-43rv [email protected]: not affected (not inside any range or versions[])
GHSA-62vg-58rm-qff7 @angular/[email protected]: AFFECTED (inside range [{"introduced": "0"}, {"last_affected": "19.2.25"}])
GHSA-62vg-58rm-qff7 @angular/[email protected]: not affected (not inside any range or versions[])
GHSA-62vg-58rm-qff7 @angular/[email protected]: AFFECTED (inside range [{"introduced": "20.0.0"}, {"fixed": "20.3.33"}])
GHSA-vg28-83rp-8xx4 [email protected]: AFFECTED (inside range [{"introduced": "0"}])
GHSA-3r78-rqg8-95gg [email protected]: not affected (record withdrawn 2026-03-24T19:05:32Z)

Note the 4.6.0rc1 line. Under PEP 440 a release candidate sorts before 4.6.0, so it falls outside introduced 4.6.0. Whether a prerelease really carries the bug is a question for the maintainers; the data only covers the versions it names.

Common mistakes

  • Comparing version strings lexically. "4.10.0" < "4.9.0" as strings. Use the ecosystem’s comparator.
  • Treating last_affected like fixed. It shifts the boundary by one version in the wrong direction, so the last vulnerable version gets marked safe.
  • Reading only the first affected entry for a package. GitHub splits branches into separate entries.
  • Ignoring withdrawn. Withdrawn duplicates often carry “all versions” ranges.
  • Using database_specific as the source of truth. GitHub explicitly says not to.
  • Matching by name across ecosystems. jquery on npm and jquery-rails on RubyGems are different packages with different version lines.

Where this fits

Version matching answers “does this advisory apply to us?”. It comes before the prioritization questions in the vulnerability prioritization workflow from CVE record to patch ticket. If you consume CVE records as well as OSV, the CVE packageURL guide covers joining CVE JSON 5.2 records to SBOM purls. If a supplier says a matched version is not exploitable in their product, that statement belongs in VEX, covered in VEX explained. To join GHSA IDs to KEV and EPSS, see our GHSA vs CVE join guide.

Limits of this article

  • The counts cover GitHub-reviewed advisories filed under 2026 at one commit. Other OSV sources, such as Go’s vulndb, PyPA, distributions and osv.dev’s own enrichment, may use SEMVER, GIT, versions and limit differently; we did not measure them.
  • osv.dev says it expands ranges into versions lists for supported ecosystems; we did not test osv.dev’s API output.
  • The evaluator handles PyPI and npm only and was tested on the four records shown, not fuzzed against each ecosystem’s reference implementation.
  • We did not check which @angular/router or frigate releases actually exist or contain fixes; the examples show how the records evaluate, not the state of those projects.

Sources and verification

Important claimSourceStatus
Event semantics, one key per event, fixed vs last_affected, ECOSYSTEM/SEMVER/GIT definitions, IsVulnerable pseudocode, spec version 1.9.3OSV schema docs/schema.mdVerified (verbatim)
database_specific values “subject to change without notice” and “should not rely on them”; last_known_affected_version_range purposegithub/advisory-database READMEVerified (verbatim)
Advisories published in OSV formatGitHub Docs: GitHub Advisory DatabaseVerified
All counts (12,918 / 678 / 12,240 records; range types; events; database_specific disagreements; ecosystem split)advisory-database commit 11d8f435, computed by scriptVerified (computed)
Evaluator output for GHSA-3325-v43h-43rv, GHSA-62vg-58rm-qff7, GHSA-vg28-83rp-8xx4, GHSA-3r78-rqg8-95ggScript run 2 December 2026Verified (run)

Frequently asked questions

What does last_affected mean in the OSV schema?

It is the last version known to be vulnerable when the record was published. That version is affected and versions above it are treated as unaffected. The spec prefers fixed because last_affected can miss later versions that were never actually fixed.

Is the fixed version affected in an OSV range?

No. The OSV evaluation pseudocode sets vulnerable to false once the version is greater than or equal to the fixed event, so the fixed version itself is not affected. A last_affected version, by contrast, is affected.

What is the difference between SEMVER and ECOSYSTEM ranges in OSV?

SEMVER ranges compare versions using SemVer 2.0 precedence. ECOSYSTEM ranges hold version strings that only the package ecosystem's own rules can order, such as PEP 440 for PyPI or Maven's ordering. GitHub's OSV files use ECOSYSTEM for every range, including npm and Go.

What does an OSV range with only an introduced event mean?

It means every version from introduced onward is affected, with no known fix. In live 2026 GitHub-reviewed advisories, 116 ranges look like this. In 79 of them, GitHub's own database_specific string gives an upper bound that the OSV range does not carry.

Osv SchemaOsvGhsaGithub Advisory DatabaseDependency ScanningVersion MatchingVulnerability Management