<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>C/C++ | FirewallSync</title><link>https://firewallsync.com/tags/c/c++/</link><description>Practical cybersecurity writing for engineering teams that ship fast.</description><language>en-us</language><image><url>https://firewallsync.com/icon-512.png</url><title>FirewallSync</title><link>https://firewallsync.com/</link></image><lastBuildDate>Fri, 04 Dec 2026 04:40:00 +0000</lastBuildDate><atom:link href="https://firewallsync.com/tags/c/c++/index.xml" rel="self" type="application/rss+xml"/><item><title>OSV-Scanner Git Submodules: What --include-git-root Changes</title><link>https://firewallsync.com/posts/osv-scanner-git-submodules-include-git-root-commit-scanning/</link><guid>https://firewallsync.com/posts/osv-scanner-git-submodules-include-git-root-commit-scanning/</guid><pubDate>Fri, 04 Dec 2026 04:40:00 +0000</pubDate><dc:creator>John Marshall</dc:creator><category>AppSec &amp; APIs</category><description>In OSV-Scanner v2.7.1 source, the extractor that queries submodule commit hashes runs only with --include-git-root. Without it, a C/C++ submodule is found only if it sits under a folder such as third_party or vendor, and its version is guessed from file hashes. Here is how each path works, what the JSON output fields mean, and how to check your own scan.</description><enclosure url="https://firewallsync.com/posts/osv-scanner-git-submodules-include-git-root-commit-scanning/cover_hu2206043767810644985.jpg" type="image/jpeg" length="0"/><media:content url="https://firewallsync.com/posts/osv-scanner-git-submodules-include-git-root-commit-scanning/cover_hu2206043767810644985.jpg" medium="image" type="image/jpeg" width="1200" height="630"/><content:encoded><![CDATA[<p><img src="https://firewallsync.com/posts/osv-scanner-git-submodules-include-git-root-commit-scanning/cover_hu2206043767810644985.jpg" alt="Close-up of a dense tangle of bare reddish-brown branches crossing over one another" width="1200" height="630"></p><p><strong>Short answer:</strong> OSV-Scanner&rsquo;s documentation says it &ldquo;will automatically scan git submodules&rdquo;, but in the v2.7.1 source the extractor that sends submodule commit hashes to osv.dev only runs when you pass <code>--include-git-root</code>. Without the flag, a C/C++ submodule is found only if it sits directly under a folder such as <code>third_party/</code> or <code>vendor/</code>, and its version is estimated from file hashes rather than read from Git. If your C/C++ dependencies are submodules, run <code>osv-scanner scan source -r --include-git-root .</code> and check the JSON for packages with a <code>commit</code> field.</p>
<p>We reached this by reading the source at tag <code>v2.7.1</code> (tagged 9 November 2026, the latest release tag on 4 December 2026). We could not run the OSV-Scanner binary in our environment, so the behaviour below is what the code does, not an observed scan. The last section shows how to confirm it on your own repository in a few minutes.</p>
<h2 id="two-ways-osv-scanner-finds-cc-code">Two ways OSV-Scanner finds C/C++ code</h2>
<p>C and C++ projects rarely have a lockfile, so OSV-Scanner&rsquo;s <a href="https://google.github.io/osv-scanner-v1/supported-languages-and-lockfiles/">C/C++ support</a> is &ldquo;based on commit-level data&rdquo;. The <code>directory</code> plugin preset, which is on by default for source scans alongside <code>lockfile</code> and <code>sbom</code>, holds two extractors:</p>
<table>
  <thead>
      <tr>
          <th>Extractor</th>
          <th>Triggers on</th>
          <th>What it sends to osv.dev</th>
          <th>Confidence</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>vcs/gitrepo</code></td>
          <td>Any <code>.git</code> <strong>directory</strong></td>
          <td>HEAD commit of that repository, plus the recorded commit of each submodule</td>
          <td>Exact commit</td>
      </tr>
      <tr>
          <td><code>filesystem/vendored</code></td>
          <td>A directory whose <strong>parent folder</strong> is named <code>3rdparty</code>, <code>dep</code>, <code>deps</code>, <code>thirdparty</code>, <code>third-party</code>, <code>third_party</code>, <code>libs</code>, <code>external</code>, <code>externals</code>, <code>vendor</code> or <code>vendored</code></td>
          <td>MD5 hashes of <code>.c</code>, <code>.cc</code>, <code>.cpp</code>, <code>.h</code>, <code>.hh</code>, <code>.hpp</code> files, to the experimental determineversion API</td>
          <td>Best match, used only if its score is above 0.15</td>
      </tr>
  </tbody>
</table>
<p>Both produce a package with a commit and no ecosystem. osv.dev&rsquo;s <a href="https://google.github.io/osv.dev/post-v1-query/"><code>/v1/query</code> endpoint</a> accepts &ldquo;the commit hash to query for&rdquo;. The commit-level data in OSV records comes from <code>GIT</code> ranges, which we covered in <a href="/posts/osv-git-ranges-commit-hashes-fixed-vs-limit-events/">OSV GIT ranges: commit hashes, fixed vs limit events</a>.</p>
<h2 id="what---include-git-root-actually-switches">What <code>--include-git-root</code> actually switches</h2>
<p>Two lines in <code>pkg/osvscanner/scan.go</code> at v2.7.1 decide the behaviour:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#75715e">// configuring the vendored extractor
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#a6e22e">ScanGitDir</span>: !<span style="color:#a6e22e">actions</span>.<span style="color:#a6e22e">IncludeGitRoot</span>,
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// building the plugin list
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#66d9ef">if</span> !<span style="color:#a6e22e">actions</span>.<span style="color:#a6e22e">IncludeGitRoot</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">actions</span>.<span style="color:#a6e22e">PluginsDisabled</span> = append(<span style="color:#a6e22e">actions</span>.<span style="color:#a6e22e">PluginsDisabled</span>, <span style="color:#a6e22e">gitrepo</span>.<span style="color:#a6e22e">Name</span>)
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>The flag&rsquo;s help text is &ldquo;include scanning git root (non-submoduled) repositories&rdquo;, and it defaults to <code>false</code>. But disabling <code>vcs/gitrepo</code> turns off more than root scanning:</p>
<ul>
<li><code>vcs/gitrepo</code> only fires on a <code>.git</code> path that is a directory. In a standard modern checkout, a submodule&rsquo;s <code>.git</code> is a small file pointing into the parent&rsquo;s <code>.git/modules/</code>, so the extractor normally fires once, on the superproject&rsquo;s <code>.git</code> directory.</li>
<li>From there it calls go-git&rsquo;s <code>Worktree().Submodules()</code> and emits one commit query per submodule. That loop is the only place in the v2.7.1 source that enumerates submodules.</li>
</ul>
<p>So with the default settings, no submodule commit reaches osv.dev from this extractor. With <code>--include-git-root</code>, you get the superproject&rsquo;s own HEAD commit <strong>and</strong> every submodule&rsquo;s commit.</p>
<p>The flag also flips the vendored extractor&rsquo;s <code>ScanGitDir</code> setting. With the flag, the vendored extractor skips any directory that contains a <code>.git</code> entry, which avoids reporting a submodule twice (once by exact commit, once by hash estimate).</p>
<h2 id="the-two-configurations-side-by-side">The two configurations side by side</h2>
<p>Assume a repository with a submodule at <code>third_party/zlib</code> and another at <code>src/libfoo</code>.</p>
<table>
  <thead>
      <tr>
          <th></th>
          <th>Default</th>
          <th><code>--include-git-root</code></th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Superproject HEAD commit queried</td>
          <td>No</td>
          <td>Yes</td>
      </tr>
      <tr>
          <td><code>third_party/zlib</code></td>
          <td>Hashed by the vendored extractor; version estimated</td>
          <td>Queried by exact recorded commit; vendored extractor skips it</td>
      </tr>
      <tr>
          <td><code>src/libfoo</code></td>
          <td><strong>Not scanned</strong> (parent folder <code>src</code> is not on the vendored list, and gitrepo is off)</td>
          <td>Queried by exact recorded commit</td>
      </tr>
      <tr>
          <td>Plain copied code in <code>vendor/libbar</code> (no <code>.git</code>)</td>
          <td>Hashed and estimated</td>
          <td>Hashed and estimated</td>
      </tr>
  </tbody>
</table>
<p>The superproject HEAD query is usually harmless for private code, because osv.dev has no <code>GIT</code> ranges for your repository. It matters if you are scanning a fork of a public project that does have OSV records.</p>
<h2 id="which-commit-is-queried-for-a-submodule">Which commit is queried for a submodule</h2>
<p><code>vcs/gitrepo</code> uses <code>status.Expected</code> from go-git. In go-git v5.19.3, the version OSV-Scanner v2.7.1 pins, <code>Expected</code> is set from the superproject&rsquo;s index entry for the submodule path, before go-git checks whether the submodule is initialised. Two practical results:</p>
<ol>
<li><strong>The recorded commit wins.</strong> If a developer ran <code>git checkout</code> inside a submodule but did not commit the new gitlink in the parent repository, OSV-Scanner still queries the commit the parent repository records.</li>
<li><strong>Uninitialised submodules can still be queried.</strong> The <code>Expected</code> hash comes from the index, not the submodule&rsquo;s files. The documentation&rsquo;s advice to run <code>git submodule update</code> first still matters for the vendored extractor, which needs the files on disk to hash them.</li>
</ol>
<p>If go-git returns an error for a submodule&rsquo;s status, the extractor skips that submodule silently (<code>continue</code>), so a broken submodule checkout can drop out of results without a warning.</p>
<h2 id="reading-commit-based-results">Reading commit-based results</h2>
<p>Commit-matched packages look different from lockfile packages in every output format. Field names below are from <code>pkg/models/results.go</code> at v2.7.1.</p>
<table>
  <thead>
      <tr>
          <th>Output</th>
          <th>Field</th>
          <th>Value for a commit-matched package</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>JSON</td>
          <td><code>results[].source.type</code></td>
          <td><code>git</code> for packages from <code>vcs/gitrepo</code></td>
      </tr>
      <tr>
          <td>JSON</td>
          <td><code>results[].packages[].package.ecosystem</code></td>
          <td><code>&quot;&quot;</code> (empty string)</td>
      </tr>
      <tr>
          <td>JSON</td>
          <td><code>results[].packages[].package.commit</code></td>
          <td>Full commit hash</td>
      </tr>
      <tr>
          <td>JSON</td>
          <td><code>results[].packages[].package.version</code></td>
          <td>Usually empty</td>
      </tr>
      <tr>
          <td>Table</td>
          <td>Ecosystem column</td>
          <td><code>GIT</code></td>
      </tr>
      <tr>
          <td>Table</td>
          <td>Version column</td>
          <td>First 8 characters of the commit</td>
      </tr>
      <tr>
          <td>SARIF</td>
          <td>Version shown in the result text</td>
          <td>Full commit hash</td>
      </tr>
  </tbody>
</table>
<p>In the v2.7.1 source, the location recorded for a submodule is the <code>.git</code> directory path joined with the submodule path, so expect <code>source.path</code> values ending in <code>.git/third_party/zlib</code> rather than <code>third_party/zlib</code>.</p>
<h2 id="check-your-own-repository">Check your own repository</h2>
<p>These commands are illustrative; they use flags documented for OSV-Scanner v2 and fields from the v2.7.1 result model. Run them from the superproject root.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>git submodule status            <span style="color:#75715e"># list submodules and the commit each is pinned to</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>osv-scanner scan source -r --format json . &gt; default.json
</span></span><span style="display:flex;"><span>osv-scanner scan source -r --include-git-root --format json . &gt; gitroot.json
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Packages found by commit in each run</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> f in default.json gitroot.json; <span style="color:#66d9ef">do</span>
</span></span><span style="display:flex;"><span>  echo <span style="color:#e6db74">&#34;== </span>$f<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>  jq -r <span style="color:#e6db74">&#39;.results[] | .source as $s | .packages[]
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">         | select(.package.commit != null)
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">         | [$s.type, $s.path, .package.commit[0:12], (.vulnerabilities // [] | length)]
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">         | @tsv&#39;</span> <span style="color:#e6db74">&#34;</span>$f<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">done</span>
</span></span></code></pre></div><p>If a submodule from <code>git submodule status</code> appears in <code>gitroot.json</code> but not in <code>default.json</code>, your default scans have been missing it.</p>
<h2 id="from-commit-findings-to-a-patch-decision">From commit findings to a patch decision</h2>
<p>A commit match gives you OSV IDs, not a package version to bump. To decide what to fix first:</p>
<ol>
<li>Read each result&rsquo;s <code>groups[].aliases</code> to find the CVE IDs.</li>
<li>Join those CVEs to the <a href="/posts/cisa-kev-json-feed-what-each-field-means-and-how-to-match-it-against-a-scanner-export/">CISA KEV feed</a> and EPSS.</li>
<li>Fix by moving the submodule to a commit that contains the fix (the <code>fixed</code> commit in the OSV record or a descendant of it), then commit the new gitlink in the parent repository.</li>
</ol>
<p>The full flow from CVE record to ticket is in our <a href="/posts/vulnerability-prioritization-workflow-cve-record-to-patch-ticket/">vulnerability prioritization workflow</a>.</p>
<h2 id="limits-of-this-article">Limits of this article</h2>
<ul>
<li>This is a source reading of OSV-Scanner v2.7.1, not a test run. The <code>main</code> branch has changed <code>scan.go</code> and the source command since that tag, though the lines quoted above have not moved in meaning.</li>
<li>The documentation and the code disagree on whether submodules are scanned by default. Our search did not turn up an issue explaining the intent. If a later release changes the behaviour, the documentation may become correct.</li>
<li>Commit-level coverage is incomplete. The OSV-Scanner documentation warns that &ldquo;there may be vulnerabilities in their dependencies that could be excluded from OSV-Scanner results&rdquo;.</li>
<li>The vendored extractor needs osv.dev. The source disables it when OSV-Scanner runs in offline comparison mode.</li>
</ul>
<h2 id="sources-and-verification">Sources and verification</h2>
<table>
  <thead>
      <tr>
          <th>Important claim</th>
          <th>Source</th>
          <th>Status</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Docs say submodules are scanned automatically and root repos are skipped by default</td>
          <td><a href="https://google.github.io/osv-scanner/usage/scan-source">OSV-Scanner: Project Source Scanning</a></td>
          <td>Verified</td>
      </tr>
      <tr>
          <td><code>vcs/gitrepo</code> disabled unless <code>--include-git-root</code>; vendored <code>ScanGitDir</code> tied to the flag</td>
          <td><a href="https://github.com/google/osv-scanner">google/osv-scanner</a> v2.7.1, <code>pkg/osvscanner/scan.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td>Flag help text and default <code>false</code></td>
          <td>v2.7.1, <code>cmd/osv-scanner/scan/source/command.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td>gitrepo fires on <code>.git</code> directories, queries HEAD and each submodule&rsquo;s <code>Expected</code> commit</td>
          <td>v2.7.1, <code>internal/scalibrextract/vcs/gitrepo/extractor.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td><code>Expected</code> comes from the index entry before the initialisation check</td>
          <td><a href="https://github.com/go-git/go-git">go-git</a> v5.19.3, <code>submodule.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td>Vendored folder names, file extensions, MD5 hashing, 0.15 threshold, 10,000-file cap</td>
          <td>v2.7.1, <code>internal/scalibrextract/filesystem/vendored/vendored.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td>Default plugin presets <code>lockfile</code>, <code>sbom</code>, <code>directory</code>; <code>directory</code> holds both extractors</td>
          <td>v2.7.1, <code>pkg/osvscanner/scan.go</code>, <code>internal/scalibrplugin/presets.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td>Output fields, <code>GIT</code> label and 8-character short commit</td>
          <td>v2.7.1, <code>pkg/models/results.go</code>, <code>internal/output/table.go</code>, <code>internal/utility/results/results.go</code></td>
          <td>Verified (source read)</td>
      </tr>
      <tr>
          <td>osv.dev accepts a commit hash in <code>/v1/query</code></td>
          <td><a href="https://google.github.io/osv.dev/post-v1-query/">osv.dev API: POST /v1/query</a></td>
          <td>Verified</td>
      </tr>
      <tr>
          <td>determineversion estimates vendored C/C++ versions with a confidence score</td>
          <td><a href="https://osv.dev/blog/posts/using-the-determineversion-api/">osv.dev blog: Using the determineversion API</a></td>
          <td>Verified</td>
      </tr>
  </tbody>
</table>
]]></content:encoded></item><item><title>OSV GIT Ranges: Commit Hashes, fixed vs limit Events</title><link>https://firewallsync.com/posts/osv-git-ranges-commit-hashes-fixed-vs-limit-events/</link><guid>https://firewallsync.com/posts/osv-git-ranges-commit-hashes-fixed-vs-limit-events/</guid><pubDate>Thu, 03 Dec 2026 04:40:00 +0000</pubDate><dc:creator>Craig Leslie</dc:creator><category>AppSec &amp; APIs</category><description>How OSV GIT ranges work: introduced and fixed are full commit hashes evaluated on the commit graph, cherry-picked fixes must each be listed, and limit trades false positives for false negatives. With counts from PyPA, OSS-Fuzz and GHSA data and a tested git-based evaluator.</description><enclosure url="https://firewallsync.com/posts/osv-git-ranges-commit-hashes-fixed-vs-limit-events/cover_hu10549478243202500838.jpg" type="image/jpeg" length="0"/><media:content url="https://firewallsync.com/posts/osv-git-ranges-commit-hashes-fixed-vs-limit-events/cover_hu10549478243202500838.jpg" medium="image" type="image/jpeg" width="1200" height="630"/><content:encoded><![CDATA[<p><img src="https://firewallsync.com/posts/osv-git-ranges-commit-hashes-fixed-vs-limit-events/cover_hu10549478243202500838.jpg" alt="Bare, dark tree branches forking in every direction against a pale grey sky" width="1200" height="630"></p><p><strong>Short answer:</strong> An OSV range of type <code>GIT</code> describes affected code by <strong>commit hash</strong>, not version number. <code>introduced</code> and <code>fixed</code> are full 40-character hashes in the repository named by <code>repo</code>, and &ldquo;greater than&rdquo; means &ldquo;descends from&rdquo; in the commit graph. A <code>fixed</code> commit clears only its own descendants, so a fix cherry-picked onto a release branch must be listed as a second <code>fixed</code> event or that branch stays flagged. A <code>limit</code> event does the opposite job: it shrinks the range to the ancestors of one commit, which drops other branches and can hide real exposure. In three large OSV datasets we checked, nobody uses <code>limit</code>.</p>
<p>This is the commit-graph companion to our <a href="/posts/osv-schema-ranges-introduced-fixed-last-affected-ghsa/">OSV schema ranges guide</a>, which covers <code>ECOSYSTEM</code> and <code>SEMVER</code> ranges and deliberately refuses <code>GIT</code>. If you work from CVE records rather than OSV, the equivalent is <code>versionType: git</code>, which we touched on in the <a href="/posts/cve-affected-versions-lessthan-defaultstatus-versiontype/">CVE affected versions guide</a> and the <a href="/posts/linux-kernel-cve-records-affected-versions-stable-branches/">Linux kernel CVE ranges article</a>.</p>
<h2 id="when-you-meet-a-git-range">When you meet a GIT range</h2>
<p>You need GIT ranges when there is no package version to compare: vendored C/C++ libraries, git submodules, code built from a commit, or fuzzing findings that predate any release. OSV.dev&rsquo;s own blog puts the problem plainly: &ldquo;C/C++ does not have a centralized package manager like npm or pyPI,&rdquo; and &ldquo;Software projects typically pull in C/C++ by submodules or vendoring.&rdquo;</p>
<p>The spec (OSV schema <strong>1.9.3</strong>, dated 30 November 2026) defines the type like this:</p>
<blockquote>
<p><code>GIT</code>: The versions <code>introduced</code> and <code>fixed</code> are full-length Git commit hashes. The repository&rsquo;s commit graph is needed to evaluate whether a given version is in the range. The relation <code>u &lt; v</code> is true when commit <code>u</code> is a (perhaps distant) parent of commit <code>v</code>.</p>
</blockquote>
<p>Two consequences follow:</p>
<ul>
<li><code>repo</code> is <strong>required</strong> for GIT ranges, and it must be usable as an argument to <code>git clone</code>.</li>
<li>You cannot evaluate a GIT range from the record alone. The spec says so directly: &ldquo;<code>GIT</code> range inclusion queries cannot be answered without access to a copy of the underlying Git repository.&rdquo; That is why it still asks for an enumerated <code>versions</code> list (tags) alongside GIT ranges.</li>
</ul>
<h2 id="the-four-events-read-as-graph-questions">The four events, read as graph questions</h2>
<table>
  <thead>
      <tr>
          <th>Event</th>
          <th>Value in a GIT range</th>
          <th>Question you ask the graph</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>introduced</code></td>
          <td>Commit hash, or <code>&quot;0&quot;</code></td>
          <td>Is this commit an ancestor of (or equal to) mine? <code>&quot;0&quot;</code> means &ldquo;from the start of history&rdquo;.</td>
      </tr>
      <tr>
          <td><code>fixed</code></td>
          <td>Commit hash</td>
          <td>Is this fix commit an ancestor of (or equal to) mine? If yes, I am fixed.</td>
      </tr>
      <tr>
          <td><code>last_affected</code></td>
          <td>Commit hash</td>
          <td>Allowed by the spec, but cannot share an <code>events</code> array with <code>fixed</code>. Rare in GIT data.</td>
      </tr>
      <tr>
          <td><code>limit</code></td>
          <td>Commit hash, or <code>&quot;*&quot;</code></td>
          <td>Is my commit a strict ancestor of a limit commit? If no limit exists, an implicit <code>&quot;*&quot;</code> (infinity) applies.</td>
      </tr>
  </tbody>
</table>
<p>The spec allows only one key per event object, and requires at least one <code>introduced</code>.</p>
<h2 id="fixed-versus-limit-a-tested-example">fixed versus limit: a tested example</h2>
<p>The spec explains the trade-off in one paragraph:</p>
<blockquote>
<p><code>events</code> arrays with <code>fixed</code> events must include all other cherrypicked fix commits in all branches as separate <code>fixed</code> events to avoid <em>false positive</em> matches in other branches. Conversely, <code>limit</code> events restrict the set of vulnerable commits to those reachable from the <code>limit</code>, which may result in <em>false negatives</em>. Where possible, it&rsquo;s strongly recommended to use <code>fixed</code> over <code>limit</code>.</p>
</blockquote>
<p>To see it, we built a toy repository: <code>main</code> runs <code>X - A - B - FIX - M</code>, and <code>release/1.x</code> branches at <code>A</code> with <code>R1</code>, <code>R2</code>, then <code>R3</code>, a <code>git cherry-pick -x</code> of <code>FIX</code>.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="color:#75715e">#!/bin/sh
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#75715e"># Toy repo: main X-A-B-FIX-M; release/1.x branched at A with R1, R2, then cherry-picked fix R3.</span>
</span></span><span style="display:flex;"><span>set -e
</span></span><span style="display:flex;"><span>rm -rf toy <span style="color:#f92672">&amp;&amp;</span> git init -q -b main toy <span style="color:#f92672">&amp;&amp;</span> cd toy
</span></span><span style="display:flex;"><span>git config user.email t@example.com <span style="color:#f92672">&amp;&amp;</span> git config user.name t
</span></span><span style="display:flex;"><span>c<span style="color:#f92672">(){</span> echo <span style="color:#e6db74">&#34;</span>$1<span style="color:#e6db74">&#34;</span> &gt;&gt; log <span style="color:#f92672">&amp;&amp;</span> git add log <span style="color:#f92672">&amp;&amp;</span> git commit -qm <span style="color:#e6db74">&#34;</span>$1<span style="color:#e6db74">&#34;</span> <span style="color:#f92672">&amp;&amp;</span> git tag <span style="color:#e6db74">&#34;</span>$1<span style="color:#e6db74">&#34;</span>; <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>c X; c A; git checkout -qb release/1.x; c R1; c R2; git checkout -q main; c B
</span></span><span style="display:flex;"><span>echo fix &gt; fix <span style="color:#f92672">&amp;&amp;</span> git add fix <span style="color:#f92672">&amp;&amp;</span> git commit -qm FIX <span style="color:#f92672">&amp;&amp;</span> git tag FIX; c M
</span></span><span style="display:flex;"><span>git checkout -q release/1.x <span style="color:#f92672">&amp;&amp;</span> git cherry-pick -x FIX &gt;/dev/null <span style="color:#f92672">&amp;&amp;</span> git tag R3
</span></span></code></pre></div><p>The evaluator below uses <code>git merge-base --is-ancestor</code> for every comparison. It is <strong>illustrative</strong>: it treats a commit as affected when it descends from any <code>introduced</code> commit and from no <code>fixed</code> commit, which is correct for single-introduced ranges like these but not for ranges that re-introduce a bug after a fix. It is not OSV.dev&rsquo;s implementation. For readability the demo range files use tag names; real records use full hashes, and the script resolves both.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#75715e">#!/usr/bin/env python3</span>
</span></span><span style="display:flex;"><span><span style="color:#e6db74">&#34;&#34;&#34;Evaluate an OSV GIT range against commits of a local clone. Illustrative.&#34;&#34;&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> subprocess<span style="color:#f92672">,</span> sys<span style="color:#f92672">,</span> json
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">is_anc</span>(repo, a, b):
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;&#34;&#34;True if commit a is an ancestor of (or equal to) commit b.&#34;&#34;&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> subprocess<span style="color:#f92672">.</span>run([<span style="color:#e6db74">&#34;git&#34;</span>, <span style="color:#e6db74">&#34;-C&#34;</span>, repo, <span style="color:#e6db74">&#34;merge-base&#34;</span>, <span style="color:#e6db74">&#34;--is-ancestor&#34;</span>, a, b])<span style="color:#f92672">.</span>returncode <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">resolve</span>(repo, ref):
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> subprocess<span style="color:#f92672">.</span>check_output([<span style="color:#e6db74">&#34;git&#34;</span>, <span style="color:#e6db74">&#34;-C&#34;</span>, repo, <span style="color:#e6db74">&#34;rev-parse&#34;</span>, ref], text<span style="color:#f92672">=</span><span style="color:#66d9ef">True</span>)<span style="color:#f92672">.</span>strip()
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">affected</span>(repo, rng, commit):
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># Resolve every event to a full hash (&#34;0&#34; and &#34;*&#34; are OSV special values).</span>
</span></span><span style="display:flex;"><span>    ev <span style="color:#f92672">=</span> [{k: (v <span style="color:#66d9ef">if</span> v <span style="color:#f92672">in</span> (<span style="color:#e6db74">&#34;0&#34;</span>, <span style="color:#e6db74">&#34;*&#34;</span>) <span style="color:#66d9ef">else</span> resolve(repo, v)) <span style="color:#66d9ef">for</span> k, v <span style="color:#f92672">in</span> e<span style="color:#f92672">.</span>items()} <span style="color:#66d9ef">for</span> e <span style="color:#f92672">in</span> rng[<span style="color:#e6db74">&#34;events&#34;</span>]]
</span></span><span style="display:flex;"><span>    limits <span style="color:#f92672">=</span> [e[<span style="color:#e6db74">&#34;limit&#34;</span>] <span style="color:#66d9ef">for</span> e <span style="color:#f92672">in</span> ev <span style="color:#66d9ef">if</span> <span style="color:#e6db74">&#34;limit&#34;</span> <span style="color:#f92672">in</span> e <span style="color:#f92672">and</span> e[<span style="color:#e6db74">&#34;limit&#34;</span>] <span style="color:#f92672">!=</span> <span style="color:#e6db74">&#34;*&#34;</span>]
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> limits <span style="color:#f92672">and</span> <span style="color:#f92672">not</span> any(is_anc(repo, commit, l) <span style="color:#f92672">and</span> commit <span style="color:#f92672">!=</span> l <span style="color:#66d9ef">for</span> l <span style="color:#f92672">in</span> limits):
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>    intro <span style="color:#f92672">=</span> [e[<span style="color:#e6db74">&#34;introduced&#34;</span>] <span style="color:#66d9ef">for</span> e <span style="color:#f92672">in</span> ev <span style="color:#66d9ef">if</span> <span style="color:#e6db74">&#34;introduced&#34;</span> <span style="color:#f92672">in</span> e]
</span></span><span style="display:flex;"><span>    fixed <span style="color:#f92672">=</span> [e[<span style="color:#e6db74">&#34;fixed&#34;</span>] <span style="color:#66d9ef">for</span> e <span style="color:#f92672">in</span> ev <span style="color:#66d9ef">if</span> <span style="color:#e6db74">&#34;fixed&#34;</span> <span style="color:#f92672">in</span> e]
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> <span style="color:#f92672">not</span> any(i <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;0&#34;</span> <span style="color:#f92672">or</span> is_anc(repo, i, commit) <span style="color:#66d9ef">for</span> i <span style="color:#f92672">in</span> intro):
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> <span style="color:#f92672">not</span> any(is_anc(repo, f, commit) <span style="color:#66d9ef">for</span> f <span style="color:#f92672">in</span> fixed)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> __name__ <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;__main__&#34;</span>:
</span></span><span style="display:flex;"><span>    repo, rng_file, <span style="color:#f92672">*</span>commits <span style="color:#f92672">=</span> sys<span style="color:#f92672">.</span>argv[<span style="color:#ae81ff">1</span>:]
</span></span><span style="display:flex;"><span>    rng <span style="color:#f92672">=</span> json<span style="color:#f92672">.</span>load(open(rng_file))
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> c <span style="color:#f92672">in</span> commits:
</span></span><span style="display:flex;"><span>        print(c, <span style="color:#e6db74">&#34;AFFECTED&#34;</span> <span style="color:#66d9ef">if</span> affected(repo, rng, resolve(repo, c)) <span style="color:#66d9ef">else</span> <span style="color:#e6db74">&#34;not affected&#34;</span>)
</span></span></code></pre></div><p>We ran it with Python 3.13 and git 2.43 against three ranges (<code>python3 osv_git_eval.py toy r1.json X A B FIX M R1 R2 R3</code>):</p>
<table>
  <thead>
      <tr>
          <th>Commit</th>
          <th>r1: <code>introduced X, fixed FIX</code></th>
          <th>r2: <code>+ fixed R3</code></th>
          <th>r3: <code>introduced X, limit FIX</code></th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>X, A, B</td>
          <td>affected</td>
          <td>affected</td>
          <td>affected</td>
      </tr>
      <tr>
          <td>FIX, M</td>
          <td>not affected</td>
          <td>not affected</td>
          <td>not affected</td>
      </tr>
      <tr>
          <td>R1, R2</td>
          <td>affected</td>
          <td>affected</td>
          <td><strong>not affected</strong></td>
      </tr>
      <tr>
          <td>R3 (has the cherry-picked fix)</td>
          <td><strong>affected</strong></td>
          <td>not affected</td>
          <td>not affected</td>
      </tr>
  </tbody>
</table>
<ul>
<li><strong>r1</strong> flags R3 even though it contains the fix: a false positive, because the cherry-pick has its own hash.</li>
<li><strong>r2</strong> adds the cherry-pick as a second <code>fixed</code> event and gets every commit right.</li>
<li><strong>r3</strong> returns X, A and B, matching the spec&rsquo;s description of <code>limit</code> as &ldquo;equivalent to <code>git rev-list X..Y</code> (but including <code>X</code> and excluding <code>Y</code>)&rdquo;. It also clears R1 and R2, which are still vulnerable: a false negative.</li>
</ul>
<p>If you consume GIT ranges, prefer a false positive you can suppress with a <a href="/posts/vex-explained-what-a-not-affected-statement-means-and-how-to-read-one/">VEX not_affected statement</a> over a false negative nobody sees.</p>
<h2 id="what-real-osv-data-uses">What real OSV data uses</h2>
<p>We counted GIT ranges in three public OSV sources (Python 3.13, PyYAML 6.0.3):</p>
<table>
  <thead>
      <tr>
          <th>Source (commit)</th>
          <th>Records</th>
          <th>Records with GIT ranges</th>
          <th>GIT ranges</th>
          <th>Ranges with &gt;1 <code>fixed</code></th>
          <th>Ranges with no <code>fixed</code></th>
          <th><code>limit</code> events</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="https://github.com/pypa/advisory-database">pypa/advisory-database</a> (<code>6c98d1c</code>, 2 Dec 2026)</td>
          <td>7,943</td>
          <td>1,551</td>
          <td>1,558</td>
          <td>174</td>
          <td>0</td>
          <td>0</td>
      </tr>
      <tr>
          <td><a href="https://github.com/google/oss-fuzz-vulns">google/oss-fuzz-vulns</a> (<code>f120110</code>, 2 Dec 2026)</td>
          <td>4,128</td>
          <td>4,108</td>
          <td>4,108</td>
          <td>581</td>
          <td>265</td>
          <td>0</td>
      </tr>
      <tr>
          <td><a href="https://github.com/github/advisory-database">github/advisory-database</a> reviewed (<code>85ddf6c</code>, 3 Dec 2026)</td>
          <td>38,222</td>
          <td>0</td>
          <td>0</td>
          <td>n/a</td>
          <td>n/a</td>
          <td>0</td>
      </tr>
  </tbody>
</table>
<p>What the counts show:</p>
<ul>
<li><strong>Nobody uses <code>limit</code>.</strong> Zero events across all three. Support it in a consumer, but expect to see it rarely.</li>
<li><strong>PyPA pairs GIT with ECOSYSTEM in the same entry.</strong> All 1,551 PyPA records with a GIT range also carry an <code>ECOSYSTEM</code> range, inside the same <code>affected</code> object as the PyPI package. 1,555 of the 1,558 ranges start at <code>introduced: &quot;0&quot;</code>. Example: PYSEC-2017-3 (ansible, CVE-2015-6240) has a GIT range with two <code>fixed</code> commits plus an ECOSYSTEM range and 45 enumerated versions. Spec 1.9.3 recommends a different layout, a separate <code>affected</code> entry with no <code>package</code> for Git details, so expect both shapes.</li>
<li><strong>OSS-Fuzz is GIT-first.</strong> 4,108 of 4,128 records use GIT ranges, almost all (4,097) under the <code>OSS-Fuzz</code> ecosystem. The 265 ranges without a <code>fixed</code> event are open-ended: per the spec&rsquo;s implicit <code>limit: &quot;*&quot;</code>, everything descending from <code>introduced</code> is affected. Only 1,645 of the source files enumerate <code>versions</code>; the spec notes OSV.dev can populate that list from tags during ingestion.</li>
<li><strong>GitHub-reviewed advisories never use GIT ranges</strong>, so a Dependabot-style pipeline built on GHSA data never needs this code path.</li>
</ul>
<h2 id="how-to-match-vendored-code">How to match vendored code</h2>
<ol>
<li><strong>Find the commit.</strong> For a submodule, <code>git submodule status</code> gives it. For a vendored copy with no history, OSV.dev&rsquo;s experimental <code>determineversion</code> API, described in its July 2023 blog post, estimates the likely upstream version of a local C/C++ library.</li>
<li><strong>Ask OSV.dev, or evaluate locally.</strong> <code>POST /v1/query</code> accepts <code>{&quot;commit&quot;: &quot;&lt;hash&gt;&quot;}</code>; the docs say that if <code>commit</code> is specified, <code>version</code> should not be set, and the package is optional. To evaluate locally, clone the <code>repo</code> and use ancestry checks as above.</li>
<li><strong>Check every <code>fixed</code> event, not just the first.</strong> One per branch is normal.</li>
<li><strong>Do not string-compare hashes.</strong> Hashes have no order. Only the graph does.</li>
<li><strong>Feed the result into the same triage as everything else.</strong> A GIT-matched record still needs a CVE alias before KEV or EPSS can help; see the <a href="/posts/vulnerability-prioritization-workflow-cve-record-to-patch-ticket/">vulnerability prioritization workflow</a>.</li>
</ol>
<h2 id="common-mistakes">Common mistakes</h2>
<ul>
<li><strong>Treating <code>fixed</code> as &ldquo;everything after this date&rdquo;.</strong> It clears only descendants of that commit. A branch cut before the fix stays affected unless its own cherry-pick is listed.</li>
<li><strong>Shallow clones.</strong> <code>git clone --depth 1</code> lacks the history needed for ancestry checks; <code>merge-base --is-ancestor</code> will fail or mislead. Fetch enough history to contain the <code>introduced</code> commit.</li>
<li><strong>Abbreviated hashes.</strong> The spec says full-length hashes. Resolve short ones before comparing, as the script does.</li>
<li><strong>Mixing tag versions with ecosystem versions.</strong> The spec warns that <code>versions</code> under a GIT range &ldquo;typically represent Git tags and cannot be relied upon to conform to any particular package manager&rsquo;s syntax&rdquo;.</li>
</ul>
<h2 id="limits-of-this-article">Limits of this article</h2>
<ul>
<li>The evaluator is a simplified illustration and mishandles ranges that re-introduce a bug after a fix. Use OSV.dev or a maintained scanner in production.</li>
<li>Data counts are from repository source files at the commits shown, not from OSV.dev&rsquo;s enriched exports, which may add <code>versions</code>. We could not download OSV.dev&rsquo;s bulk exports from our environment.</li>
<li>We did not test OSV-Scanner&rsquo;s GIT handling or the <code>determineversion</code> API.</li>
</ul>
<h2 id="sources-and-verification">Sources and verification</h2>
<table>
  <thead>
      <tr>
          <th>Important claim</th>
          <th>Source</th>
          <th>Status</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>GIT type definition, <code>u &lt; v</code> relation, <code>repo</code> required, <code>versions</code> still required, event rules, fixed vs limit trade-off, limit example semantics</td>
          <td><a href="https://github.com/ossf/osv-schema/blob/main/docs/schema.md">OSV schema 1.9.3, docs/schema.md</a></td>
          <td>Verified (quoted)</td>
      </tr>
      <tr>
          <td>Separate Git entries without <code>package</code> recommended</td>
          <td>Same, &ldquo;Separating Git and Strict Ecosystems&rdquo;</td>
          <td>Verified (quoted)</td>
      </tr>
      <tr>
          <td><code>commit</code> field in <code>POST /v1/query</code>; <code>version</code> must not be set; package optional</td>
          <td><a href="https://google.github.io/osv.dev/post-v1-query/">OSV.dev API: POST /v1/query</a></td>
          <td>Verified (quoted)</td>
      </tr>
      <tr>
          <td>C/C++ has no central package manager; <code>determineversion</code> is experimental</td>
          <td><a href="https://osv.dev/blog/posts/using-the-determineversion-api/">OSV.dev blog, 20 July 2023</a></td>
          <td>Verified (quoted)</td>
      </tr>
      <tr>
          <td>Toy repository results for r1, r2, r3</td>
          <td>Script run 3 December 2026, Python 3.13, git 2.43</td>
          <td>Verified (run)</td>
      </tr>
      <tr>
          <td>All counts in the data table</td>
          <td>Script run 3 December 2026 on the commits shown</td>
          <td>Verified (computed)</td>
      </tr>
  </tbody>
</table>
]]></content:encoded></item></channel></rss>