Get the Zoom link
Cloud Security Office Hours Banner

OVAL and SCAP, hands-on

Linux vendors publish their security advisories in OVAL, an XML format that a scanner can check a system against. You will almost never write OVAL. You will read it constantly, usually at the moment your vulnerability scanner and your Linux vendor disagree about whether a system is vulnerable. Here is how to settle that.

Jump to the walk-through All how-to guides

·

Time: ~2 hours  ·  Difficulty: Intermediate  ·  You need: Docker (the scanner is Linux-only, so the lab runs in a container)

Slides: download the PDF or make your own editable copy (copying needs a Google account). The slides are licensed CC BY-NC 4.0.

What OVAL is, and why you will read it rather than write it

Here is the moment this page prepares you for. Your vulnerability scanner reports a Red Hat Enterprise Linux (RHEL) 9 server as vulnerable to a CVE, a publicly numbered vulnerability, in openssl, because the installed openssl is version 3.0.7 and the openssl project's own fix arrived in 3.0.8. Red Hat's advisory data says the installed package already contains the fix. One of them is wrong, and the evidence that settles it is written in OVAL.

OVAL is the Open Vulnerability and Assessment Language: an XML vocabulary for stating, precisely and machine-readably, what has to be true of a system for some claim about it to hold. "This host is affected by CVE-2023-0286" is a claim. OVAL is how a vendor writes that claim down so that any scanner can evaluate it and get the same answer.

Almost nobody authors OVAL from scratch, and this page is not going to pretend otherwise. What you will do, repeatedly, is consume it and occasionally argue with it. Every major Linux distribution publishes its security advisories as OVAL. Every SCAP-based compliance scan is OVAL underneath; SCAP is the family of standards that automated compliance checkers are built on, and a section below takes it apart. And every DISA STIG and CIS Benchmark you run through an automated checker is delivered as OVAL bound to an XCCDF checklist. Those two are hardening baselines, lists of settings a system should have: STIGs (Security Technical Implementation Guides) come from the US Defense Information Systems Agency, and CIS Benchmarks from the Center for Internet Security.

So when your vulnerability scanner and your distribution disagree about whether you are exposed, as in the openssl case above, the authoritative answer is sitting in an OVAL definition, and being able to read it is the difference between escalating a real finding and burning a week patching a false positive.

The most useful thing OVAL encodes: backports. Red Hat, SUSE, Debian, and Ubuntu routinely fix a vulnerability by patching an older package version rather than shipping the newer upstream release, the one the original project publishes. The version string stays at, say, 1.1.1k forever, and only the release field moves: that is the vendor's own build number, after the hyphen in a full version such as 1.1.1k-9. A scanner that compares your version against "fixed in upstream 1.1.1n" reports you as vulnerable and is wrong. The vendor's OVAL states the real fixed evr (epoch, version and release, explained below), and it is the only thing that does.

On this page

  1. How to use this guide
  2. Where OVAL sits inside SCAP
  3. The four building blocks
  4. Walk-through
  5. Hands-on exercises
  6. Common mistakes
  7. Where next

How to use this guide

Intermediate here means you are comfortable at a Linux command line, can run a Docker container, and know what a vulnerability scanner reports and what a CVE is. If the command line is new to you, the learning path's prerequisites point to a free place to start, and the CVE lifecycle section of the vulnerability management guide shows how an advisory reaches your scanner. Some practice reading XML helps, because OVAL is XML.

Read the sections before the walk-through in order. The box on backports, above the table of contents, explains the most useful thing OVAL encodes. Where OVAL sits inside SCAP names the standards around OVAL; its last part, current versions and who owns what, can wait for a second reading. The four building blocks then takes one example definition apart. In the walk-through, step 1 starts a Fedora container and installs the scanner, oscap. Steps 2 to 4 download Red Hat's OVAL feed, follow one definition through it and evaluate the whole feed. Steps 5 to 7 run a compliance scan, read its results and generate a remediation script, step 8 points the scanner at a container image, and step 9 removes what the lab left on your computer. The exercises then ask you to trace definitions and rules yourself, with each answer hidden until you select "Show the answer". They use the lab, so do them before step 9.

A code block labelled BASH is a command to paste into a terminal, and every block has a copy button. The two blocks labelled XML are excerpts of OVAL to read, not files to save. Step 1 has two BASH blocks, and they run in different places. The first runs in your own terminal: it makes a folder and starts a Fedora container. The second, and every BASH block after it, runs inside that container, in its /work folder, which is ~/oval-lab on your computer, so your reports survive when the container exits. The exceptions are the first block of step 8, which runs Docker commands and so goes in a second terminal on your own computer, and the block in step 9, which runs on your own computer after you leave the container. The shell inside the container is bash, which accepts the # comments in those blocks. The page does not show what each command prints; the comments in the blocks, and the text after some, say what to look for.

Some commands hold a value for you to replace. The id in step 3's second command comes from the illustrative definition in the four building blocks, so use the ids you find in the real feed instead, as its comment says. Exercises 3 and 4 have <rule-id> and $PROFILE.

If oscap is not found, or a file under /usr/share/xml/scap/ is missing, check that you are inside the container: step 1 installs the scanner and that content there. If an xmllint query prints nothing, read the note on namespaces in step 3's first block before concluding that the element is absent.

Where OVAL sits inside SCAP

A compliance scan starts from one file. In step 5 you will point the scanner at ssg-fedora-ds.xml and check a Fedora system against a named baseline, rule by rule. Each rule needs prose a person can read (what the rule asks for and why), a check a machine can run (how to tell pass from fail on a live system), and a statement of which platforms it applies to. SCAP, the Security Content Automation Protocol, is the set of standards that splits up that work. OVAL is one component of it, and the components divide the work cleanly:

In practice these arrive bundled as a data stream: one XML file containing the XCCDF, the OVAL, and the CPE dictionary together. That is what a file named ssg-rhel9-ds.xml is.

Current versions, and who owns what

This corner of the ecosystem has moved, and stale references are everywhere.

You will still find plenty of documentation pointing at MITRE as the current owner. It is not, and a link into the archived site is a good signal that whatever you are reading has not been touched in years.

The four building blocks

OVAL's structure is where people bounce off it, because everything is joined by id reference rather than by nesting: an element points at the next one by quoting that element's id, instead of containing it. Four kinds of element, each with a single job:

Read it as a sentence and the indirection stops being noise: a definition is true when its criteria are satisfied; a criterion is satisfied when its test passes; a test passes when the items collected for its object match its state.

One definition, shaped like a real vendor advisory

Element names below match what Red Hat publishes. The ids and versions are illustrative, and the criteria tree is simplified: Red Hat's own definitions open with one more branch, which step 4 shows.

<definition class="patch" id="oval:com.redhat.rhsa:def:20231234" version="1">
  <metadata>
    <title>RHSA-2023:1234: openssl security update (Important)</title>
    <affected family="unix">
      <platform>Red Hat Enterprise Linux 9</platform>
    </affected>
    <reference source="CVE" ref_id="CVE-2023-0286"
               ref_url="https://access.redhat.com/security/cve/CVE-2023-0286"/>
  </metadata>

  <!-- The criteria tree. Note the AND: the platform test guards the
       package test, so this definition simply does not apply on RHEL 8. -->
  <criteria operator="AND">
    <criterion test_ref="oval:com.redhat.rhsa:tst:20231234001"
               comment="Red Hat Enterprise Linux 9 is installed"/>
    <criterion test_ref="oval:com.redhat.rhsa:tst:20231234002"
               comment="openssl is earlier than 1:3.0.7-6.el9_1"/>
  </criteria>
</definition>

Follow tst:20231234002 and you land on the test, which points at an object and a state:

<!-- TEST: check="at least one" means the test passes if any installed
     package matching the object satisfies the state. -->
<rpminfo_test id="oval:com.redhat.rhsa:tst:20231234002" check="at least one"
              comment="openssl is earlier than 1:3.0.7-6.el9_1" version="1">
  <object object_ref="oval:com.redhat.rhsa:obj:20231234002"/>
  <state  state_ref="oval:com.redhat.rhsa:ste:20231234002"/>
</rpminfo_test>

<!-- OBJECT: what to collect from the system. Just a package name. -->
<rpminfo_object id="oval:com.redhat.rhsa:obj:20231234002" version="1">
  <name>openssl</name>
</rpminfo_object>

<!-- STATE: the condition that means "still vulnerable".
     datatype="evr_string" is the important part - see below. -->
<rpminfo_state id="oval:com.redhat.rhsa:ste:20231234002" version="1">
  <evr datatype="evr_string" operation="less than">1:3.0.7-6.el9_1</evr>
</rpminfo_state>

evr is epoch, version, release. datatype="evr_string" tells the scanner to compare using RPM's own version-comparison algorithm rather than string or numeric comparison, which is the only way 1.1.1k-9 correctly sorts after 1.1.1k-8 and before 1.1.1k-10.

And look at where the fix lives: -6.el9_1, the release field. The upstream version never moved. That is a backport, written down in the only place it is written down.

Step 3 follows the same chain of ids through a real definition in Red Hat's feed.

Walk-through

1. Get a scanner

oscap is Linux-only, so run the lab in a container regardless of your laptop. In your own terminal, make a folder for the lab and start a Fedora container from it. -v mounts this folder into the container as /work, so your reports survive when the container exits.

mkdir -p ~/oval-lab && cd ~/oval-lab

docker run --rm -it -v "$PWD:/work" -w /work fedora:latest bash

That leaves you at a bash prompt inside the container, in /work. Run the next block there, and every BASH block after it on this page except the first one in step 8 and the one in step 9:

dnf install -y openscap-scanner scap-security-guide bzip2 libxml2 && oscap --version

oscap --version prints the OVAL and XCCDF schema versions it supports. Read them. Content written against a newer schema than your scanner understands is a real and confusing failure mode.

2. Fetch a real vendor OVAL feed

A vendor's OVAL feed is one file holding its OVAL definitions for one release.

# Red Hat publishes per-release OVAL streams; Debian, Ubuntu, and SUSE
# publish equivalents. The download is about 1.5 MB, and bunzip2 unpacks
# it to more than 35 MB. Both grow as Red Hat publishes advisories.
curl -sSLO https://access.redhat.com/security/data/oval/v2/RHEL9/rhel-9.oval.xml.bz2
bunzip2 -f rhel-9.oval.xml.bz2

# How many definitions did we just download?
grep -c '<definition ' rhel-9.oval.xml

3. Read one definition end to end

This is the exercise that makes the format stop feeling opaque. Pick a CVE, find its definition, then follow the id chain by hand. The commands use xmllint --xpath, which prints the parts of an XML file that an XPath expression (a path through the document's elements) selects.

# Find a definition that references a CVE you care about.
xmllint --xpath \
  "//*[local-name()='definition'][.//*[@ref_id='CVE-2023-0286']]/@id" \
  rhel-9.oval.xml

# Note local-name(): OVAL is heavily namespaced, and a plain //definition
# XPath silently returns nothing. Empty output from a namespaced document
# almost always means the namespace, not an absent element.
# Then walk the chain, substituting each id you find as you go:
#   definition -> criterion test_ref -> test -> object_ref + state_ref
xmllint --xpath "//*[@id='oval:com.redhat.rhsa:tst:20231234002']" rhel-9.oval.xml

4. Run an OVAL-only evaluation

This evaluates every definition in the feed against the running system and writes one result line per definition to oval-eval.txt. On a RHEL 9 system, a true definition is an advisory that applies to you. This container is Fedora, and what it reports shows why a vendor feed has to be run on the platform it was written for.

oscap oval eval --results oval-results.xml --report oval-report.html \
  rhel-9.oval.xml > oval-eval.txt

# Count the definitions that came back true, and compare with the number
# of definitions step 2 counted in the feed.
grep -c ': true' oval-eval.txt

# Which package owns the file that Red Hat's platform check reads?
rpm -qf /etc/redhat-release

The two counts match: every definition is true, and that tells you nothing about this container's packages. The last command prints fedora-release-common and its version. Open any definition from step 3 and look at the top of its criteria tree. It starts with an OR, and the OR's first criterion, "Red Hat Enterprise Linux must be installed", points at a test with check="none satisfy". That test collects the package that owns /etc/redhat-release and passes when that package is not named redhat-release. Here it belongs to fedora-release-common, so the first branch of the OR is true, and the definition is true before a single package version is compared. On RHEL 9 the same test fails, and the OR's second branch decides the result: an AND that starts with "Red Hat Enterprise Linux 9 is installed" and then checks the packages. Read a vendor feed's results only on the platform it was written for, and read the criteria before you trust a count.

5. Run a real compliance scan through XCCDF

Now the other half of SCAP. The scap-security-guide package installs data streams under /usr/share/xml/scap/ssg/content/.

ls /usr/share/xml/scap/ssg/content/

# oscap info tells you what is inside a data stream, and crucially which
# profiles it offers. Never guess a profile id - they are long and versioned.
oscap info /usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml
oscap xccdf eval \
  --profile xccdf_org.ssgproject.content_profile_standard \
  --results-arf arf.xml \
  --report report.html \
  /usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml

echo $?   # 0 = all rules passed, 2 = at least one failed, 1 = the scan errored

Exit code 1 and exit code 2 mean completely different things, and a CI step written as oscap ... || exit 1 collapses them. 2 is "the scan worked and found problems". 1 is "the scan did not happen". Treating a scan that never ran as a scan that found nothing is the failure this whole discipline exists to prevent.

6. Read the results

# Open report.html in a browser for the human view. For the machine view,
# pull the rule results straight out of the ARF:
xmllint --xpath \
  "//*[local-name()='rule-result'][*[local-name()='result']='fail']/@idref" \
  arf.xml | tr ' ' '\n' | head -20

Every failing rule id maps back to an XCCDF rule with prose rationale, and that rule points at the OVAL definition that produced the verdict. When someone disputes a finding, that chain is the evidence.

7. Generate remediation, and read it before running it

oscap xccdf generate fix \
  --profile xccdf_org.ssgproject.content_profile_standard \
  --fix-type bash \
  /usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml > remediate.sh

# --fix-type ansible emits a playbook instead, which is usually the better
# artifact: it is idempotent, reviewable, and fits an existing change process.

Generated remediation is both useful and dangerous. It is derived from a baseline that knows nothing about your workload, and a STIG profile applied wholesale to a running application server will disable something that application needs. Treat the output as a reviewed pull request, never as a command to pipe into a shell.

8. Scan a container image instead of a host

An image is a filesystem that has not been started, so the scanner can read its package list without running anything. On a Linux machine with Podman, oscap-podman, run as root, does that in one command. It cannot work inside this lab's container, because Podman needs privileges that Docker does not give an ordinary container. So unpack the image yourself and point the scanner at the result.

The image is Red Hat's Universal Base Image 9.0.0 (UBI, the freely redistributable RHEL 9 base image), built in November 2022, so it is missing years of fixes. Docker commands do not work inside the lab container, so open a second terminal on your own computer and run this block there. It downloads the image, creates a container from it without starting it, writes that container's filesystem to ubi9-old.tar in your lab folder (about 240 MB), and removes the container.

cd ~/oval-lab
docker create --name ubi9-old registry.access.redhat.com/ubi9/ubi:9.0.0
docker export ubi9-old -o ubi9-old.tar
docker rm ubi9-old

Back in the container, install openscap-utils, which provides oscap-chroot, and unpack the file into the container's own filesystem rather than /work: a folder on a Mac normally treats file names that differ only in case as the same file, and the image has a few of those. oscap-chroot runs the same oval eval as step 4, but every check reads the files and package database under /ubi9-old instead of the container's own.

dnf install -y openscap-utils
mkdir -p /ubi9-old && tar -xf ubi9-old.tar -C /ubi9-old
oscap-chroot /ubi9-old oval eval --report image-report.html rhel-9.oval.xml > image-scan.txt
grep -c ': true' image-scan.txt

The scan prints one warning, that the uname probe does not support offline mode. That probe asks which kernel is running, and an image has no running kernel; the feed's definitions that use it are about live kernel patches, and they come back false here. The last command counts the definitions that came back true, which are the Red Hat advisories that apply to the image. When this page was checked on 6 November 2026 it printed 225, and the number grows as Red Hat publishes advisories. Open image-report.html from your lab folder to see which they are. oscap oval eval exits 0 whether or not any definition is true, so a pipeline that gates on this scan has to read the results, not the exit code. As a control, export registry.access.redhat.com/ubi9/ubi:latest the same way and scan it: no advisory in the feed applies to the current image, so the count is 0.

Scanning images is where OVAL earns its keep in cloud work. The unit you are assessing is a golden image or a base layer, not a long-lived server, and answering "which advisories apply to this image" before it is deployed a thousand times is worth considerably more than answering it afterwards.

9. Clean up

The lab leaves its files in ~/oval-lab (about 240 MB for each image you exported, plus the feed and the reports) and three images in Docker. Do the exercises below first, because they use the feed and the container. Then type exit to leave the container, which also removes it, because step 1 started it with --rm. Docker will not remove an image while a container is using it. In your own terminal, remove the three images and the lab folder:

docker rmi fedora:latest registry.access.redhat.com/ubi9/ubi:9.0.0 registry.access.redhat.com/ubi9/ubi:latest
rm -rf ~/oval-lab

If you skipped the control in step 8, Docker reports that there is no ubi:latest image and removes the other two. Leave out any image you were already using before the lab.

Hands-on exercises

Exercise 1

Using the Red Hat feed you downloaded, pick any definition and follow it all the way down: definition to criterion, criterion to test, test to object and state. Write out in one plain sentence what condition the definition is checking.

Show the answer

Your sentence should come out roughly as: "On a system where the RHEL 9 platform test passes, at least one installed RPM named X has an evr less than Y."

Two structural things are worth having noticed on the way down. Red Hat's platform check sits at the top of the criteria tree in two parts: an OR whose first branch is true on any system where /etc/redhat-release is not owned by redhat-release (step 4), and under it an AND that starts with "Red Hat Enterprise Linux 9 is installed". That AND is why a definition can be present in a feed and simply not apply on a RHEL 8 system. And the same object is frequently referenced by several tests with different states, which is how one definition covers a package that was fixed at different versions on different minor releases.

Exercise 2

A scanner reports your RHEL 9 host as vulnerable to a CVE in openssl, citing "fixed in 3.0.8". Your host has openssl-3.0.7-6.el9_1. The vendor OVAL says the fixed evr is 1:3.0.7-6.el9_1 and the definition evaluates to false. Who is right, and what exactly did the scanner get wrong?

Show the answer

The vendor is right and you are not vulnerable. The scanner compared your version against the upstream fixed version and concluded that 3.0.7 is less than 3.0.8. Red Hat backported the fix into the 3.0.7 package and expressed it in the release field, -6.el9_1, leaving the upstream version untouched.

The scanner's mistake is a category error, not an arithmetic one: it used upstream version numbers as a proxy for patch status on a distribution that deliberately decouples those two things. The evr comparison and the vendor feed both exist for this reason.

The practical move when you meet this: get the evidence rather than the argument. rpm -q --changelog openssl | grep CVE- lists the CVEs the installed package claims to fix, and it either names yours or it does not.

Exercise 3

Take one failing rule id from your XCCDF scan and find the OVAL definition behind it. Then answer: could you have determined pass or fail by reading the XCCDF alone?

Show the answer
# The XCCDF rule carries a <check-content-ref> naming the OVAL definition id.
xmllint --xpath "//*[local-name()='Rule'][@id='<rule-id>']
  //*[local-name()='check-content-ref']/@name" \
  /usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml

No, and that is the whole division of labour. XCCDF says what should be true and why it matters, in prose aimed at a human. OVAL says how to determine whether it is true, in a form aimed at a machine. An XCCDF rule with no check reference is documentation; it will report notchecked and it will not fail a scan.

That last point is worth checking for deliberately. A profile can look like it is enforcing far more than it is, because notchecked results are easy to read past in a report that is mostly green.

Exercise 4

A rule in the profile is wrong for your environment and you need to switch it off. Why is editing the data stream the wrong answer, and what is the right one?

Show the answer

Editing the data stream forks vendor content. The next release overwrites your change or, worse, does not, and you quietly drift onto a private baseline nobody can reproduce or audit. You also lose the signature on signed content.

The right mechanism is tailoring: a separate XCCDF tailoring file that selects and deselects rules and overrides variable values, referencing the original data stream without modifying it.

oscap xccdf eval \
  --profile "$PROFILE" \
  --tailoring-file my-tailoring.xml \
  /usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml

The tailoring file is also the artifact your auditor wants, because it is an explicit, reviewable, version-controlled list of every deviation from the published baseline and, if you write the remark fields, why. scap-workbench has a GUI for producing one if hand-writing XCCDF is not how you want to spend an afternoon.

Common mistakes

Where next