<?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>Csaf Vex | FirewallSync</title><link>https://firewallsync.com/tags/csaf-vex/</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>Thu, 05 Nov 2026 04:30:00 +0000</lastBuildDate><atom:link href="https://firewallsync.com/tags/csaf-vex/index.xml" rel="self" type="application/rss+xml"/><item><title>CSAF VEX product_tree: Resolve Product IDs to SBOM purls</title><link>https://firewallsync.com/posts/csaf-vex-product-tree-product-status-purl-sbom-matching/</link><guid>https://firewallsync.com/posts/csaf-vex-product-tree-product-status-purl-sbom-matching/</guid><pubDate>Thu, 05 Nov 2026 04:30:00 +0000</pubDate><dc:creator>John Marshall</dc:creator><category>Security Operations</category><description>A CSAF VEX file never puts a purl next to a status. Product IDs in product_status point into the product_tree, often through relationships. Here is how to walk branches and relationships, collapse the eight status lists into four VEX answers, and join the result to a CycloneDX SBOM, with a tested Python script.</description><enclosure url="https://firewallsync.com/posts/csaf-vex-product-tree-product-status-purl-sbom-matching/cover_hu13121586183071927737.jpg" type="image/jpeg" length="0"/><media:content url="https://firewallsync.com/posts/csaf-vex-product-tree-product-status-purl-sbom-matching/cover_hu13121586183071927737.jpg" medium="image" type="image/jpeg" width="1200" height="630"/><content:encoded><![CDATA[<p><img src="https://firewallsync.com/posts/csaf-vex-product-tree-product-status-purl-sbom-matching/cover_hu13121586183071927737.jpg" alt="Thin bare tree branches crossing in a dense tangle against a flat grey-blue sky" width="1200" height="630"></p><p><strong>Scope.</strong> This is a field-level guide for engineers who consume vendor CSAF VEX files and need to apply them to their own SBOMs. We read the CSAF 2.0 prose and JSON schema in the OASIS CSAF TC&rsquo;s GitHub repository, Red Hat&rsquo;s July 2024 announcement of its CSAF VEX files, and Trivy&rsquo;s CSAF matcher and documentation at tag v0.76.1. The example document and the Python script below are ours; we validated the document against the CSAF 2.0 JSON schema and ran the script with Python 3.13. The script is illustrative, not a production matcher.</p>
<h2 id="the-short-answer">The short answer</h2>
<p>A CSAF VEX file never puts a purl next to a status. It says &ldquo;product ID <code>GW-4.2.1:LIB-1.8.0</code> is <code>known_not_affected</code>&rdquo;, and you have to work out what that ID is:</p>
<ol>
<li>Find the ID in the <code>product_tree</code>: at the end of a <code>branches</code> path, in <code>full_product_names</code>, or as the <code>full_product_name</code> of a <code>relationships</code> entry.</li>
<li>If it is a relationship, resolve both sides: <code>product_reference</code> (the component) and <code>relates_to_product_reference</code> (the product it sits in).</li>
<li>Read <code>product_identification_helper.purl</code> (or <code>cpe</code>) for each side.</li>
<li>Apply the status only when your SBOM contains the component <strong>and</strong> the parent matches the product you are assessing.</li>
<li>Collapse the eight <code>product_status</code> lists to the four VEX answers before you write anything to a ticket.</li>
</ol>
<p>The rest of this article goes through each step, shows a schema-valid example, and gives a script that does the join.</p>
<h2 id="what-the-vex-profile-requires">What the VEX profile requires</h2>
<p>CSAF 2.0 has been an OASIS Standard since 18 November 2022. The VEX profile is section 4.5. A document satisfies it when <code>/document/category</code> is <code>csaf_vex</code> and it contains:</p>
<ul>
<li>a <code>product_tree</code> &ldquo;which lists all products referenced later on in the CSAF document regardless of their state&rdquo;;</li>
<li><code>vulnerabilities</code>, each with <code>notes</code> and at least one of <code>cve</code> or <code>ids</code>;</li>
<li>at least one of the <code>fixed</code>, <code>known_affected</code>, <code>known_not_affected</code> or <code>under_investigation</code> lists.</li>
</ul>
<p>Two conditions are per product, and they are the ones consumers should check:</p>
<ul>
<li>Every product in <code>known_not_affected</code> needs an impact statement, either &ldquo;as machine readable flag in <code>/vulnerabilities[]/flags</code> or as human readable justification in <code>/vulnerabilities[]/threats</code>&rdquo; with <code>category</code> set to <code>impact</code>.</li>
<li>Every product in <code>known_affected</code> needs &ldquo;additional product specific information&rdquo; in <code>remediations</code> &ldquo;as an action statement&rdquo;. The categories <code>no_fix_planned</code> and <code>none_available</code> count.</li>
</ul>
<p>The five flag labels are the CISA justification codes: <code>component_not_present</code>, <code>vulnerable_code_not_present</code>, <code>vulnerable_code_cannot_be_controlled_by_adversary</code>, <code>vulnerable_code_not_in_execute_path</code> and <code>inline_mitigations_already_exist</code>. If you need the meaning of each one, the <a href="/posts/vex-explained-what-a-not-affected-statement-means-and-how-to-read-one/">VEX explainer</a> covers them. The <a href="/posts/cyclonedx-vex-analysis-state-justification-openvex-csaf-mapping/">CycloneDX VEX mapping guide</a> covers converting between CSAF and other VEX formats. This article is about something they do not cover: finding the products a CSAF statement actually refers to.</p>
<h2 id="step-1-walk-the-product-tree">Step 1: walk the product tree</h2>
<p>The <code>product_tree</code> can name products in three places. A consumer has to read all three.</p>
<table>
  <thead>
      <tr>
          <th>Where</th>
          <th>What it holds</th>
          <th>Product ID comes from</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>branches</code> (nested)</td>
          <td>A hierarchy such as <code>vendor</code> → <code>product_name</code> → <code>product_version</code>. A leaf branch has a <code>product</code> object.</td>
          <td><code>branches[]...product.product_id</code></td>
      </tr>
      <tr>
          <td><code>full_product_names</code></td>
          <td>Flat list of products with no hierarchy</td>
          <td><code>full_product_names[].product_id</code></td>
      </tr>
      <tr>
          <td><code>relationships</code></td>
          <td>A new product made of two existing ones, such as a library inside an image</td>
          <td><code>relationships[].full_product_name.product_id</code></td>
      </tr>
  </tbody>
</table>
<p>Every one of these is a &ldquo;full product name&rdquo;: <code>name</code> and <code>product_id</code> are required, and <code>product_identification_helper</code> is optional. That helper is where <code>purl</code>, <code>cpe</code>, hashes and SBOM URLs go. The CSAF schema only checks the purl against a loose pattern (<code>^pkg:[A-Za-z\.\-\+][A-Za-z0-9\.\-\+]*/.+</code>) and says it &ldquo;does not completely evaluate whether a PURL is valid&rdquo;, so validate purls yourself before matching on them.</p>
<p>There is also <code>product_groups</code>, which bundles product IDs under a group ID. Product status lists only hold product IDs, but <code>flags</code>, <code>threats</code> and <code>remediations</code> can reference groups through <code>group_ids</code>, so expand groups when you collect impact and action statements.</p>
<p>The spec recommends the <code>vendor</code> → <code>product_name</code> → <code>product_version</code> shape &ldquo;whenever possible to support the identification and matching of products on the consumer side&rdquo;. It also allows <code>product_version_range</code> branches, but recommends enumerating versions instead. If you meet a range branch, you need a version-range parser for whatever scheme it uses; the purl join below will not help.</p>
<h2 id="step-2-treat-relationships-as-component-in-product">Step 2: treat relationships as &ldquo;component in product&rdquo;</h2>
<p>A relationship has four required fields: <code>category</code>, <code>product_reference</code>, <code>relates_to_product_reference</code> and <code>full_product_name</code>. The categories are <code>default_component_of</code>, <code>external_component_of</code>, <code>installed_on</code>, <code>installed_with</code> and <code>optional_component_of</code>. The spec gives the reason relationships exist: a product may be &ldquo;vulnerable only when installed together with another&rdquo;, or you may need &ldquo;to describe operating system components&rdquo;.</p>
<p>This is the part consumers get wrong. In our example below, <code>LIB-1.8.0</code> is the library on its own and <code>GW-4.2.1:LIB-1.8.0</code> is &ldquo;libexample 1.8.0 as shipped in Example Gateway 4.2.1&rdquo;. A vendor that marks the second ID <code>known_not_affected</code> is saying the gateway does not reach the vulnerable code. It is not saying libexample 1.8.0 is safe everywhere. If your matcher resolves the relationship ID to the component purl alone, you will suppress the CVE for every other image that ships libexample 1.8.0. That is the false negative VEX is supposed to prevent.</p>
<p>The rule we use: for a relationship ID, apply the status only when the component purl matches a component in the SBOM <strong>and</strong> the parent purl matches the SBOM&rsquo;s subject (for CycloneDX, <code>metadata.component</code>).</p>
<p>Red Hat&rsquo;s VEX files are a real case of this structure. Red Hat publishes one CSAF VEX file per CVE. Its July 2024 announcement says each file has a <code>product_tree</code> object listing &ldquo;products, their components, and the relationships between them&rdquo;. In the general-availability release Red Hat &ldquo;extended the scope of the <code>purl</code> identifiers to unfixed components as well&rdquo; for rpm, oci and rpmmod components. In the October 2023 beta, only fixed components carried a purl. Check which one you are parsing.</p>
<h2 id="step-3-collapse-eight-status-lists-into-four-answers">Step 3: collapse eight status lists into four answers</h2>
<p>CSAF defines eight <code>product_status</code> lists. VEX consumers need four answers. The spec&rsquo;s own test for contradicting statuses (section 6.1.6) gives the grouping, and the sets &ldquo;MUST be pairwise disjoint&rdquo; within one vulnerability:</p>
<table>
  <thead>
      <tr>
          <th>VEX answer</th>
          <th>CSAF <code>product_status</code> lists</th>
          <th>What to do</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Affected</td>
          <td><code>first_affected</code>, <code>known_affected</code>, <code>last_affected</code></td>
          <td>Open or keep the ticket. Read <code>remediations</code> for the action statement.</td>
      </tr>
      <tr>
          <td>Not affected</td>
          <td><code>known_not_affected</code></td>
          <td>Suppress for that product only, and keep the flag or impact text as evidence.</td>
      </tr>
      <tr>
          <td>Fixed</td>
          <td><code>first_fixed</code>, <code>fixed</code></td>
          <td>Close if you run that version. The spec says these versions &ldquo;may not be the recommended fixed versions&rdquo;.</td>
      </tr>
      <tr>
          <td>Under investigation</td>
          <td><code>under_investigation</code></td>
          <td>Keep the scanner finding and re-pull the document later.</td>
      </tr>
      <tr>
          <td>(none)</td>
          <td><code>recommended</code></td>
          <td>Not part of any contradiction group. The spec notes an issuer might recommend a version &ldquo;from any group - also from the affected group&rdquo;. Use it to choose an upgrade target, not to decide status.</td>
      </tr>
  </tbody>
</table>
<p>If you find one product ID in two groups for the same CVE, the document fails the CSAF mandatory test. Reject the statement for that product rather than picking one.</p>
<p>For affected products, the remediation categories tell you what kind of action is available: <code>vendor_fix</code>, <code>workaround</code>, <code>mitigation</code>, <code>none_available</code> or <code>no_fix_planned</code>. <code>vendor_fix</code> cannot be combined with <code>none_available</code> or <code>no_fix_planned</code> for the same product.</p>
<h2 id="a-schema-valid-example">A schema-valid example</h2>
<p>This document is ours, written for this article. It has one product version where a library is not reachable and a later version where it was updated. It passes validation against the CSAF 2.0 JSON schema from the OASIS repository (Python <code>jsonschema</code>, Draft 2020-12, format checks on; 0 errors). Schema validation does not run CSAF&rsquo;s mandatory tests, so it does not prove the profile rules are met. We checked those by hand.</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-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;document&#34;</span>: {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;csaf_vex&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;csaf_version&#34;</span>: <span style="color:#e6db74">&#34;2.0&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;publisher&#34;</span>: {<span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;vendor&#34;</span>, <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;Example Vendor&#34;</span>, <span style="color:#f92672">&#34;namespace&#34;</span>: <span style="color:#e6db74">&#34;https://vendor.example&#34;</span>},
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title&#34;</span>: <span style="color:#e6db74">&#34;Example Gateway: CVE-2099-0001 in libexample&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;tracking&#34;</span>: {<span style="color:#f92672">&#34;id&#34;</span>: <span style="color:#e6db74">&#34;EXV-2099-0001&#34;</span>, <span style="color:#f92672">&#34;status&#34;</span>: <span style="color:#e6db74">&#34;final&#34;</span>, <span style="color:#f92672">&#34;version&#34;</span>: <span style="color:#e6db74">&#34;2&#34;</span>, <span style="color:#f92672">&#34;...&#34;</span>: <span style="color:#e6db74">&#34;...&#34;</span>}
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;product_tree&#34;</span>: {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;branches&#34;</span>: [{<span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;vendor&#34;</span>, <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;Example Vendor&#34;</span>, <span style="color:#f92672">&#34;branches&#34;</span>: [
</span></span><span style="display:flex;"><span>      {<span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;product_name&#34;</span>, <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;Example Gateway&#34;</span>, <span style="color:#f92672">&#34;branches&#34;</span>: [
</span></span><span style="display:flex;"><span>        {<span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;product_version&#34;</span>, <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;4.2.1&#34;</span>,
</span></span><span style="display:flex;"><span>         <span style="color:#f92672">&#34;product&#34;</span>: {<span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;Example Gateway 4.2.1&#34;</span>, <span style="color:#f92672">&#34;product_id&#34;</span>: <span style="color:#e6db74">&#34;GW-4.2.1&#34;</span>,
</span></span><span style="display:flex;"><span>           <span style="color:#f92672">&#34;product_identification_helper&#34;</span>: {<span style="color:#f92672">&#34;purl&#34;</span>: <span style="color:#e6db74">&#34;pkg:oci/example-gateway@sha256%3A1111?tag=4.2.1&#34;</span>}}}
</span></span><span style="display:flex;"><span>      ]},
</span></span><span style="display:flex;"><span>      {<span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;product_name&#34;</span>, <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;libexample&#34;</span>, <span style="color:#f92672">&#34;branches&#34;</span>: [
</span></span><span style="display:flex;"><span>        {<span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;product_version&#34;</span>, <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;1.8.0&#34;</span>,
</span></span><span style="display:flex;"><span>         <span style="color:#f92672">&#34;product&#34;</span>: {<span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;libexample 1.8.0&#34;</span>, <span style="color:#f92672">&#34;product_id&#34;</span>: <span style="color:#e6db74">&#34;LIB-1.8.0&#34;</span>,
</span></span><span style="display:flex;"><span>           <span style="color:#f92672">&#34;product_identification_helper&#34;</span>: {<span style="color:#f92672">&#34;purl&#34;</span>: <span style="color:#e6db74">&#34;pkg:deb/debian/libexample@1.8.0-1&#34;</span>}}}
</span></span><span style="display:flex;"><span>      ]}
</span></span><span style="display:flex;"><span>    ]}],
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;relationships&#34;</span>: [
</span></span><span style="display:flex;"><span>      {<span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;default_component_of&#34;</span>,
</span></span><span style="display:flex;"><span>       <span style="color:#f92672">&#34;product_reference&#34;</span>: <span style="color:#e6db74">&#34;LIB-1.8.0&#34;</span>,
</span></span><span style="display:flex;"><span>       <span style="color:#f92672">&#34;relates_to_product_reference&#34;</span>: <span style="color:#e6db74">&#34;GW-4.2.1&#34;</span>,
</span></span><span style="display:flex;"><span>       <span style="color:#f92672">&#34;full_product_name&#34;</span>: {<span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;libexample 1.8.0 in Example Gateway 4.2.1&#34;</span>,
</span></span><span style="display:flex;"><span>                             <span style="color:#f92672">&#34;product_id&#34;</span>: <span style="color:#e6db74">&#34;GW-4.2.1:LIB-1.8.0&#34;</span>}}
</span></span><span style="display:flex;"><span>    ]
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;vulnerabilities&#34;</span>: [{
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;cve&#34;</span>: <span style="color:#e6db74">&#34;CVE-2099-0001&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;notes&#34;</span>: [{<span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;description&#34;</span>, <span style="color:#f92672">&#34;text&#34;</span>: <span style="color:#e6db74">&#34;Illustrative vulnerability in libexample&#39;s XML parser.&#34;</span>}],
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;product_status&#34;</span>: {<span style="color:#f92672">&#34;known_not_affected&#34;</span>: [<span style="color:#e6db74">&#34;GW-4.2.1:LIB-1.8.0&#34;</span>], <span style="color:#f92672">&#34;fixed&#34;</span>: [<span style="color:#e6db74">&#34;GW-4.3.0:LIB-1.8.2&#34;</span>]},
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;flags&#34;</span>: [{<span style="color:#f92672">&#34;label&#34;</span>: <span style="color:#e6db74">&#34;vulnerable_code_not_in_execute_path&#34;</span>, <span style="color:#f92672">&#34;product_ids&#34;</span>: [<span style="color:#e6db74">&#34;GW-4.2.1:LIB-1.8.0&#34;</span>]}],
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;threats&#34;</span>: [{<span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;impact&#34;</span>, <span style="color:#f92672">&#34;details&#34;</span>: <span style="color:#e6db74">&#34;Example Gateway never calls the XML parser in libexample.&#34;</span>,
</span></span><span style="display:flex;"><span>                 <span style="color:#f92672">&#34;product_ids&#34;</span>: [<span style="color:#e6db74">&#34;GW-4.2.1:LIB-1.8.0&#34;</span>]}]
</span></span><span style="display:flex;"><span>  }]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>The excerpt trims the tracking block and the 4.3.0 / 1.8.2 branches and relationship, which follow the same pattern. The CVE ID is a placeholder.</p>
<h2 id="step-4-join-to-the-sbom">Step 4: join to the SBOM</h2>
<p>The script resolves every product ID in <code>product_status</code> to purls, follows relationships, and checks both sides against a CycloneDX SBOM. For purl comparison it uses the matching rules Trivy documents, which Trivy itself notes &ldquo;are not formally defined within the current official PURL specification&rdquo;: a VEX purl without a version matches every version; every qualifier in the VEX purl must be present in the SBOM purl; extra SBOM qualifiers are ignored.</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;Resolve CSAF VEX product_status entries to purls and join them to a CycloneDX SBOM.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">Illustrative: purl matching follows the rules in purl_match(); no version-range logic.&#34;&#34;&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> json<span style="color:#f92672">,</span> sys
</span></span><span style="display:flex;"><span><span style="color:#f92672">from</span> urllib.parse <span style="color:#f92672">import</span> unquote
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">parse</span>(p):
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;&#34;&#34;Split a purl into (type/namespace/name, version or None, qualifiers dict). Subpath ignored.&#34;&#34;&#34;</span>
</span></span><span style="display:flex;"><span>    p <span style="color:#f92672">=</span> p<span style="color:#f92672">.</span>split(<span style="color:#e6db74">&#34;#&#34;</span>)[<span style="color:#ae81ff">0</span>]
</span></span><span style="display:flex;"><span>    core, _, q <span style="color:#f92672">=</span> p<span style="color:#f92672">.</span>partition(<span style="color:#e6db74">&#34;?&#34;</span>)
</span></span><span style="display:flex;"><span>    quals <span style="color:#f92672">=</span> dict(kv<span style="color:#f92672">.</span>split(<span style="color:#e6db74">&#34;=&#34;</span>, <span style="color:#ae81ff">1</span>) <span style="color:#66d9ef">for</span> kv <span style="color:#f92672">in</span> q<span style="color:#f92672">.</span>split(<span style="color:#e6db74">&#34;&amp;&#34;</span>) <span style="color:#66d9ef">if</span> <span style="color:#e6db74">&#34;=&#34;</span> <span style="color:#f92672">in</span> kv)
</span></span><span style="display:flex;"><span>    path, _, ver <span style="color:#f92672">=</span> core<span style="color:#f92672">.</span>rpartition(<span style="color:#e6db74">&#34;@&#34;</span>) <span style="color:#66d9ef">if</span> <span style="color:#e6db74">&#34;@&#34;</span> <span style="color:#f92672">in</span> core<span style="color:#f92672">.</span>rsplit(<span style="color:#e6db74">&#34;/&#34;</span>, <span style="color:#ae81ff">1</span>)[<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>] <span style="color:#66d9ef">else</span> (core, <span style="color:#e6db74">&#34;&#34;</span>, <span style="color:#e6db74">&#34;&#34;</span>)
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> unquote(path)<span style="color:#f92672">.</span>lower(), unquote(ver) <span style="color:#f92672">or</span> <span style="color:#66d9ef">None</span>, {k<span style="color:#f92672">.</span>lower(): unquote(v) <span style="color:#66d9ef">for</span> k, v <span style="color:#f92672">in</span> quals<span style="color:#f92672">.</span>items()}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">purl_match</span>(vex_purl, sbom_purl):
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;&#34;&#34;Community matching rules (as documented by Trivy): a VEX purl without a version matches
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    every version; VEX qualifiers must all be present in the SBOM purl; extra SBOM qualifiers are ignored.&#34;&#34;&#34;</span>
</span></span><span style="display:flex;"><span>    vp, vv, vq <span style="color:#f92672">=</span> parse(vex_purl)
</span></span><span style="display:flex;"><span>    sp, sv, sq <span style="color:#f92672">=</span> parse(sbom_purl)
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> vp <span style="color:#f92672">==</span> sp <span style="color:#f92672">and</span> (vv <span style="color:#f92672">is</span> <span style="color:#66d9ef">None</span> <span style="color:#f92672">or</span> vv <span style="color:#f92672">==</span> sv) <span style="color:#f92672">and</span> all(sq<span style="color:#f92672">.</span>get(k) <span style="color:#f92672">==</span> v <span style="color:#66d9ef">for</span> k, v <span style="color:#f92672">in</span> vq<span style="color:#f92672">.</span>items())
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">walk_branches</span>(branches, out):
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> b <span style="color:#f92672">in</span> branches <span style="color:#f92672">or</span> []:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">if</span> <span style="color:#e6db74">&#34;product&#34;</span> <span style="color:#f92672">in</span> b:
</span></span><span style="display:flex;"><span>            fpn <span style="color:#f92672">=</span> b[<span style="color:#e6db74">&#34;product&#34;</span>]
</span></span><span style="display:flex;"><span>            out[fpn[<span style="color:#e6db74">&#34;product_id&#34;</span>]] <span style="color:#f92672">=</span> fpn<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;product_identification_helper&#34;</span>, {})<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;purl&#34;</span>)
</span></span><span style="display:flex;"><span>        walk_branches(b<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;branches&#34;</span>), out)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">load_products</span>(doc):
</span></span><span style="display:flex;"><span>    tree <span style="color:#f92672">=</span> doc[<span style="color:#e6db74">&#34;product_tree&#34;</span>]
</span></span><span style="display:flex;"><span>    purls <span style="color:#f92672">=</span> {}
</span></span><span style="display:flex;"><span>    walk_branches(tree<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;branches&#34;</span>), purls)
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> fpn <span style="color:#f92672">in</span> tree<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;full_product_names&#34;</span>, []):
</span></span><span style="display:flex;"><span>        purls[fpn[<span style="color:#e6db74">&#34;product_id&#34;</span>]] <span style="color:#f92672">=</span> fpn<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;product_identification_helper&#34;</span>, {})<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;purl&#34;</span>)
</span></span><span style="display:flex;"><span>    rels <span style="color:#f92672">=</span> {}
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> tree<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;relationships&#34;</span>, []):
</span></span><span style="display:flex;"><span>        rels[r[<span style="color:#e6db74">&#34;full_product_name&#34;</span>][<span style="color:#e6db74">&#34;product_id&#34;</span>]] <span style="color:#f92672">=</span> (
</span></span><span style="display:flex;"><span>            r[<span style="color:#e6db74">&#34;category&#34;</span>], r[<span style="color:#e6db74">&#34;product_reference&#34;</span>], r[<span style="color:#e6db74">&#34;relates_to_product_reference&#34;</span>])
</span></span><span style="display:flex;"><span>    groups <span style="color:#f92672">=</span> {g[<span style="color:#e6db74">&#34;group_id&#34;</span>]: g[<span style="color:#e6db74">&#34;product_ids&#34;</span>] <span style="color:#66d9ef">for</span> g <span style="color:#f92672">in</span> tree<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;product_groups&#34;</span>, [])}
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> purls, rels, groups
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">main</span>(vex_path, sbom_path):
</span></span><span style="display:flex;"><span>    doc <span style="color:#f92672">=</span> json<span style="color:#f92672">.</span>load(open(vex_path))
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">assert</span> doc[<span style="color:#e6db74">&#34;document&#34;</span>][<span style="color:#e6db74">&#34;category&#34;</span>] <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;csaf_vex&#34;</span>, <span style="color:#e6db74">&#34;not a VEX profile document&#34;</span>
</span></span><span style="display:flex;"><span>    purls, rels, groups <span style="color:#f92672">=</span> load_products(doc)
</span></span><span style="display:flex;"><span>    sbom <span style="color:#f92672">=</span> json<span style="color:#f92672">.</span>load(open(sbom_path))
</span></span><span style="display:flex;"><span>    parent <span style="color:#f92672">=</span> sbom[<span style="color:#e6db74">&#34;metadata&#34;</span>][<span style="color:#e6db74">&#34;component&#34;</span>][<span style="color:#e6db74">&#34;purl&#34;</span>]
</span></span><span style="display:flex;"><span>    inventory <span style="color:#f92672">=</span> [c[<span style="color:#e6db74">&#34;purl&#34;</span>] <span style="color:#66d9ef">for</span> c <span style="color:#f92672">in</span> sbom<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;components&#34;</span>, []) <span style="color:#66d9ef">if</span> c<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;purl&#34;</span>)]
</span></span><span style="display:flex;"><span>    in_sbom <span style="color:#f92672">=</span> <span style="color:#66d9ef">lambda</span> vex_purl: any(purl_match(vex_purl, s) <span style="color:#66d9ef">for</span> s <span style="color:#f92672">in</span> inventory)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> v <span style="color:#f92672">in</span> doc[<span style="color:#e6db74">&#34;vulnerabilities&#34;</span>]:
</span></span><span style="display:flex;"><span>        flags <span style="color:#f92672">=</span> {pid: f[<span style="color:#e6db74">&#34;label&#34;</span>] <span style="color:#66d9ef">for</span> f <span style="color:#f92672">in</span> v<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;flags&#34;</span>, [])
</span></span><span style="display:flex;"><span>                 <span style="color:#66d9ef">for</span> pid <span style="color:#f92672">in</span> f<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;product_ids&#34;</span>, []) <span style="color:#f92672">+</span> sum((groups[g] <span style="color:#66d9ef">for</span> g <span style="color:#f92672">in</span> f<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;group_ids&#34;</span>, [])), [])}
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> status, pids <span style="color:#f92672">in</span> v<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;product_status&#34;</span>, {})<span style="color:#f92672">.</span>items():
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">for</span> pid <span style="color:#f92672">in</span> pids:
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> pid <span style="color:#f92672">in</span> rels:                      <span style="color:#75715e"># component-in-product: match BOTH sides</span>
</span></span><span style="display:flex;"><span>                    cat, comp, prod <span style="color:#f92672">=</span> rels[pid]
</span></span><span style="display:flex;"><span>                    comp_p, prod_p <span style="color:#f92672">=</span> purls<span style="color:#f92672">.</span>get(comp), purls<span style="color:#f92672">.</span>get(prod)
</span></span><span style="display:flex;"><span>                    hit <span style="color:#f92672">=</span> bool(comp_p <span style="color:#f92672">and</span> prod_p <span style="color:#f92672">and</span> purl_match(prod_p, parent) <span style="color:#f92672">and</span> in_sbom(comp_p))
</span></span><span style="display:flex;"><span>                    target <span style="color:#f92672">=</span> <span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;</span><span style="color:#e6db74">{</span>comp_p<span style="color:#e6db74">}</span><span style="color:#e6db74"> </span><span style="color:#e6db74">{</span>cat<span style="color:#e6db74">}</span><span style="color:#e6db74"> </span><span style="color:#e6db74">{</span>prod_p<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">else</span>:                                <span style="color:#75715e"># standalone product</span>
</span></span><span style="display:flex;"><span>                    p <span style="color:#f92672">=</span> purls<span style="color:#f92672">.</span>get(pid)
</span></span><span style="display:flex;"><span>                    hit <span style="color:#f92672">=</span> bool(p <span style="color:#f92672">and</span> (in_sbom(p) <span style="color:#f92672">or</span> purl_match(p, parent)))
</span></span><span style="display:flex;"><span>                    target <span style="color:#f92672">=</span> p
</span></span><span style="display:flex;"><span>                print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;</span><span style="color:#e6db74">{</span>v<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#39;cve&#39;</span>)<span style="color:#e6db74">}</span><span style="color:#ae81ff">\t</span><span style="color:#e6db74">{</span>status<span style="color:#e6db74">}</span><span style="color:#ae81ff">\t</span><span style="color:#e6db74">{</span>flags<span style="color:#f92672">.</span>get(pid, <span style="color:#e6db74">&#39;-&#39;</span>)<span style="color:#e6db74">}</span><span style="color:#ae81ff">\t</span><span style="color:#e6db74">{</span><span style="color:#e6db74">&#39;MATCH&#39;</span> <span style="color:#66d9ef">if</span> hit <span style="color:#66d9ef">else</span> <span style="color:#e6db74">&#39;no match&#39;</span><span style="color:#e6db74">}</span><span style="color:#ae81ff">\t</span><span style="color:#e6db74">{</span>target<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</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>    main(<span style="color:#f92672">*</span>sys<span style="color:#f92672">.</span>argv[<span style="color:#ae81ff">1</span>:<span style="color:#ae81ff">3</span>])
</span></span></code></pre></div><h3 id="test-run">Test run</h3>
<p>We ran it (<code>python3 -I csaf_vex_join.py vex.json sbom.cdx.json</code>) against the full example document and three small CycloneDX 1.6 SBOMs.</p>
<p><strong>SBOM 1</strong>, image 4.2.1 (<code>metadata.component.purl</code> = <code>pkg:oci/example-gateway@sha256%3A1111?tag=4.2.1</code>), containing <code>pkg:deb/debian/libexample@1.8.0-1?arch=amd64&amp;distro=debian-12</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-text" data-lang="text"><span style="display:flex;"><span>CVE-2099-0001  known_not_affected  vulnerable_code_not_in_execute_path  MATCH     pkg:deb/debian/libexample@1.8.0-1 default_component_of pkg:oci/example-gateway@sha256%3A1111?tag=4.2.1
</span></span><span style="display:flex;"><span>CVE-2099-0001  fixed               -                                    no match  pkg:deb/debian/libexample@1.8.2-1 default_component_of pkg:oci/example-gateway@sha256%3A2222?tag=4.3.0
</span></span></code></pre></div><p>The SBOM&rsquo;s extra <code>arch</code> and <code>distro</code> qualifiers did not block the match, because the VEX purl has none.</p>
<p><strong>SBOM 2</strong>, image 4.3.0 with libexample 1.8.2: the results flip. The <code>fixed</code> statement matches and the <code>known_not_affected</code> one does not.</p>
<p><strong>SBOM 3</strong>, the 4.2.1 SBOM again, but with the VEX component purl changed to <code>...libexample@1.8.0-1?arch=arm64</code>: <code>no match</code>, because the VEX purl now requires a qualifier value the SBOM lacks.</p>
<p>What the script does not do: version ranges (<code>product_version_range</code>), CPE-only products, hashes, <code>product_groups</code> in status lists (the schema does not allow them there), or the mandatory-test checks. It also prints matches and nothing else; it does not decide what to do with a CVE your scanner found but the VEX file does not mention.</p>
<h2 id="how-trivy-applies-csaf-vex">How Trivy applies CSAF VEX</h2>
<p>Trivy is a common place engineers first meet CSAF VEX. At tag v0.76.1, its documentation says CSAF works for container images, filesystems, code repositories, VM images, Kubernetes and SBOM targets, passed with <code>--vex</code>. Its matcher (<code>pkg/vex/csaf.go</code>) shows three things worth knowing:</p>
<ul>
<li><strong>Only two statuses act.</strong> The status map holds <code>known_not_affected</code> and <code>fixed</code>. A match on either filters the finding. <code>known_affected</code> and <code>under_investigation</code> statements never change the result.</li>
<li><strong>Matching is by purl.</strong> If the detected package has no purl, or the vulnerability has no <code>product_status</code>, nothing is filtered.</li>
<li><strong>Relationship categories are not distinguished.</strong> The documentation says &ldquo;the specified relationship category is not taken into account&rdquo; and that <code>default_component_of</code>, <code>installed_on</code> and <code>installed_with</code> &ldquo;are treated internally as <code>depends_on</code>&rdquo;. For a relationship, the code requires the parent purl to match a product higher in the dependency tree (such as the scanned image) and the component purl to match the sub-component, which is the both-sides rule from Step 2. <code>external_component_of</code> and <code>optional_component_of</code> relationships are skipped. A status on a plain product ID, with no relationship, is matched against the package&rsquo;s own purl, so it applies wherever that package appears.</li>
</ul>
<p>So if a vendor&rsquo;s CSAF file uses <code>optional_component_of</code> for a component, Trivy will not apply that status through the relationship. That is safe in direction (no false suppression), but it can surprise you if you expect the finding to drop.</p>
<h2 id="common-mistakes">Common mistakes</h2>
<ul>
<li><strong>Matching the component alone.</strong> Covered above. It turns a statement about one product into a statement about all of them.</li>
<li><strong>Trusting <code>known_not_affected</code> with no impact statement.</strong> The profile requires a flag or an impact threat for each such product. If neither exists, the document does not satisfy the profile; send it back to the vendor rather than suppressing.</li>
<li><strong>Reading only <code>branches</code>.</strong> Products in <code>full_product_names</code> and relationships carry IDs too. A parser that only walks branches will report &ldquo;unknown product&rdquo; for most relationship-heavy files.</li>
<li><strong>Treating <code>recommended</code> as fixed.</strong> The spec allows recommending a version from the affected group.</li>
<li><strong>Ignoring <code>tracking.version</code> and <code>current_release_date</code>.</strong> VEX files are revised as investigations finish. Store the version you applied, and re-apply when it changes.</li>
</ul>
<h2 id="where-this-fits">Where this fits</h2>
<p>VEX is one input to a patch decision, not the decision. In our <a href="/posts/vulnerability-prioritization-workflow-cve-record-to-patch-ticket/">vulnerability prioritization workflow</a>, a supplier VEX statement is the step that can close a ticket before KEV, EPSS or SSVC are weighed. For the SBOM side of the join, the <a href="/posts/sbom-minimum-elements-2026-what-cisa-and-partners-changed-from-the-2021-ntia-baseline/">SBOM minimum elements guide</a> covers which identifiers your SBOM should carry in the first place. Without purls in the SBOM, none of this matching works.</p>
<h2 id="limits-of-this-article">Limits of this article</h2>
<p>We read CSAF 2.0 from the OASIS TC&rsquo;s GitHub repository (the editor&rsquo;s draft prose, headed &ldquo;OASIS Standard, 18 November 2022&rdquo;, and the JSON schema) rather than the copy hosted on docs.oasis-open.org. CSAF 2.1 is still a draft in that repository and may change field names or add statuses. We did not download a Red Hat VEX file; Red Hat&rsquo;s structure is described from its own announcements. The purl matching rules are a community convention, not part of the purl standard. Our test document is synthetic.</p>
<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>CSAF 2.0 is an OASIS Standard dated 18 November 2022; VEX profile requirements (section 4.5)</td>
          <td><a href="https://github.com/oasis-tcs/csaf/blob/master/csaf_2.0/prose/csaf-v2-editor-draft.md">CSAF 2.0 prose, OASIS TC repository</a></td>
          <td>Qualified (TC repository copy)</td>
      </tr>
      <tr>
          <td>Eight product_status lists and their definitions; flag labels; remediation categories; relationship categories</td>
          <td>Same document, sections 3.2.3.9, 3.2.3.5, 3.2.3.12.1, 3.2.2.4</td>
          <td>Verified</td>
      </tr>
      <tr>
          <td>Contradiction groups must be pairwise disjoint; recommended may come from any group</td>
          <td>Same document, section 6.1.6</td>
          <td>Verified</td>
      </tr>
      <tr>
          <td>purl helper pattern and &ldquo;does not completely evaluate&rdquo; note</td>
          <td>Same document, section 3.1.3.3.4</td>
          <td>Verified</td>
      </tr>
      <tr>
          <td>Example document is schema-valid</td>
          <td><a href="https://github.com/oasis-tcs/csaf/blob/master/csaf_2.0/json_schema/csaf_json_schema.json">CSAF 2.0 JSON schema</a>, validated with Python jsonschema</td>
          <td>Verified (our test)</td>
      </tr>
      <tr>
          <td>Red Hat VEX files: per CVE, product_tree with relationships, purls extended to unfixed rpm/oci/rpmmod components at GA</td>
          <td><a href="https://www.redhat.com/en/blog/red-hat-vex-files-cves-are-now-generally-available">Red Hat blog, 10 July 2024</a>; <a href="https://www.redhat.com/en/blog/vulnerability-exploitability-exchange-vex-beta-files-now-available">beta announcement, 16 October 2023</a></td>
          <td>Qualified (vendor announcement; GA post read via a localized copy)</td>
      </tr>
      <tr>
          <td>Trivy CSAF matcher uses known_not_affected and fixed; three relationship categories</td>
          <td><a href="https://github.com/aquasecurity/trivy/blob/v0.76.1/pkg/vex/csaf.go">Trivy v0.76.1 pkg/vex/csaf.go</a></td>
          <td>Verified</td>
      </tr>
      <tr>
          <td>Trivy CSAF targets, relationship handling and purl matching rules</td>
          <td><a href="https://github.com/aquasecurity/trivy/blob/v0.76.1/docs/guide/supply-chain/vex/file.md">Trivy v0.76.1 VEX file documentation</a></td>
          <td>Verified</td>
      </tr>
  </tbody>
</table>
]]></content:encoded></item></channel></rss>