Debian Codegraph @

docs/manual/manual.adoc

raw
1 = OpenSCAP User Manual
2 :imagesdir: ./images
3 :workbench_url: https://www.open-scap.org/tools/scap-workbench/
4 :json_tailoring_url: https://github.com/ComplianceAsCode/schemas/tree/main/tailoring
5 :sce_web: https://www.open-scap.org/features/other-standards/sce/
6 :openscap_web: https://open-scap.org/
7 :oscap_git: https://github.com/OpenSCAP/openscap
8 :devel_manual: https://github.com/OpenSCAP/openscap/blob/main/docs/developer/developer.adoc
9 :ssg_git: https://github.com/ComplianceAsCode/content
10 :xmlsec: https://www.aleksey.com/xmlsec/
11 :xslt: http://www.w3.org/TR/xslt
12 :xsl: http://www.w3.org/Style/XSL/
13 :ssg: http://open-scap.org/security-policies/scap-security-guide/
14 :xccdf: http://scap.nist.gov/specifications/xccdf/
15 :xccdf_1-2: http://scap.nist.gov/specifications/xccdf/#resource-1.2
16 :scap: http://scap.nist.gov/
17 :nist: http://www.nist.gov/
18 :cpe: https://cpe.mitre.org/
19 :cce: https://cce.mitre.org/
20 :oval: https://oval.mitre.org/
21 :pci_dss: https://www.pcisecuritystandards.org/security_standards/
22 :stig: http://iase.disa.mil/stigs/Pages/index.aspx
23 :scap_1-3: https://csrc.nist.gov/Projects/Security-Content-Automation-Protocol/SCAP-Releases/scap-1-3
24 :scap_1-2: https://csrc.nist.gov/Projects/Security-Content-Automation-Protocol/SCAP-Releases/SCAP-1-2
25 :scap_1-1: https://csrc.nist.gov/Projects/Security-Content-Automation-Protocol/SCAP-Releases/SCAP-1-1
26 :scap_1-0: https://csrc.nist.gov/Projects/Security-Content-Automation-Protocol/SCAP-Releases/SCAP-1-0
27 :nvd: https://web.nvd.nist.gov/view/ncp/repository
28 :cis: https://www.cisecurity.org/cis-benchmarks
29 :toc:
30 :toclevels: 4
31 :toc-placement: preamble
32 :numbered:
33 :footer-style: none
34
35 image::vertical-logo.png[align="center"]
36
37 toc::[]
38
39 == Introduction
40
41 This documentation provides information about OpenSCAP and its most common
42 operations. With OpenSCAP, you can check security configuration settings of a
43 system, and examine the system for signs of a compromise by using rules based on
44 standards and specifications.
45
46 OpenSCAP uses {scap}[SCAP] which is a line of specifications maintained by the
47 {nist}[NIST]. SCAP was created to provide a standardized approach for
48 maintaining system security. New specifications are governed by NIST's SCAP
49 http://scap.nist.gov/timeline.html[Release cycle] in order to provide a
50 consistent and repeatable revision workflow. OpenSCAP mainly processes the
51 {xccdf}[XCCDF] which is a standard way of expressing a checklist content and
52 defines security checklists. It also combines with other specifications such as
53 {cpe}[CPE], {cce}[CCE] and {oval}[OVAL] to create a SCAP-expressed checklist
54 that can be processed by SCAP-validated products. For more information about the
55 SCAP please refer to http://open-scap.org/features/standards/[SCAP Standards].
56
57 OpenSCAP supports SCAP {scap_1-3}[1.3] and is backward compatible with SCAP
58 {scap_1-2}[1.2], SCAP {scap_1-1}[1.1] and SCAP {scap_1-0}[1.0]. No special
59 treatment is required to import and process earlier versions of the SCAP
60 content.
61
62 If you want to perform configuration or vulnerability scans of a local system
63 then the following must be available:
64
65 . A tool (`oscap` or SCAP Workbench)
66 . SCAP content (SCAP source data stream, XCCDF, OVAL...)
67
68 The `oscap` tool is a part of the {openscap_web}[OpenSCAP] project. If you're
69 interested in a graphical alternative to this tool please visit
70 {workbench_url}[SCAP Workbench] page.
71
72 We will use the {ssg_git}[ComplianceAsCode] (scap-security-guide) project to provide us the SCAP
73 content. It provides security policies written in a form of SCAP documents
74 covering many areas of security compliance, and it implements security guidances
75 recommended by respected authorities, namely {pci_dss}[PCI DSS], {stig}[STIG],
76 and {cis}[CIS].
77
78 You can also generate your own SCAP content if you have an understanding of at
79 least XCCDF or OVAL. XCCDF content is also frequently published online under
80 open source licenses, and you can customize this content to suit your needs
81 instead.
82
83 == Installing OpenSCAP
84
85 You can either build OpenSCAP from {oscap_git}[source code] or you can use an
86 existing build for your Linux distribution.
87
88 For instructions about building from source code, please refer to
89 {devel_manual}[OpenSCAP Developer Manual].
90
91 To install OpenSCAP on Red Hat Enterprise Linux 8 and newer, on CentOS 8 and
92 newer or on Fedora use the following command:
93
94 ----
95 # dnf install openscap-scanner
96 ----
97
98 To install OpenSCAP on Debian 12 or Ubuntu 24.04 or newer use the following command:
99
100 ----
101 # apt install openscap-scanner
102 ----
103
104 To install OpenSCAP on older versions of Debian or Ubuntu use the following command:
105
106 ----
107 # apt install libopenscap8
108 ----
109
110 After the installation is completed you can start using the `oscap` command line
111 tool.
112
113 To display the version of OpenSCAP, supported specifications, and supported OVAL objects, type the following command:
114
115 ----
116 $ oscap --version
117 ----
118
119 === Getting SCAP content
120
121 To perform any task with OpenSCAP you also need to have security policies in
122 SCAP format. We call them *SCAP content*. There are many providers of SCAP
123 content.
124
125 In this document we will use SCAP content provided by *SCAP Security Guide*
126 (SSG). Many Linux distributions ship it in the `scap-security-guide` package.
127
128 To install `scap-security-guide` on Red Hat Enterprise Linux 8 and newer, on
129 CentOS 8 and newer or on Fedora use the following command:
130
131 ----
132 # dnf install scap-security-guide
133 ----
134
135 The SCAP content will be installed in the `/usr/share/xml/scap/ssg/content/`
136 directory.
137
138 On other platforms, you can download the upstream release from
139 https://github.com/ComplianceAsCode/content/releases/[GitHub].
140
141 When the SCAP content is installed on your system, `oscap` can
142 process the content by specifying the file path to the content.
143
144 You can also use any other SCAP content with OpenSCAP.
145
146 == Displaying information about SCAP content
147
148 Information about an SCAP file can be displayed using the `oscap info` command.
149
150 === Displaying information about SCAP source data streams
151
152 The most common SCAP file type is an SCAP source data stream. In the following
153 example, we will display information about SCAP source data stream
154 `/usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml` from the
155 `scap-security-guide` package.
156
157 ----
158 $ oscap info /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
159 Document type: Source Data Stream
160 Imported: 2021-01-12T04:50:11
161
162 Stream: scap_org.open-scap_datastream_from_xccdf_ssg-rhel8-xccdf-1.2.xml
163 Generated: (null)
164 Version: 1.3
165 Checklists:
166 Ref-Id: scap_org.open-scap_cref_ssg-rhel8-xccdf-1.2.xml
167 Status: draft
168 Generated: 2021-01-12
169 Resolved: true
170 Profiles:
171 Title: CIS Red Hat Enterprise Linux 8 Benchmark
172 Id: xccdf_org.ssgproject.content_profile_cis
173 Title: Unclassified Information in Non-federal Information Systems and Organizations (NIST 800-171)
174 Id: xccdf_org.ssgproject.content_profile_cui
175 Title: Australian Cyber Security Centre (ACSC) Essential Eight
176 Id: xccdf_org.ssgproject.content_profile_e8
177 Title: Health Insurance Portability and Accountability Act (HIPAA)
178 Id: xccdf_org.ssgproject.content_profile_hipaa
179 Title: PCI-DSS v3.2.1 Control Baseline for Red Hat Enterprise Linux 8
180 Id: xccdf_org.ssgproject.content_profile_pci-dss
181 Title: [DRAFT] DISA STIG for Red Hat Enterprise Linux 8
182 Id: xccdf_org.ssgproject.content_profile_stig
183 Title: Protection Profile for General Purpose Operating Systems
184 Id: xccdf_org.ssgproject.content_profile_ospp
185 Referenced check files:
186 ssg-rhel8-oval.xml
187 system: http://oval.mitre.org/XMLSchema/oval-definitions-5
188 ssg-rhel8-ocil.xml
189 system: http://scap.nist.gov/schema/ocil/2
190 security-data-oval-com.redhat.rhsa-RHEL8.xml
191 system: http://oval.mitre.org/XMLSchema/oval-definitions-5
192 ----
193
194 * **Document type** describes what format the file is in. Common types include
195 XCCDF, OVAL, source data stream and result data stream.
196 * **Imported** is the date the file was imported for use with OpenSCAP. Since
197 OpenSCAP uses the local filesystem and has no proprietary database format
198 the imported date is the same as file modification date.
199 * **Stream** is the data stream ID.
200 * **Version** is the version of the SCAP standard.
201 * **Checklists** lists available checklists incorporated in the data stream that
202 you can use for the `--benchmark-id` command line attribute with `oscap xccdf
203 eval`. Also each checklist has the detailed information printed.
204 * **Status** is the XCCDF Benchmark status. Common values include "accepted",
205 "draft", "deprecated" and "incomplete". Please refer to the XCCDF specification
206 for details.
207 * **Generated** date is the date the file was created or generated. This date is
208 shown for XCCDF files and Checklists and is sourced from the XCCDF **Status**
209 element.
210 * **Profiles** lists available profiles, their titles and IDs that you can use for
211 the `--profile` command line attribute.
212
213 To display more detailed information about a profile including the profile
214 description, use the `--profile` option followed by the profile ID.
215
216 ----
217 $ oscap info --profile xccdf_org.ssgproject.content_profile_ospp /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
218 ----
219
220 === Listing rules selected by a profile
221
222 To list the IDs of all XCCDF rules that are selected by a given profile, use
223 the `--list-rules` option together with `--profile`. The output contains one
224 rule ID per line and is machine-readable, which makes it suitable for scripting,
225 CI/CD pipelines, and tailoring validation workflows.
226
227 ----
228 $ oscap info --profile ospp --list-rules /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
229 xccdf_org.ssgproject.content_rule_partition_for_tmp
230 xccdf_org.ssgproject.content_rule_partition_for_var
231 ...
232 ----
233
234 The `--list-rules` option requires `--profile`. Running `--list-rules` without
235 `--profile` will produce an error.
236
237 === Listing variables set by a profile
238
239 To list the XCCDF Values (variables) and their resolved values for a given
240 profile, use the `--list-vars` option together with `--profile`. Each line
241 contains a Value ID and its resolved value, separated by a tab character.
242
243 ----
244 $ oscap info --profile ospp --list-vars /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
245 xccdf_org.ssgproject.content_value_var_password_minlen 15
246 xccdf_org.ssgproject.content_value_var_accounts_max_concurrent_login_sessions 10
247 ...
248 ----
249
250 The `--list-vars` option requires `--profile`. Running `--list-vars` without
251 `--profile` will produce an error.
252
253 === Displaying information about SCAP result data streams
254
255 The `oscap info` command is also helpful with other SCAP file types such as
256 SCAP result data stream (ARF) files.
257
258 OpenSCAP can display the evaluation start and end dates when given ARF file.
259
260 In this example, we will display information about the ARF file `arf.xml`.
261
262 ----
263 $ oscap info arf.xml
264 Document type: Result Data Stream
265 Imported: 2021-02-11T11:04:51
266
267 Asset: asset0
268 ARF report: xccdf1
269 Report request: collection1
270 Result ID: xccdf_org.open-scap_testresult_xccdf_org.ssgproject.content_profile_ospp
271 Source benchmark: /usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml
272 Source profile: xccdf_org.ssgproject.content_profile_ospp
273 Evaluation started: 2021-02-11T11:03:06+01:00
274 Evaluation finished: 2021-02-11T11:04:51+01:00
275 Platform CPEs:
276 cpe:/o:fedoraproject:fedora:25
277 cpe:/o:fedoraproject:fedora:26
278 cpe:/o:fedoraproject:fedora:27
279 ----
280
281 == Scanning
282
283 The main goal of OpenSCAP is to perform configuration and vulnerability scans of
284 a local system. OpenSCAP is able to evaluate SCAP source data streams, XCCDF
285 benchmarks and OVAL definitions and generate the appropriate results.
286
287 SCAP content can be provided either in a single file (as an SCAP source data
288 stream), or as multiple separate XML files.
289
290 === Scanning using SCAP source data streams
291
292 Commonly, all required input files are bundled together in an SCAP source data
293 stream. Scanning using an SCAP source data stream can be performed by the
294 `oscap xccdf eval` command, with some additional parameters available.
295 The basic syntax of the `oscap xccdf eval` command is the following:
296
297 ----
298 # oscap xccdf eval --profile PROFILE_ID --results-arf ARF_FILE --report REPORT_FILE SOURCE_DATA_STREAM_FILE
299 ----
300
301 Where:
302
303 * `PROFILE_ID` is the ID of an XCCDF profile
304 * `ARF_FILE` is the file path where the results in SCAP results data stream
305 format (ARF) will be generated
306 * `REPORT_FILE` is the file path where a report in HTML format will be generated
307 * `SOURCE_DATA_STREAM_FILE` is the file path of the evaluated SCAP source data
308 stream
309
310 For example, to evaluate the `xccdf_org.ssgproject.content_profile_ospp` profile
311 from the `/usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml` SCAP source
312 data stream run this command:
313
314 ----
315 # oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_ospp --results-arf results.xml --report report.html /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
316 ----
317
318 The progress and results will be shown in the terminal. Full results are
319 generated in `results.xml` as an SCAP result data stream. Detailed results can
320 be found in the HTML report `report.html`.
321
322 ----
323 $ firefox report.html
324 ----
325
326 TIP: Instead of the complete profile ID you can provide only a suffix of the
327 profile ID. For example, instead of `--profile
328 xccdf_org.ssgproject.content_profile_ospp` you can use just `--profile ospp`.
329
330 Rule description, rule rationale and rule warnings will be displayed in the output if the `--show-rule-details` option is provided.
331
332 ----
333 # oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_stig --results-arf results.xml --show-rule-details /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
334 ----
335
336 === Selecting SCAP source data stream components
337
338 To evaluate a specific XCCDF benchmark that is part of a specific SCAP source
339 data stream, use the following command:
340
341 ----
342 $ oscap xccdf eval --datastream-id DS_ID --xccdf-id CREF --results-arf ARF_FILE SOURCE_DATA_STREAM_FILE
343 ----
344
345 Where:
346
347 * `DS_ID` is the ID of `<ds:data-stream>` element to be evaluated
348 * `XCCDF_ID` is ID of the `<ds:component-ref>` element pointing to the
349 desired XCCDF document
350 * `ARF_FILE` is a file containing the scan results in a form of an SCAP
351 result data stream
352 * `SOURCE_DATA_STREAM_FILE` is the SCAP source data stream file
353
354 NOTE: If you omit `--datastream-id` on the command line, the first data
355 stream from the collection will be used. If you omit `--xccdf-id`, the
356 first component from the checklists element will be used. If you omit
357 both, the first data stream that has a component in the checklists
358 element will be used - the first component in its checklists element
359 will be used.
360
361 To evaluate a specific XCCDF benchmark that is part of an SCAP source data
362 stream use the following options:
363
364 ----
365 $ oscap xccdf eval --benchmark-id BENCHMARK_ID --results-arf ARF_XML SOURCE_DATA_STREAM_FILE
366 ----
367
368 Where:
369
370 * `SOURCE_DATA_STREAM_FILE` is a file representing the SCAP source data stream
371 * `BENCHMARK_ID` is the value of the "id" attribute of `<xccdf:Benchmark>`
372 containing component
373 * `ARF_FILE` is a file containing the scan results in a form of an SCAP
374 result data stream
375
376
377 === Evaluating Standalone OVAL Definitions
378
379 The SCAP document can have a form of a single OVAL file (an OVAL Definition
380 file). The `oscap` tool processes the OVAL Definition file during evaluation of
381 OVAL definitions. It collects system information, evaluates it and generates an
382 OVAL Result file. The result of evaluation of each OVAL definition is printed to
383 standard output stream. The following examples describe the most common
384 scenarios involving an OVAL Definition file.
385
386 To evaluate OVAL definitions within the given OVAL Definition file the
387 `oscap oval eval` command can be used. Its basic form is the following:
388
389 ----
390 $ oscap oval eval --results RESULTS_FILE OVAL_FILE
391 ----
392
393 Where:
394
395 * `OVAL_FILE` is the OVAL Definition file
396 * `RESULTS_FILE` is the path where OVAL Results file will be stored
397
398 It's possible to select and evaluate one particular definition
399 within the given OVAL Definition file using `--id` option:
400
401 ----
402 $ oscap oval eval --id oval:rhel:def:1000 --results oval-results.xml oval.xml
403 ----
404
405 Where the OVAL definition being evaluated has ID `oval:rhel:def:1000`,
406 `oval.xml` is the OVAL Definition file and `oval-results.xml` is the
407 OVAL Result file.
408
409 To evaluate all definitions from the OVAL component that are part of a
410 particular data stream component within a SCAP source data stream, run the
411 following command:
412
413 ----
414 $ oscap oval eval --datastream-id ds.xml --oval-id xccdf.xml --results oval-results.xml scap-ds.xml
415 ----
416
417 Where `ds.xml` is the ID of a specific data stream, `xccdf.xml` is an XCCDF file
418 specifying the OVAL component, `oval-results.xml` is the OVAL Result file, and
419 `scap-ds.xml` is the SCAP source data stream collection.
420
421 When the SCAP content is represented by multiple XML files, the OVAL
422 Definition file can be distributed along with the XCCDF file. In such a
423 situation, OVAL Definitions may depend on variables that are exported
424 from the XCCDF file during the scan, and separate evaluation of the OVAL
425 definition(s) would produce misleading results. Therefore, any external
426 variables has to be exported to a special file that is used during the
427 OVAL definitions evaluation. The following commands are examples of this
428 scenario:
429
430 ----
431 $ oscap xccdf export-oval-variables \
432 --profile united_states_government_configuration_baseline \
433 xccdf.xml
434 ----
435
436 ----
437 $ oscap oval eval \
438 --variables oval_variables.xml \
439 --results oval_results.xml
440 oval.xml
441 ----
442 Where *united_states_government_configuration_baseline* represents a
443 profile in the XCCDF document, *xccdf.xml* is a file
444 specifying the XCCDF document, *oval.xml* is the OVAL
445 Definition file, *oval_variables.xml* is the
446 file containing exported variables from the XCCDF file, and
447 *oval_results.xml* is the the OVAL Result file.
448
449 An OVAL directives file can be used to control whether results should be "thin" or "full".
450 This file can be loaded by OpenSCAP using *--directives <file>* option.
451
452 Example of an OVAL directive file which enables thin results instead of
453 full results:
454
455 ----
456 <?xml version="1.0" encoding="UTF-8"?>
457 <oval_directives
458 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
459 xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5"
460 xmlns:oval-res="http://oval.mitre.org/XMLSchema/oval-results-5"
461 xmlns="http://oval.mitre.org/XMLSchema/oval-directives-5"
462 xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-results-5
463 oval-results-schema.xsd http://oval.mitre.org/XMLSchema/oval-common-5
464 oval-common-schema.xsd http://oval.mitre.org/XMLSchema/oval-directives-5
465 oval-directives-schema.xsd">
466 <generator>
467 <oval:product_name>OpenSCAP</oval:product_name>
468 <!-- make sure the OVAL version matches your input -->
469 <oval:schema_version>5.8</oval:schema_version>
470 <oval:timestamp>2017-02-04T00:00:00</oval:timestamp>
471 </generator>
472 <directives include_source_definitions="true">
473 <oval-res:definition_true reported="true" content="thin"/>
474 <oval-res:definition_false reported="true" content="thin"/>
475 <oval-res:definition_unknown reported="true" content="thin"/>
476 <oval-res:definition_error reported="true" content="thin"/>
477 <oval-res:definition_not_evaluated reported="true" content="thin"/>
478 <oval-res:definition_not_applicable reported="true" content="thin"/>
479 </directives>
480 </oval_directives>
481 ----
482
483 If your use-case requires thin OVAL results you most likely also want
484 to omit system characteristics. You can use the `--without-syschar`
485 option to that effect.
486
487 Usage of OVAL directives file when scanning a plain OVAL file:
488
489 ----
490 $ oscap oval eval --directives directives.xml --without-syschar --results oval-results.xml oval.xml
491 ----
492
493 Usage of OVAL directives file when scanning OVAL component from a source data stream:
494
495 ----
496 $ oscap oval eval --directives directives.xml --without-syschar --datastream-id ds.xml --oval-id oval.xml --results oval-results.xml scap-ds.xml
497 ----
498
499 It is not always clear which OVAL file will be used when multiple files
500 are distributed. In case you are evaluating an XCCDF file you can use:
501
502 ----
503 $ oscap info ssg-rhel7-xccdf.xml
504 Document type: XCCDF Checklist
505 Checklist version: 1.1
506 Imported: 2017-01-20T14:20:43
507 Status: draft
508 Generated: 2017-01-19
509 Resolved: true
510 Profiles:
511 standard
512 pci-dss
513 C2S
514 rht-ccp
515 common
516 stig-rhel7-workstation-upstream
517 stig-rhel7-server-gui-upstream
518 stig-rhel7-server-upstream
519 stig-rhevh-upstream
520 ospp-rhel7-server
521 nist-cl-il-al
522 cjis-rhel7-server
523 docker-host
524 nist-800-171-cui
525 Referenced check files:
526 ssg-rhel7-oval.xml
527 system: http://oval.mitre.org/XMLSchema/oval-definitions-5
528 ssg-rhel7-ocil.xml
529 system: http://scap.nist.gov/schema/ocil/2
530 https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL7.xml.bz2
531 system: http://oval.mitre.org/XMLSchema/oval-definitions-5
532 ----
533
534 In the output you can see all referenced check files. In this case we see
535 that `ssg-rhel7-oval.xml` is referenced. To see contents of this file you
536 can open it in a text editor.
537
538 You can use `oscap info` with source data stream files as well. Source
539 data stream will often reference OVAL files that are bundled in it.
540
541
542 === Evaluating XCCDF
543
544 When evaluating an XCCDF benchmark, `oscap` usually processes an XCCDF
545 file, an OVAL file and the CPE dictionary. It performs system
546 analysis and produces XCCDF results based on this analysis. The results
547 of the scan do not have to be saved in a separate file but can be
548 attached to the XCCDF file. The evaluation result of each XCCDF rule
549 within an XCCDF checklist is printed to standard output stream. The CVE
550 and CCE identifiers associated with the rules are printed as well. The
551 following is a sample output for a single XCCDF rule:
552
553 ----
554 Title Verify permissions on 'group' file
555 Rule usgcb-rhel5desktop-rule-2.2.3.1.j
556 Ident CCE-3967-7
557 Result pass
558 ----
559
560 The meaning of results is defined by https://csrc.nist.gov/CSRC/media/Publications/nistir/7275/rev-4/final/documents/nistir-7275r4_updated-march-2012_clean.pdf[XCCDF Specification].
561 This table lists the possible results of a single rule:
562
563 .XCCDF results
564 |===
565 |Result |Description |Example Situation
566
567 |pass
568 |The target system or system component satisfied all the conditions of the rule.
569 |
570
571 |fail
572 |The target system or system component did not satisfy all the conditions of the rule.
573 |
574
575 |error
576 |The checking engine could not complete the evaluation, therefore the status of the target’s compliance with the rule is not certain.
577 |OpenSCAP was run with insufficient privileges and could not gather all of the necessary information.
578
579 |unknown
580 |The testing tool encountered some problem and the result is unknown.
581 |OpenSCAP was unable to interpret the output of the checking engine (the output has no meaning to OpenSCAP).
582
583 |notapplicable
584 |The rule was not applicable to the target of the test.
585 |The rule might have been specific to a different version of the target OS, or it might have been a test against a platform feature that was not installed.
586
587 |notchecked
588 |The rule was not evaluated by the checking engine. This status is designed for rules that have no <xccdf:check> elements or that correspond to an unsupported checking system. It may also correspond to a status returned by a checking engine if the checking engine does not support the indicated check code.
589 |The rule does not reference any OVAL check.
590
591 |notselected
592 |The rule was not selected in the benchmark. OpenSCAP does not display rules that were not selected.
593 |The rule exists in the benchmark, but is not a part of selected profile.
594
595 |informational
596 |The rule was checked, but the output from the checking engine is simply information for auditors or administrators; it is not a compliance category. This status value is designed for rules whose main purpose is to extract information from the target rather than test the target.
597 |
598
599 |fixed
600 |The rule had initially evaluated to "fail", but was then fixed by automated remediation and therefore it now evaluates as "pass".
601 |
602 |===
603
604 The CPE dictionary is used to determine whether the content is
605 applicable on the target platform or not. Any content that is not
606 applicable will result in each relevant XCCDF rule being evaluated to
607 "notapplicable".
608
609 The following examples show the most common scenarios of XCCDF benchmark
610 evaluation:
611
612 * To evaluate a specific profile in an XCCDF file run this command:
613
614 ----
615 $ oscap xccdf eval --profile Desktop --results xccdf-results.xml --cpe cpe-dictionary.xml scap-xccdf.xml
616 ----
617
618 Where `scap-xccdf.xml` is the XCCDF document, `Desktop` is the selected
619 profile from the XCCDF document, `xccdf-results.xml` is a file storing
620 the scan results, and `cpe-dictionary.xml` is the CPE dictionary.
621
622 * You can additionally add `--rule` option to the above command to evaluate
623 a specific rule:
624
625 ----
626 $ oscap xccdf eval --profile Desktop --rule ensure_gpgcheck_globally_activated --results xccdf-results.xml --cpe cpe-dictionary.xml scap-xccdf.xml
627 ----
628
629 Where `ensure_gpgcheck_globally_activated` is the only rule from the `Desktop`
630 profile which will be evaluated.
631
632 The `--rule` option can be used multiple times to evaluate multiple rules at once.
633
634 * You can skip some rules by using the `--skip-rule` option.
635
636 In the examples above we are generating XCCDF result files using the `--results`
637 command-line argument. You can use `--results-arf` to generate an SCAP result
638 data stream (also called ARF - Asset Reporting Format) XML instead.
639
640 ----
641 $ oscap xccdf eval --benchmark-id benchmark_id --results-arf arf-results.xml scap-ds.xml
642 ----
643
644 === Generating results compatible with STIG Viewer
645
646 DISA STIG Viewer is a graphical user interface (GUI) application that enables
647 easy viewing of SCAP-formatted Security Technical Implementation Guides
648 (STIGs). For more information on DISA STIG Viewer see the
649 https://public.cyber.mil/stigs/srg-stig-tools/[SRG / STIG Tools] website.
650
651 OpenSCAP can generate results compatible with STIG Viewer even when evaluating
652 SCAP content that uses different rule IDs than the official DISA STIG format,
653 for example, content from the `scap-security-guide` package or third-party
654 content.
655
656 To produce results compatible with STIG Viewer, each rule in an SCAP source data
657 stream must contain a reference to a STIG Rule ID, and the value of the `href`
658 attribute must be either
659 `http://iase.disa.mil/stigs/Pages/stig-viewing-guidance.aspx` or
660 `https://public.cyber.mil/stigs/srg-stig-tools/`.
661
662 For example:
663 ----
664 <Rule id="rpm_verify_permissions">
665 ...
666 <reference href="https://public.cyber.mil/stigs/srg-stig-tools/">SV-86473r2_rule</reference>
667 ...
668 </Rule>
669 ----
670
671 In the following example, we use the
672 `/usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml` file provided by the
673 `scap-security-guide` RPM package. This data stream file meets both
674 prerequisites for rules.
675
676 1) Scan your system using the `oscap` command with the `--stig-viewer` option.
677
678 ----
679 $ oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_stig --stig-viewer results-stig.xml /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
680 ----
681
682 2) Download a STIG file of your choice, for example, from the
683 https://public.cyber.mil/stigs/downloads/[STIGs Document Library], and extract
684 it. The version of the STIG must conform to the version of the
685 `xccdf_org.ssgproject.content_profile_stig` profile.
686
687 3) In STIG Viewer, click on `File` and then on `Import STIG`. Then, select the
688 STIG in `STIGs` panel on the left side. Click on `Checklists` and then on
689 `Create Checklists - Check Marked STIG(s)`.
690
691 4) Import the OpenSCAP scan results by clicking on `Import` and then on `XCCDF
692 Results File`. Locate the `results-stig.xml` file obtained in step 1. STIG
693 Viewer shows the results subsequently.
694
695 NOTE: The `--stig-viewer` option serves for evaluating an SCAP source data stream
696 other than a STIG provided by DISA, for example, `scap-security-guide` content
697 and loading the generated file in STIG Viewer into a checklist created from a
698 STIG by DISA. When evaluating a STIG provided by DISA using `oscap`, use the
699 `--results` option instead. Similarly, when creating checklists based on
700 `scap-security-guide` content in STIG Viewer and evaluating
701 `scap-security-guide` by oscap, use `--results` instead of `--stig-viewer`.
702
703 === Checking for compliance with a particular requirement coverage
704
705 A common theme is to check system status based on requirements of a particular policy.
706 OpenSCAP can select rules that are related to a specific requirement based on the references in the rules.
707
708 1) List references that are supported in your scap content using the `oscap info --references` command.
709 This will list of available reference names and their URIs.
710 For example:
711
712 ----
713 $ oscap info --references /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
714 ... snip ...
715 References:
716 anssi: http://www.ssi.gouv.fr/administration/bonnes-pratiques/
717 cis: https://www.cisecurity.org/benchmark/red_hat_linux/
718 disa: https://public.cyber.mil/stigs/cci/
719 ... snip ...
720 ----
721
722 2) Run the evaluation with the `--reference` option, using the name obtained in the previous step and the requirement ID, separated by a colon.
723 That will filter the list of rules so that only rules that have the given reference ID assigned would be evaluated.
724 For example:
725
726 ----
727 $ oscap xccdf eval --profile cis --reference cis:3.3.2 /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
728 ----
729
730 NOTE: If the `oscap info --references` command doesn't list any reference names in the `References` section of its output, it means that the provided SCAP content doesn't support this feature.
731
732 == Remediating system
733
734 OpenSCAP allows one to automatically remediate systems that have been found in a
735 non-compliant state. For system remediation the rules in SCAP content need to
736 have a remediation script attached. For example, the SCAP source data streams in
737 the `scap-security-guide` package contain rules with remediation fix scripts.
738
739 System remediation consists of the following steps:
740
741 . The `oscap` command performs a regular XCCDF evaluation.
742 . An assessment of the results is performed by evaluating the OVAL definitions.
743 Each rule that has failed is marked as a candidate for remediation.
744 . The `oscap` program searches for an appropriate `<xccdf:fix>` element,
745 resolves it, prepares the environment, and executes the fix script.
746 . Any output of the fix script is captured by `oscap` and stored within the
747 `<xccdf:rule-result>` element. The return value of the fix script is stored as
748 well.
749 . Whenever `oscap` executes a fix script, it immediately evaluates the OVAL
750 definition again (to verify that the fix script has been applied correctly).
751 During this second run, if the OVAL evaluation returns success, the result of
752 the rule is *fixed*, otherwise it is an *error*.
753 . Detailed results of the remediation are stored in an output XCCDF file. It
754 contains two `<xccdf:TestResult>` elements. The first `<xccdf:TestResult>`
755 element represents the scan prior to the remediation. The second
756 `<xccdf:TestResult>` is derived from the first one and contains remediation
757 results.
758
759 There are three modes of operation of `oscap` with regard to remediation:
760 online, offline, and review.
761
762 === Remediation during scanning
763
764 The remediation scripts can be executed at the time of scanning. Evaluation and
765 remediation are performed as a part of a single command.
766
767 To enable remediation during scanning, use the `oscap xccdf eval` command with
768 the `--remediate` command-line option.
769
770 In this example we will execute remediation during evaluation of the OSPP profile:
771
772 ----
773 # oscap xccdf eval --remediate --profile xccdf_org.ssgproject.content_profile_ospp --results-arf results.xml /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
774 ----
775
776 The output of this command consists of two sections. The first section shows the
777 result of the scan prior to the remediation, and the second section shows the
778 result of the scan after applying the remediation. The second part can contain
779 only *fixed* and *error* results. The *fixed* result indicates that the scan performed
780 after the remediation passed. The *error* result indicates that even after
781 applying the remediation, the evaluation still does not pass.
782
783 === Remediation after scanning
784
785 This feature allows you to postpone fix execution.
786
787 In first step, the system is only evaluated, and the results are stored in the
788 `<xccdf:TestResult>` element in an XCCDF results file.
789
790 In the second step, `oscap` executes the fix scripts and verifies the result. It
791 is safe to store the results into the input file, no data will be lost. During
792 offline remediation, a new `<xccdf:TestResult>` element is created that is based
793 on the input one and inherits all the data. The newly created
794 `<xccdf:TestResult>` differs only in the `<xccdf:rule-result>` elements that
795 have failed. For those, remediation is executed.
796
797
798 For example:
799 ----
800 # oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_ospp --results results.xml /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
801 ----
802
803 ----
804 # oscap xccdf remediate --results remediation-results.xml results.xml
805 ----
806
807 === Reviewing remediations
808
809 The review mode allows users to store remediation instructions to a file for
810 further review. The remediation content is not executed during this operation.
811 To generate remediation instructions in the form of a shell script, run:
812
813 . Run a scan and generate XCCDF results file using the `--results` option.
814 +
815 ----
816 # oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_ospp --results results.xml /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
817 ----
818 +
819 . Obtain the results ID.
820 +
821 ----
822 $ oscap info results.xml
823 ----
824 +
825 . Generate the fix based on the scan results.
826 +
827 ----
828 # oscap xccdf generate fix --fix-type bash --output my-remediation-script.sh --result-id xccdf_org.open-scap_testresult_xccdf_org.ssgproject.content_profile_ospp results.xml
829 ----
830
831
832 == Tailoring
833
834 This section describes tailoring of content using a tailoring file.
835 Tailoring allows you to change behavior of SCAP content without its direct modification.
836
837 === Creating Tailoring files
838
839 Tailoring files can be easily created using {workbench_url}[SCAP Workbench] which is a GUI application.
840
841 On the command line, tailoring files can be created using the `autotailor` tool.
842 This tool is a part of the `openscap-utils` package.
843
844 The basic syntax is:
845
846 ----
847 $ autotailor \
848 --select RULE_ID --unselect RULE_ID --var-value VAR=VALUE \
849 --output TAILORING_FILE --new_profile_id NEW_PROFILE_ID
850 DS_FILENAME BASE_PROFILE_ID
851 ----
852
853 Where:
854
855 * `--select RULE_ID` adds a rule with `RULE_ID`. This argument can be
856 added multiple times if needed.
857 * `--unselect RULE_ID` adds a rule with `RULE_ID`. This argument can be
858 added multiple times if needed.
859 * `--var-value VAR=VALUE` specifies modification of the XCCDF value in the
860 form `<varname>=<value>`
861 * `TAILORING_FILE` is a path to the file that will be created
862 * `NEW_PROFILE_ID` is the ID of the customized profile
863 * `DS_FILENAME` is the path to SCAP source data stream that is tailored
864 * `BASE_PROFILE_ID` is the original profile that we want to customize
865
866 The script creates a new file with a new profile with ID in a form `BASE_PROFILE_ID_customized`.
867
868 In the following example, we will create a customized profile with ID `custom` based on the OSPP profile from the SCAP Security Guide for Red Hat Enterprise Linux 8 (located in `/usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml` which is provided by the `scap-security-guide` RPM package) which will remove the rule `service_usbguard_enabled` and save it as a XCCDF Tailoring file into `/tmp/tailoring.xml`.
869
870 ----
871 $ autotailor --unselect service_usbguard_enabled --output /tmp/tailoring.xml \
872 --new-profile-id custom /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml ospp
873 ----
874
875 The `autotailor` tool can also consume {json_tailoring_url}[JSON tailoring] files and convert them into XCCDF Tailoring.
876
877 ----
878 $ autotailor --json-tailoring custom.json /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
879 ----
880
881 For more details about other options of the `autotailor` program please read the `autotailor(8)` man page or run `autotailor --help`.
882
883
884 === Using Tailoring files
885
886 . List profiles in the tailoring file
887 +
888 ----
889 $ oscap info ssg-rhel8-ds-tailoring.xml
890 Document type: XCCDF Tailoring
891 Imported: 2016-08-31T11:08:16
892 Benchmark Hint: /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
893 Profiles:
894 xccdf_org.ssgproject.content_profile_C2S_customized
895 ----
896 +
897 . Run a scan. The command evaluates tailored data stream by
898 `ssg-rhel8-ds-tailoring.xml` tailoring file. XCCDF results can be found in
899 `results.xml` file.
900 +
901 ----
902 $ oscap xccdf eval \
903 --profile xccdf_org.ssgproject.content_profile_C2S_customized \
904 --tailoring-file ssg-rhel8-ds-tailoring.xml \
905 --results results.xml
906 /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
907 ----
908
909 WARNING: Use the ID of the customized profile (from the tailoring file), do not
910 use the ID of the original profile.
911
912
913 Instead of external tailoring file, you can also use tailoring component
914 integrated to data stream.
915
916 ----
917 $ oscap info simple-ds.xml
918
919 Document type: Source Data Stream
920 Imported: 2016-02-02T14:06:14
921
922 Stream: scap_org.open-scap_datastream_from_xccdf_simple-xccdf.xml
923 Generated: (null)
924 Version: 1.2
925 Checklists:
926 Ref-Id: scap_org.open-scap_cref_simple-xccdf.xml
927 Status: incomplete
928 Resolved: false
929 Profiles:
930 xccdf_org.open-scap_profile_override
931 Referenced check files:
932 simple-oval.xml
933 system: http://oval.mitre.org/XMLSchema/oval-definitions-5
934 Ref-Id: scap_org.open-scap_cref_simple-tailoring.xml
935 Benchmark Hint: (null)
936 Profiles:
937 xccdf_org.open-scap_profile_default
938 xccdf_org.open-scap_profile_unselecting
939 xccdf_org.open-scap_profile_override
940 Checks:
941 Ref-Id: scap_org.open-scap_cref_simple-oval.xml
942 No dictionaries.
943 ----
944
945 To choose tailoring component `scap_org.open-scap_cref_simple-tailoring.xml`,
946 the command below can be used.
947
948 ----
949 $ oscap xccdf eval \
950 --tailoring-id scap_org.open-scap_cref_simple-tailoring.xml \
951 --profile xccdf_org.open-scap_profile_default \
952 --results results.xml simple-ds.xml
953 ----
954
955 The command above evaluates content using tailoring component
956 `scap_org.open-scap_cref_simple-tailoring.xml` from source data stream. Scan
957 results are stored in `results.xml` file.
958
959
960 == Scanning with Script Check Engine (SCE)
961
962 The Script Check Engine (SCE) is an alternative check engine for XCCDF checklist
963 evaluation. SCE allows you to call shell scripts out of the XCCDF document.
964 This approach might be suitable for various use cases, mostly when OVAL checks
965 are not required. More information about SCE usage is available on this page:
966 {sce_web}[Using SCE].
967
968 WARNING: SCE is not part of any SCAP specification.
969
970
971 == Validating SCAP Content
972
973 The `oscap` tool can be used to validate the security content
974 against standard SCAP XML schemas. The validation results are printed to the
975 standard error stream (stderr). The general syntax of the validation command
976 is the following:
977
978 ----
979 $ oscap module validate [module_options_and_arguments] FILE
980 ----
981
982 where `FILE` is the full path to the file being validated. As a `module` you
983 can use:
984
985 * xccdf,
986 * oval,
987 * cpe or
988 * cve.
989
990 The only exception is the data stream module (ds), which uses the sds-validate
991 operation instead of validate. So for example, it would be like:
992
993 ----
994 $ oscap ds sds-validate scap-ds.xml
995 ----
996
997 NOTE: Note that all SCAP components within the given data stream are validated
998 automatically and none of the components is specified separately.
999
1000 There is an extra Schematron-based validation enabled when you validate OVAL or
1001 XCCDF specification. This validation method is slower but it provides deeper analysis.
1002
1003 Run one of the following commands to validate an OVAL or XCCDF document without
1004 Schematron checks:
1005
1006 ----
1007 $ oscap xccdf validate --skip-schematron xccdf-file.xml
1008 ----
1009
1010 ----
1011 $ oscap oval validate --skip-schematron oval-file.xml
1012 ----
1013
1014 The results of validation are printed to standard error stream (stderr).
1015
1016 NOTE: Please note that for the rest of `oscap` functionality, unless you specify
1017 `--skip-validation`, validation will automatically occur before
1018 files are used. Therefore, you do not need to explicitly validate a data stream
1019 before use. Though it will not include the Schematron-based validation step.
1020
1021 === Validating digital signature in SCAP source data stream
1022
1023 When evaluating a digitally signed SCAP source data stream OpenSCAP validates
1024 the digital signature of the data stream. The signature validation is performed
1025 automatically while loading the file. Data streams with invalid signatures would
1026 be rejected and would not be evaluated. OpenSCAP uses
1027 https://www.aleksey.com/xmlsec/[XML Security Library] with OpenSSL backend to
1028 validate the digital signature.
1029
1030 The signature validation only checks that the datastream hasn't been altered
1031 since its latest signature. OpenSCAP doesn't address trustworthiness of
1032 certificates or public keys that are part of the `KeyInfo` signature element and
1033 that are used to verify the signature. You should verify those keys yourself to
1034 prevent evaluation of datastreams that have been modified and signed by bad
1035 actors.
1036
1037 The signature validation can be skipped by adding the
1038 `--skip-signature-validation` option to the `oscap xccdf eval` command.
1039
1040 Also, signature validation can be enforced (effectively rendering all unsigned
1041 data streams invalid) with the `--enforce-signature` option to the `oscap xccdf eval` command.
1042
1043 == Generating reports, guides and scripts
1044
1045 Another useful features of `oscap` is the ability to generate documents in a
1046 human-readable HTML format. This feature is used to generate security guides and
1047 checklists, which serve as a source of information, as well as guidance for
1048 secure system configuration. The results of system scans can also be transformed
1049 to well-readable result reports. Moreover, remediation scripts and Ansible
1050 playbooks can be generated if the SCAP content contains these data.
1051
1052 The general command syntax is the following:
1053
1054 ----
1055 oscap module generate sub-module [specific_module/sub-module_options_and_arguments] file
1056 ----
1057
1058 Where module is either `xccdf` or `oval`, `sub-module` is a type of
1059 the generated document, and file represents an XCCDF or OVAL file. A sub-module
1060 can be either `report`, `guide`, `custom` or `fix`. Please see
1061 `man oscap` for more details.
1062
1063
1064 === Generating HTML guides
1065
1066 To generate a HTML guide from an SCAP source data stream or an XCCDF file use the `oscap xccdf generate guide` command.
1067
1068 Generating a guide with profile checklist (see an
1069 https://static.open-scap.org/examples/guide-checklist.html[example]):
1070
1071 ----
1072 $ oscap xccdf generate guide --profile xccdf_org.ssgproject.content_profile_ospp /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml > guide.html
1073 ----
1074
1075 === Generating HTML reports
1076
1077 To generate HTML scan reports after scan from the scan results in ARF or XCCDF
1078 format the `oscap xccdf generate report` command can be used.
1079
1080 Generating the HTML report with information about checks (see an
1081 https://static.open-scap.org/examples/report-xccdf-oval.html[example]):
1082
1083 ----
1084 $ oscap xccdf generate report arf.xml > report.html
1085 ----
1086
1087 TIP: The HTML report can be generated also during scan by adding the `--report`
1088 option to the `oscap xccdf eval` command.
1089
1090 === Generating bash scripts
1091
1092 To generate a bash remediation script from an XCCDF profile, use the `oscap
1093 xccdf generate fix` command. OpenSCAP will extract remediation scripts for all
1094 rules in the given profile to a file.
1095
1096 For example, to generate a bash remediation script for RHEL 8 OSPP profile, run:
1097
1098 ----
1099 $ oscap xccdf generate fix --profile ospp /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml > fix.sh
1100 ----
1101
1102 The output contains fixes for all rules in the given profile including those
1103 rules that would pass. It's because system isn't scanned during this command. If
1104 you want to generate remediation only for the failed rules based on scan
1105 results, refer to <<_reviewing_remediations,Reviewing remediations>>.
1106
1107 === Generating Ansible Playbooks
1108
1109 Similar to generating bash scripts, OpenSCAP is able to extract Ansible tasks
1110 associated with XCCDF rules and generate an Ansible Playbook that can be used to
1111 configure the operating system according to the given profile. To generate
1112 Anisble Playbook use the `oscap xccdf generate fix` command with `--fix-type
1113 ansible` option.
1114
1115 For example, to generate Ansible Playbook from RHEL 8 OSPP profile, run:
1116
1117 ----
1118 $ oscap xccdf generate fix --profile ospp --fix-type ansible /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml > playbook.yml
1119 ----
1120
1121 The generated Ansible Playbook is generated from an OpenSCAP profile without
1122 preliminary evaluation. It attempts to fix every selected rule, even if the
1123 system is already compliant. The output contains fixes for all rules in the
1124 given profile including those rules that would pass. It's because system isn't
1125 scanned during this command. If you want to generate remediation only for the
1126 failed rules based on scan results, refer to <<_reviewing_remediations,Reviewing
1127 remediations>>.
1128
1129 === Generating Image Builder Blueprints
1130
1131 OpenSCAP can also create a remediation in form of Image Builder (OSBuild) Blueprint. This remeditaion
1132 is intendeded to be used as a bootstrap for image creation and usually it will contain only essential
1133 elements of the configuration, elements that would be hard or impossible to change after the image
1134 is created, like partitioning or set of installed packages.
1135
1136 It is recommended to combine this type of remediation with other types, executed on the running system.
1137
1138 For example, to generate a blueprint remediation for RHEL 8 OSPP profile, run:
1139
1140 ----
1141 $ oscap xccdf generate fix --profile ospp --fix-type blueprint /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml > blueprint.toml
1142 ----
1143
1144 === Generating RHEL Kickstarts
1145
1146 OpenSCAP can generate RHEL kickstarts which can be used for unattended installation of RHEL, Fedora and similar systems.
1147 Information about RHEL kickstarts and their syntax can be found at https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/performing_an_advanced_rhel_9_installation/kickstart_references[Kickstart references] and https://pykickstart.readthedocs.io/en/latest/kickstart-docs.html[Kickstart Documentation].
1148
1149 To generate a kickstart, use `oscap xccdf generate fix` command with the `--fix-type kickstart` option.
1150
1151 The kickstart will be generated from kickstart snippets in XCCDF rules in the input SCAP content.
1152 The kickstart snippets need to be present in `<fix>` elements with `system` attribute set to `urn:xccdf:fix:script:kickstart`.
1153
1154 When processing the kickstart snippets from the XCCDF Rules, each line is processed separately.
1155 If a line starts with a supported block keyword, that line and all following lines until a line starting with `%end` are considered a block.
1156 Blocks are propagated to the output without any processing.
1157 If a line isn't part of a block, the following rules are applied:
1158
1159 * Lines starting with `#` are ignored.
1160 * Empty lines are ignored.
1161 * Lines starting with a supported command are processed.
1162 * Lines starting with something else than a supported command are dropped and error is produced.
1163 * Excess whitespace are trimmed.
1164
1165 Supported block keywords:
1166
1167 * `%pre` - represents a start of a `%pre` kickstart section, all lines until corresponding '%end' are overthrown
1168 * `%post` - represents a start of a `%post` kickstart section, all lines until corresponding '%end' are overthrown
1169
1170 Supported commands:
1171
1172 * `package install package_name` - adds `package_name` to `%packages` section in the kickstart
1173 * `package remove package_name` - adds `-package_name` to `%packages` section in the kickstart
1174 * `service enable service_name` - adds `service_name` to list in the `--enabled=` option in the `services` command in commands section in the kickstart
1175 * `service disable service_name` - adds `service_name` to list in the `--disabled=` option in the `services` command in commands section in the kickstart
1176 * `logvol path size` - adds `logvol` entry to the commands section of the kickstart that will mount a partition of the given `size` in MB to the given `path` as a mount point
1177 * `bootloader option` or `bootloader option=value` - adds `option` or `option=value` to the list in the `--append=` option in the `bootloader` command in commands section in the kickstart
1178 * `kdump disable` - this will disable K-Dump by adding the `com_redhat_kdump` Addon section to the kickstart with a `--disable` option
1179 * `firewall enable service_name` - adds `service_name` to list in the `--service=` option in the `firewall` command in commands section in the kickstart
1180 * `firewall disable service_name` - adds `service_name` to list in the `--remove-service=` option in the `firewall` command in commands section in the kickstart
1181
1182 For example, to generate a kickstart for RHEL 9 STIG profile, run:
1183
1184 ----
1185 $ oscap xccdf generate fix --profile stig --fix-type kickstart /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml > rhel9-kickstart-stig.cfg
1186 ----
1187
1188 The generated kickstart file needs to be reviewed and customized for the intended deployment.
1189 The kickstart sets some default values to makte automated installation possible.
1190 These default values are usually good enough but sometimes need to be changed manually.
1191 Pay special attention to the items marked as `required for security compliance`.
1192
1193 NOTE: The `kickstart` fix type shouldn't be confused with `anaconda` fix type.
1194 The `anaconda` fix type is used by the OSCAP Anaconda Addon and shouldn't be used directly by users.
1195 Users should use the `kickstart` fix type.
1196
1197 == Details on SCAP conformance
1198
1199 === Check Engines
1200
1201 Most XCCDF content uses the OVAL check engine. This is when OVAL
1202 Definitions are being evaluated in order to assess a system. Complete
1203 information of an evaluation is recorded in OVAL Results files, as
1204 defined by the OVAL specification. By examining these files it's
1205 possible check what definitions were used for the evaluation and why the
1206 results are as they are. Please note these files are not generated
1207 unless `--oval-results` is used.
1208
1209 Some content may use alternative check engines, for example the
1210 {sce_web}[SCE] check engine.
1211
1212 Results of rules with a check that requires a check engine not supported
1213 by OpenSCAP will be reported as *notchecked*. Check contents are not
1214 read or interpreted in any way unless the check system is known and
1215 supported. Following is an evaluation output of an XCCDF with unknown
1216 check system:
1217
1218 ----
1219 $ oscap xccdf eval sds-datastream.xml
1220
1221 Title Check group file contents
1222 Rule xccdf_org.example_rule_system_authcontent-group
1223 Result notchecked
1224
1225 Title Check password file contents
1226 Rule xccdf_org.example_rule_system_authcontent-passwd
1227 Result notchecked
1228
1229 Title Check shadow file contents
1230 Rule xccdf_org.example_rule_system_authcontent-shadow
1231 Result notchecked
1232
1233 ...
1234 ----
1235
1236 NOTE: The *notchecked* result is also reported for rules that have no
1237 check implemented. *notchecked* means that there was no check in that
1238 particular rule that could be evaluated.
1239
1240
1241 === CVE, CCE, CPE and other identifiers
1242
1243 Each XCCDF Rule can have `<xccdf:ident>` elements inside. These elements
1244 allow the content creator to reference various external identifiers like
1245 CVE, CCE, CPE and others.
1246
1247 When scanning, `oscap` outputs identifiers of scanned rules regardless of
1248 their results. For example:
1249
1250 ----
1251 Title Ensure Repodata Signature Checking is Not Disabled For Any Repos
1252 Rule rule-2.1.2.3.6.a
1253 Result pass
1254
1255 Title Verify user who owns 'shadow' file
1256 Rule rule-2.2.3.1.a
1257 Ident CCE-3918-0
1258 Result pass
1259
1260 Title Verify group who owns 'shadow' file
1261 Rule rule-2.2.3.1.b
1262 Ident CCE-3988-3
1263 Result pass
1264 ----
1265
1266 All identifiers (if any) are printed to stdout for each rule. Since
1267 standard output doesn't allow for compact identifier metadata to be
1268 displayed, only the identifiers themselves are displayed there.
1269
1270 Identifiers are also part of the HTML report output. If the identifier
1271 is a CVE you can click it to display its metadata from the official NVD
1272 database (requires internet connection). OpenSCAP doesn't provide
1273 metadata for other types of identifiers.
1274
1275 Another place where these identifiers can be found are machine-readable SCAP
1276 result data stream (ARF) files. This file can be generated during the scan by
1277 adding `--results-arf` option.
1278
1279 ----
1280 $ oscap xccdf eval \
1281 --profile xccdf_org.ssgproject.content_profile_common \
1282 --fetch-remote-resources --results-arf results.xml \
1283 /usr/share/xml/scap/ssg/content/ssg-rhel6-ds.xml
1284 ----
1285
1286 Result data stream file `results.xml` contains these identifiers in `<xccdf:rule-result>`
1287 elements.
1288
1289 ----
1290 <rule-result
1291 idref="xccdf_org.ssgproject.content_rule_partition_for_tmp"
1292 time="2017-01-20T14:30:18" severity="low" weight="1.000000">
1293 <result>pass</result>
1294 <ident system="https://nvd.nist.gov/cce/index.cfm">CCE-27173-4</ident>
1295 <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
1296 <check-content-ref name="oval:ssg-partition_for_tmp:def:1" href="#oval0"/>
1297 </check>
1298 </rule-result>
1299 ----
1300
1301 Since OpenSCAP 1.2.9 you can use the Group-By feature of HTML report
1302 to get an overview of results based on their identifiers and references.
1303
1304 The HTML report can also be used to look-up Rules by their identifiers.
1305 You can type the identifier (e.g.: CCE-27173-4) in the search box in
1306 the HTML report and only rules with this identifier will be shown.
1307 This can be used for any type of XCCDF identifier or reference.
1308 You can also click on the rule title to show more details and see all
1309 its identifiers, including the identifier you looked for.
1310 This relies heavily on SCAP content quality, if the identifiers are
1311 not present in the source content they will not be available in the
1312 HTML report.
1313
1314 If you want to map two identifiers -- e.g.: map CCE identifier to
1315 NIST 800-53 identifier -- you need to look-up the CCE ID in the
1316 HTML report through the search box using the first identifier. And then,
1317 by grouping by NIST SP 800-53 ID, you can see all NIST 800-53 IDs
1318 related to the searched CCE ID.
1319
1320
1321 === Bundled CCE data
1322
1323 OpenSCAP does not provide any static or product bundled CCE data. Thus
1324 it has no way of displaying the last generated, updated and officially
1325 published dates of static or product bundled CCE data because the dates
1326 are not defined.
1327
1328
1329 === CPE applicability
1330
1331 XCCDF rules in the content may target only specific platforms and hold
1332 no meaning on other platforms. Such an XCCDF rule contains an
1333 `<xccdf:platform>`` element in its body. This element references a CPE
1334 name or CPE2 platform (defined using `<cpe2:platform-specification>`)
1335 that could be defined in a CPE dictionary file or a CPE language file
1336 or it can also be embedded directly in the XCCDF document.
1337
1338 An XCCDF rule can contain multiple `<xccdf:platform>` elements. It is
1339 deemed applicable if at least one of the listed platforms is applicable.
1340 If an XCCDF rule contains no `<xccdf:platform>` elements it is considered
1341 always applicable.
1342
1343 If the CPE name or CPE2 platform is defined in an external file, use the
1344 `--cpe` option and `oscap` auto-detects format of the file. The following
1345 command is an example of the XCCDF content evaluation using CPE name
1346 from an external file:
1347
1348 ----
1349 $ oscap xccdf eval --results xccdf-results.xml --cpe external-cpe-file.xml xccdf-file.xml
1350 ----
1351
1352 Where `xccdf-file.xml` is the XCCDF document, `xccdf-results.xml` is a file
1353 containing the scan results, and `external-cpe-file.xml` is the CPE
1354 dictionary or a language file.
1355
1356 If you are evaluating a source data stream, `oscap` automatically
1357 registers all CPEs contained within the data stream. No extra steps have
1358 to be taken. You can also register an additional external CPE file, as
1359 shown by the command below:
1360
1361 ----
1362 $ oscap xccdf eval --datastream-id ds.xml --xccdf-id xccdf.xml --results xccdf-results.xml --cpe additional-external-cpe.xml scap-ds.xml
1363 ----
1364
1365 Where `scap-ds.xml` is a file representing the SCAP data stream
1366 collection, `ds.xml` is the particular data stream, `xccdf.xml` is the
1367 XCCDF document, `xccdf-results.xml` is a file containing the scan
1368 results, and `additional-external-cpe.xml` is the additional CPE
1369 dictionary or language file.
1370
1371 The `oscap` tool will use an OVAL file attached to the CPE dictionary to
1372 determine applicability of any CPE name in the dictionary.
1373
1374 Apart from the instructions above, no extra steps have to be taken for
1375 content using `<cpe:fact-ref>` or `<cpe2:fact-ref>`. See the following
1376 sections for details on resolving.
1377
1378 ==== xccdf:platform applicability resolution
1379
1380 When a CPE name or language model platform is referenced via
1381 `<xccdf:platform>` elements, resolution happens in the following order:
1382
1383 . Look into embedded CPE2 language model if name is found and applicable deem
1384 it applicable
1385 . If not found or not applicable, look into external CPE2 language models
1386 (order of registration)
1387 . If not found or not applicable, look into embedded CPE dictionary
1388 . If not found or not applicable, look into external CPE dictionaries (order of
1389 registration)
1390
1391 If the CPE name is not found in any of the sources, it is deemed not
1392 applicable. If it is found in any of the sources but not applicable, we
1393 look for it elsewhere.
1394
1395 ==== cpe:fact-ref and cpe2:fact-ref resolution
1396
1397 CPE name referenced from within `fact-ref` is resolved in the following
1398 order:
1399
1400 . Look into embedded CPE dictionary, if name is found and applicable
1401 deem it applicable
1402 . If not found or not applicable, look into external CPE dictionaries
1403 (order of registration)
1404
1405 === Notes on the Concept of Multiple OVAL Values
1406
1407 This section describes advanced concepts of OVAL Variables and their
1408 implementation in `oscap`. The SCAP specification allows for an OVAL
1409 variable to have multiple values during a single assessment run. There
1410 are two variable modes which can be combined:
1411
1412 * Multival -- A variable is assigned with multiple values at the same
1413 time. As an example, consider a variable which refers to preferred
1414 permission of a given file, that may take multiple values like: '600',
1415 '400'. The evaluation tries to match each (or all) and then outputs a
1416 single OVAL Definition result.
1417 * Multiset -- A variable is assigned with a different value (or
1418 multival) for different evaluations. This is known as a
1419 *variable_instance*. As an example consider an OVAL definition which
1420 checks that a package given by a variable is not installed. For the first
1421 evaluation of the definition, the variable can be assigned with
1422 'telnet-server' value, for second time the variable can be assigned with
1423 'tftp-server' value. Therefore both evaluations may output different
1424 results. Thus, the OVAL Results file may contain multiple results for
1425 the same definition, these are distinguished by *variable_instance*
1426 attribute.
1427
1428 These two concepts are a source of confusion for both the content
1429 authors and the result consumers. On one hand, the first concept is well
1430 supported by the standard and the OVAL Variable file format. It allows
1431 multiple *<value>* elements for each *<variable>* element. On the other
1432 hand, the second concept is not supported by an OVAL Variable schema
1433 which prevents fully automated evaluation of the multisets (unless you
1434 use XCCDF to bridge that gap).
1435
1436 TIP: `oscap` supports both variable modes as described below.
1437
1438 ==== Sources of Variable Values
1439
1440 First we need to understand how a single value can be bound to a
1441 variable in the OVAL checking engine. There are three ways to do this:
1442
1443 1) OVAL Variables File -- The values of external variables can be
1444 defined in an external file. Such a file is called an OVAL Variable File
1445 and can be recognized by using the following command: `oscap info
1446 file.xml`. The OVAL Variables file can be passed to the evaluation by
1447 `--variables` argument such as:
1448
1449 ----
1450 $ oscap oval eval \
1451 --variables oval_variables.xml \
1452 --results oval_results.xml \
1453 oval.xml
1454 ----
1455
1456 2) XCCDF Bindings -- The values of external variables can be given from
1457 an XCCDF file. In the XCCDF file within each `<xccdf:check>` element,
1458 there might be `<xccdf:check-export>` elements. These elements allow
1459 transition of `<xccdf:value>` elements to `<oval:variables>` elements. The
1460 following command allows users to export variable bindings from XCCDF to
1461 an OVAL Variables file:
1462
1463 ----
1464 $ oscap xccdf export-oval-variables --profile united_states_government_configuration_baseline xccdf.xml
1465 ----
1466
1467 3) Values within an OVAL Definition File -- Variables' values defined
1468 directly in the OVAL definitions file `<constant_variable>` and
1469 `<local_variable>` elements.
1470
1471 ==== Evaluation of Multiple OVAL Values
1472
1473 With `oscap`, there are two possible ways how two or more values can be
1474 specified for a variable used by one OVAL definition. The approach you choose
1475 depends on what mode you want to use, multival or multiset.
1476
1477 The `oscap` handles multiple OVAL values seamlessly. Users don't need to do
1478 anything differently than for a normal scan.
1479 The command below demonstrates evaluation of an SCAP source data stream, which
1480 may include multiset, multival, or both concepts combined, or none of them.
1481
1482 ----
1483 $ oscap xccdf eval --profile my_baseline --results-arf scap-arf.xml --cpe additional-external-cpe.xml scap-ds.xml
1484 ----
1485
1486 ==== Multival
1487
1488 Multival can pass multiple values to a single OVAL definition
1489 evaluation. This can be accomplished by all three ways as described in
1490 previous section.
1491
1492 1) OVAL Variables file -- This option is straight forward. The file
1493 format (XSD schema) allows for multiple `<value>` elements within each
1494 `<variable>` element.
1495
1496 ----
1497 <variable id="oval:com.example.www:var:1" datatype="string" comment="Unknown">
1498 <value>600</value>
1499 <value>400</value>
1500 </variable>
1501 ----
1502
1503 2) XCCDF Bindings -- Use multiple `<xccdf:check-export>` referring to the
1504 very same OVAL variable binding with multiple different XCCDF values.
1505
1506 ----
1507 <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
1508 <check-export value-id="xccdf_com.example.www_value_1"
1509 export-name="oval:com.example.www:var:1"/>
1510 <check-export value-id="xccdf_com.example.www_value_2"
1511 export-name="oval:com.example.www:var:1"/>
1512 <check-content-ref href="my-test-oval.xml" name="oval:com.example.www:def:1"/>
1513 </check>
1514 ----
1515
1516 3) Values within OVAL Definitions file -- This is similar to using a
1517 Variables file, there are multiple `<value>` elements allowed within
1518 `<constant_variable>` or `<local_variable>` elements.
1519
1520 ==== Multiset
1521
1522 Multiset allows for the very same OVAL definition to be evaluated
1523 multiple times using different values assigned to the variables for each
1524 evaluation. In OpenSCAP, this is only possible by option (2) XCCDF
1525 Bindings. The following XCCDF snippet evaluates twice the very same OVAL
1526 Definition, each time it binds a different value to the OVAL variable.
1527
1528 ----
1529 <Rule id="xccdf_moc.elpmaxe.www_rule_1" selected="true">
1530 <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
1531 <check-export value-id="xccdf_moc.elpmaxe.www_value_1" export-name="oval:com.example.www:var:1"/>
1532 <check-content-ref href="my-test-oval.xml" name="oval:com.example.www:def:1"/>
1533 </check>
1534 </Rule>
1535 <Rule id="xccdf_moc.elpmaxe.www_rule_2" selected="true">
1536 <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
1537 <check-export value-id="xccdf_moc.elpmaxe.www_value_2" export-name="oval:com.example.www:var:1"/>
1538 <check-content-ref href="my-test-oval.xml" name="oval:com.example.www:def:1"/>
1539 </check>
1540 </Rule>
1541 ----
1542
1543 After the evaluation, the OVAL results file will contain multiple
1544 result-definitions and multiple result-tests and multiple
1545 collected-objects. The elements of the same id will be differentiated by
1546 the value of the *variable_instance* attribute. Each of the
1547 definitions/tests/object might have a different result of evaluation.
1548 The following snippet of OVAL results file illustrates output of a
1549 multiset evaluation.
1550
1551 ----
1552 <tests>
1553 <test test_id="oval:com.example.www:tst:1" version="1"
1554 check="at least one" result="true" variable_instance="1">
1555 <tested_item item_id="1117551" result="true"/>
1556 <tested_variable variable_id="oval:com.example.www:var:1">600</tested_variable>
1557 </test>
1558 <test test_id="oval:com.example.www:tst:1" version="1"
1559 check="at least one" result="false" variable_instance="2">
1560 <tested_item item_id="1117551" result="false"/>
1561 <tested_variable variable_id="oval:com.example.www:var:1">400</tested_variable>
1562 </test>
1563 </tests>
1564 ----
1565
1566 === Identifying SWID tags
1567
1568 OpenSCAP identifies SWID tags using OVAL inventory class definitions that are
1569 part of an SCAP source data stream or a standalone OVAL Definition file.
1570
1571 It supports the following 3 methods of SWID tags detection:
1572
1573 1. One or more `cpe2-dict:check` elements that reference an OVAL inventory
1574 class definition that searches for the presence of a matching SWID tag.
1575 2. A `cpe:check-fact-ref` element that references an OVAL inventory class
1576 definition that searches for the presence of a matching SWID tag.
1577 3. An OVAL definition that references another OVAL inventory class definition
1578 using the `oval-def:extend_definition` element where the extended definition
1579 searches for the presence of a matching SWID tag.
1580
1581 The `oscap` command handles the SWID tag detection transparently. The detection
1582 algorithm is using OVAL's `xmlfilecontent` test. The OVAL inventory class definitions can be
1583 evaluated in a standard way, i.e. by using the `oscap oval eval` for a
1584 standalone OVAL Definition file or `oscap xccdf eval` for definitions that are
1585 part of an SCAP source data stream.
1586
1587 For example, the following command can be used to evaluate an SCAP source data
1588 stream that contains OVAL inventory class definitions that search for the
1589 presence of a matching SWID tag (referenced XML files can be obtained from the
1590 https://csrc.nist.gov/CSRC/media/Projects/scap-validation-program/documents/SCAP1.3ValidationTestContent_1-3.0.0.0.zip[SCAP 1.3 validation test suite]).
1591
1592 ----
1593 $ oscap xccdf eval --results-arf arf.xml --profile xccdf_gov.nist.validation_profile_r2850-rhel r2850-rhel-datastream.xml
1594 ----
1595
1596 As another example, the following command can be used to evaluate a standalone OVAL
1597 Definition file that contains OVAL inventory class definitions that search for
1598 the presence of a matching SWID tag:
1599
1600 ----
1601 $ oscap oval eval --results results.xml r2860-rhel-oval.xml
1602 ----
1603
1604
1605 === Notes on specifics of OVAL implementation
1606
1607 ==== Excluding non-local filesystems using the recurse_file_system="local" attribute of a FileBehaviors entity
1608
1609 The scanner loosely follows the OVAL's idea behind this attribute to behave like
1610 the coreutils utility *df* (`df -l`). This is the list of filesystems, that are
1611 not considered local by the scanner:
1612
1613 * proc, sysfs
1614 * afs
1615 * ceph
1616 * cifs
1617 * smb3, smbfs
1618 * sshfs
1619 * ncpfs, ncp
1620 * nfs, nfs4
1621 * gfs, gfs2
1622 * glusterfs
1623 * gpfs
1624 * pvfs2
1625 * ocfs2
1626 * lustre
1627 * davfs
1628
1629
1630 == List of accepted environment variables
1631
1632 OpenSCAP accepts the following environment variables.
1633 If OpenSCAP is executed with verbosity level INFO or DEVEL their runtime values will be listed at the beginning of the log.
1634
1635 * `OSCAP_CHECK_ENGINE_PLUGIN_DIR` - Defines path to a directory that contains plug-in libraries implementing additional check engines, eg. SCE.
1636 * `OSCAP_CONTAINER_VARS` - Additional environment variables read by environmentvariable58_probe. The variables are separated by `\n`. It is used by `oscap-podman` and `oscap-docker` scripts during container scanning.
1637 * `OSCAP_EVALUATION_TARGET` - Change value of target facts `urn:xccdf:fact:identifier` and `urn:xccdf:fact:asset:identifier:ein` in XCCDF results. Used during offline scanning to pass the name of the target system.
1638 * `OSCAP_FULL_VALIDATION` - If set, XML schema validation will be performed in every step of SCAP content processing.
1639 * `OSCAP_OVAL_COMMAND_OPTIONS` - Additional command line options for `oscap oval` module. The value of this environment variable is appended to the actual command line options of `oscap` command.
1640 * `OSCAP_PCRE_EXEC_RECURSION_LIMIT` - Set recursion limit of regular expression matching using `pcre_exec`/`pcre2_match` functions.
1641 * `OSCAP_PROBE_ROOT` - Path to a directory which contains mounted filesystem to be evaluated. Used for offline scanning.
1642 * `SEXP_VALIDATE_DISABLE` - If set, `oscap` will not validate SEXP expressions during its execution.
1643 * `SOURCE_DATE_EPOCH` - Timestamp in seconds since epoch. This timestamp will be used instead of the current time to populate `timestamp` attributes in SCAP source data streams. This is used for reproducible builds of data streams.
1644 * `OSCAP_PROBE_MEMORY_USAGE_RATIO` - maximum memory usage ratio (used/total) for OpenSCAP probes, default: 0.1
1645 * `OSCAP_PROBE_MAX_COLLECTED_ITEMS` - maximal count of collected items by OpenSCAP probe for a single OVAL object evaluation
1646 * `OSCAP_PROBE_IGNORE_PATHS` - Skip given paths during evaluation. If multiple paths should be skipped they need to be separated by a colon. The paths should be absolute canonical paths.
1647 * `OSCAP_PREFERRED_ENGINE` - Set a preffered check engine for XCCDF rules. If a rule has multiple checks, the checks for the preffered check engine will be used. Allowed values: `SCE`, `OVAL`. If this variable is set to `SCE` and a rule has both SCE and OVAL checks the SCE check will be used. If this variable is set to `OVAL` and a rule has both SCE and OVAL checks the OVAL check will be used. If this environment variable isn't set, the standard XCCDF mechanism will be used for check selection.
1648
1649 Also, OpenSCAP uses `libcurl` library which also can be configured using environment variables. See https://curl.se/libcurl/c/libcurl-env.html[the list of libcurl environment variables].
1650
1651 == Using external or remote resources
1652
1653 Some SCAP content references external resources. For example, older versions of SCAP Security Guide (prior to version 0.1.73)
1654 used external OVAL file to check that the system is up to date and has no known
1655 security vulnerabilities. However, other content can use external resources for
1656 other purposes.
1657
1658 NOTE: Starting with version 0.1.73, SCAP Security Guide content doesn't use external resources anymore.
1659
1660 When you are evaluating SCAP content with external resources the `oscap` tool
1661 will warn you:
1662
1663 ----
1664 $ oscap xccdf eval \
1665 --profile xccdf_org.ssgproject.content_profile_common \
1666 ds.xml
1667
1668 WARNING: This content points out to the remote resources. Use `--fetch-remote-resources' option to download them.
1669 WARNING: Skipping https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL7.xml.bz2 file which is referenced from XCCDF content
1670 ----
1671
1672 By default the `oscap` tool will not blindly download and execute remote content.
1673 If you trust your local content and the remote content it references, you can use
1674 the `--fetch-remote-resources` option to automatically download it using the
1675 `oscap` tool.
1676
1677 ----
1678 $ oscap xccdf eval \
1679 --fetch-remote-resources \
1680 --profile xccdf_org.ssgproject.content_profile_common \
1681 ds.xml
1682 Downloading: https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL7.xml.bz2 ... ok
1683 Title Ensure /var/log Located On Separate Partition
1684 Rule xccdf_org.ssgproject.content_rule_partition_for_var_log
1685 ...
1686 ----
1687
1688 On systems that don't have a direct internet access or if the user doesn't want OpenSCAP to connect to the network it's possible to download the remote content using other tools, save it to a directory and then pass it to OpenSCAP as a file.
1689 To do that, use `--local-files` instead of `--fetch-remote-resources` as argument of the `oscap` command.
1690
1691 In place of the remote data stream component OpenSCAP will attempt to use a file whose file name is equal to `name` attribute of the `uri` element within the `catalog` element within the `component-ref` element representing a checklist in the data stream if such file exists.
1692
1693 In the following example, the `ssg-rhel8-ds.xml` is an SCAP source datastream.
1694 It needs some checks from a remote component. The remote component's `component-ref` ID is `scap_org.open-scap_cref_security-data-oval-com.redhat.rhsa-RHEL8.xml` and the `component-ref` is pointing to `https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml`.
1695 The checks from the remote component are used in the only checklist in the data stream.
1696 The `component-ref` of the checklist component contains a `catalog` where one of the `uri` elements maps the remote component's `component-ref` ID in the `uri` attribute to the actual name `security-data-oval-com.redhat.rhsa-RHEL8.xml` which is the value of the `name` attribute.
1697 Therefore, we can download the remote data from `https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml` and save it as `security-data-oval-com.redhat.rhsa-RHEL8.xml` to some directory.
1698 Then, we execute `oscap` with `--local-files` and provide a path to the directory where it's located.
1699 It will pick the file and use it instead of the remote data and it won't connect to the network.
1700
1701 ----
1702 $ mkdir ~/scap-files
1703 $ wget -O ~/scap-files/security-data-oval-com.redhat.rhsa-RHEL8.xml https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml
1704 ...
1705 $ oscap xccdf eval --local-files ~/scap-files --profile ospp ssg-rhel8-ds.xml
1706 ----
1707
1708 NOTE: The `--local-files` option works only with SCAP 1.3 source data streams. It can't be used with SCAP 1.2 source data streams.
1709
1710 == Practical Examples
1711 This section demonstrates practical usage of certain security content provided
1712 for Red Hat products.
1713
1714 These practical examples show usage of industry standard checklists that
1715 were validated by NIST.
1716
1717 === Auditing System Settings with SCAP Security Guide
1718 The SSG project contains guidance for settings of Red Hat Enterprise Linux 9.
1719
1720 1) Install the SSG
1721
1722 ----
1723 # sudo dnf install -y scap-security-guide
1724 ----
1725
1726 2) To inspect the security content use the `oscap info` module:
1727
1728 ----
1729 $ oscap info /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
1730 ----
1731
1732 The output of this command contains available configuration profiles.
1733 To audit your system settings choose one of the profiles and run the evaluation command.
1734 For example, the following command is used to assess the given system using the "CIS Red Hat Enterprise Linux 9 Benchmark for Level 2 - Server" profile.
1735
1736 ----
1737 # oscap xccdf eval \
1738 --profile xccdf_org.ssgproject.content_profile_cis \
1739 --results-arf results.xml \
1740 --report report.html \
1741 /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
1742 ----
1743
1744 === How to Evaluate PCI-DSS on RHEL9
1745 This section describes how to evaluate the Payment Card Industry Data Security
1746 Standard (PCI-DSS) on Red Hat Enterprise Linux 9.
1747
1748 1) Install SSG which provides the PCI-DSS SCAP content
1749
1750 ----
1751 # dnf install -y scap-security-guide
1752 ----
1753
1754 2) Verify that the PCI-DSS profile is present
1755
1756 ----
1757 # oscap info /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
1758 ----
1759
1760 3) Evaluate the PCI-DSS profile
1761
1762 ----
1763 # oscap xccdf eval \
1764 --results-arf results-arf.xml \
1765 --profile xccdf_org.ssgproject.content_profile_pci-dss \
1766 /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
1767 ----
1768
1769 4) Generate report readable in a web browser.
1770
1771 ----
1772 $ oscap xccdf generate report --output report.html results-arf.xml
1773 ----
1774
1775 === How to Evaluate DISA STIG
1776
1777 This section describes how to evaluate the Defense Information Systems Agency
1778 (DISA) Security Technical Implementation Guide (STIG) on Red Hat Eneterprise
1779 Linux 7.
1780
1781 . Download the DISA STIG content.
1782 +
1783 ----
1784 $ wget https://dl.dod.cyber.mil/wp-content/uploads/stigs/zip/U_RHEL_7_V3R2_STIG_SCAP_1-2_Benchmark.zip
1785 ----
1786 +
1787 . Unpack the content.
1788 +
1789 ----
1790 $ unzip U_RHEL_7_V3R2_STIG_SCAP_1-2_Benchmark.zip
1791 ----
1792 +
1793 . Display a list of available profiles.
1794 +
1795 ----
1796 $ oscap info U_RHEL_7_V3R2_STIG_SCAP_1-2_Benchmark.xml
1797 ----
1798 +
1799 . Evaluate your favorite profile, for example *MAC-1_Public*, and write
1800 ARF results into the results.xml file.
1801 +
1802 ----
1803 # oscap xccdf eval \
1804 --profile xccdf_mil.disa.stig_profile_MAC-1_Public \
1805 --results-arf results.xml \
1806 --report report.html \
1807 U_RHEL_7_V3R2_STIG_SCAP_1-2_Benchmark.xml
1808 ----
1809
1810 If you are interested in DISA STIG content for other systems please refer to
1811 https://public.cyber.mil/stigs/downloads/[DoD Cyber Exchange].
1812
1813
1814 == Scanning remote and virtual machines or containers
1815
1816 Apart from the `oscap` command, OpenSCAP provides also other utilities for
1817 special purposes. Those utilities use `oscap` under the hood, but they
1818 enable users to perform advanced tasks in a single command.
1819 This manual gives a quick overview of and shows basic usage of these tools.
1820 Each of the tools have its own manual page that gives more detailed information.
1821
1822 To install these tools install the `openscap-utils` package.
1823
1824 ----
1825 # dnf install openscap-utils
1826 ----
1827
1828 === Scanning remote machines
1829
1830 The `oscap-ssh` command is a simple tool for scanning remote machines with
1831 OpenSCAP over network and collecting results.
1832
1833 The tool uses SSH connection to copy the SCAP content to a remote machine, then
1834 it runs an evaluation of the target system and downloads the results back.
1835 The remote machine needs to have OpenSCAP installed.
1836
1837 The tool can evaluate source data streams and OVAL files.
1838 Usage of the tool mimics usage and options of `oscap` tool.
1839
1840 In the following example, we will scan a remote Fedora server located on IP address
1841 *192.168.1.13* that listens for SSH connections on port *22*.
1842 The server will be scanned for compliance with the *Common Profile for General-Purpose
1843 Fedora Systems* provided by SCAP Security Guide.
1844 HTML report is written out as *report.html* on the local machine.
1845
1846 ----
1847 $ oscap-ssh [email protected] 22 xccdf eval \
1848 --profile xccdf_org.ssgproject.content_profile_common \
1849 --report report.html \
1850 /usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml
1851 ----
1852
1853 === Scanning containers and container images using oscap-podman
1854
1855 The `oscap-podman` tool can be used to scan Linux containers and container images.
1856 Usage of the tool mimics usage and options of `oscap` tool.
1857
1858 NOTE: `oscap-podman` is available only on Fedora and Red Hat Enterprise Linux 8
1859 or newer. On other systems use `oscap-docker` instead.
1860
1861
1862 . Get the ID of a container or a container image, for example:
1863 +
1864 ----
1865 # podman images
1866 REPOSITORY TAG IMAGE ID CREATED SIZE
1867 registry.access.redhat.com/ubi8 latest 3269c37eae33 2 months ago 208 MB
1868 ----
1869 +
1870 . Evaluate the SCAP content, for example:
1871 +
1872 ----
1873 # oscap-podman 3269c37eae33 xccdf eval --report report.html --profile ospp /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
1874 ----
1875
1876 Note that the `oscap-podman` command requires root privileges.
1877
1878 === Building hardened bootable container images using oscap-im
1879
1880 The `oscap-im` tool is a convenience script that makes building hardened bootable container images easier.
1881 This tool is designed to be used during the build of the bootable container image.
1882
1883 Include `oscap-im` in your `Containerfile` that will be used to build your bootable container image.
1884 The `Containerfile` first needs to install the `openscap-utils` package which ships the `oscap-im` tool.
1885
1886 Also, SCAP content needs to be installed to the image before `oscap-im` will be run.
1887 Although any SCAP content can be consumed by the tool, the SCAP source data streams shipped in `scap-security-guide` are specially cared to be compatible with bootable containers.
1888
1889 Example `Containerfile`:
1890
1891 ----
1892 FROM quay.io/centos-bootc/centos-bootc:stream9
1893
1894 RUN dnf install -y openscap-utils scap-security-guide
1895
1896 RUN oscap-im --profile stig /usr/share/xml/scap/ssg/content/ssg-cs9-ds.xml
1897 ----
1898
1899 Once you have your `Containerfile`, execute the image build:
1900
1901 ----
1902 podman build -t hardened_image .
1903 ----
1904
1905 The `oscap-im` tool installs and removes all packages required by the selected profile to or from the image.
1906 Then, it runs a scan and remediation with the selected profile.
1907 It doesn't use offline scanning.
1908 The configuration files and other content in the image are modified by this process, depending on the used SCAP content.
1909
1910 The built bootable container image can be then deployed and booted.
1911 After booting the image, the state of the resulting system will be in line with the selected security profile.
1912
1913 The `oscap-im` tool can't be used anywhere else than in a `Containerfile`.
1914
1915 === Scanning of Docker containers and images using oscap-docker
1916
1917 The `oscap-docker` is used to scan Docker containers and images. It can
1918 assess vulnerabilities in the container or image and check their compliance
1919 with security policies. Usage of the tool mimics usage and options
1920 of `oscap` tool.
1921
1922 NOTE: `oscap-docker` isn't available on Fedora and on Red Hat Enterprise Linux 8
1923 or newer. On other systems use `oscap-podman` instead.
1924
1925 The `oscap-docker` tool uses a technique called offline scanning.
1926 That means that the filesystem of the container is mounted to a directory
1927 on the host. The mounted filesystem is read-only. OpenSCAP then assess
1928 the container from the host. Therefore no agent is installed
1929 in the container and container is not touched or changed in any way.
1930
1931 In the first example, we will perform a vulnerability assessment
1932 of an Docker image of Red Hat Enterprise Linux 7 (named *rhel7*). The command
1933 will attach docker image, determine OS variant/version, download CVE stream
1934 applicable to the given image and finally it will evaluate the image
1935 for vulnerabilities. CVE stream is a list of vulnerabilities in SCAP format
1936 and is downloaded directly from Red Hat.
1937 HTML report is written out as *report.html* on the local machine.
1938
1939 ----
1940 $ oscap-docker image-cve rhel7 --report report.html
1941 ----
1942
1943 In the second example, we will check the same *rhel7* image for
1944 compliance with a security policy specified in an XCCDF checklist.
1945
1946 ----
1947 $ oscap-docker image rhel7 xccdf eval --report report.html xccdf.xml
1948 ----
1949
1950 To scan running containers, commands are very similar, just replace
1951 "image-cve" with "container-cve" and "image" with "container".
1952
1953 === Scanning of virtual machines using oscap-vm
1954
1955 OpenSCAP provides a simple tool to evaluate virtual machines called `oscap-vm`.
1956
1957 The tool can scan given virtual machine directly from the virtualisation host.
1958 Usage of the tool mimics usage and options of `oscap` tool.
1959
1960 Similarly to `oscap-docker`, this utility also uses offline scanning,
1961 so it doesn't install anything in the guest, doesn't require OpenSCAP
1962 installed in the guest and it doesn't create or change anything in the
1963 guest's filesystem.
1964
1965 === Scanning arbitrary filesystems using oscap-chroot
1966
1967 A very simple script `oscap-chroot` can be used to perform
1968 an offline scan of a filesystem that is mounted at arbitrary path.
1969 It can be used for scanning of custom objects that are not supported
1970 by `oscap-docker` or `oscap-vm`, like containers in other
1971 formats than Docker.
1972 Again, usage of the tool mimics usage and options of `oscap` tool.
1973
1974 == Scanning and remediating the system at boot time
1975
1976 OpenSCAP can scan and remediate the system at boot time using systemd's `system-update.target`.
1977 The `oscap-remediate.service` is expecting the `/system-update` symlink (universal trigger for all services in system-update's requires list) which points to a file with base name `oscap-remediate-offline.conf.sh`.
1978 The file itself could be located anywhere, but it should be accessible at boot time. This configuration file is essentially a Bash script with a set of environment variables, loaded with `source` by the service.
1979 Upon the start the service will immediately remove the symlink to prevent invocation loop but it won't touch the configuration file itself. A helper tool, `oscap-remediate-offline`, can be used to bootstrap the configuration and prime the `/system-update` symlink, but its flexibility is limited and in general it should only be used for debugging.
1980
1981 WARNING: The `oscap-remediate-offline` tool should not be considered as a stable API for priming the service. The *only* API of the service is the configuration file and the `/system-update` symlink pointing to it.
1982
1983 Configuration variables:
1984 ----
1985 # Mandatory -----------------------------
1986
1987 # The path to the data stream file
1988 OSCAP_REMEDIATE_DS=/some/data_stream.xml
1989
1990 # The ID of the profile to use
1991 OSCAP_REMEDIATE_PROFILE_ID=some_profile
1992
1993 # Optional ------------------------------
1994
1995 # Data stream, XCCDF or Benchmark IDs
1996 # Benchmark ID and DS + XCCDF IDs pair are mutually
1997 # exclusive. DS + XCCDF IDs will take precedence
1998 OSCAP_REMEDIATE_DATASTREAM_ID=some_ds_id
1999 OSCAP_REMEDIATE_XCCDF_ID=some_xccdf_id
2000 OSCAP_REMEDIATE_BENCHMARK_ID=some_bench_id
2001
2002 # Tailoring file and tailoring component ID
2003 OSCAP_REMEDIATE_TAILORING=/some/tailoring.xml
2004 OSCAP_REMEDIATE_TAILORING_ID=tailoring_id
2005
2006 # Where to write ARF result and HTML report
2007 # No defaults, they won't be generated if
2008 # they are not requested explicitly
2009 OSCAP_REMEDIATE_ARF_RESULT=/some/arf_res.xml
2010 OSCAP_REMEDIATE_HTML_REPORT=/some/report.html
2011
2012 # Log file name and verbosity
2013 OSCAP_REMEDIATE_VERBOSE_LOG=/var/some_verbose.log
2014 # Optional even if OSCAP_REMEDIATE_VERBOSE_LOG is provided (default: INFO)
2015 OSCAP_REMEDIATE_VERBOSE_LEVEL=INFO
2016 ----
2017
2018 == Frequently Asked Questions (FAQs)
2019 *Why do I get "notchecked" results when I use e.g. https://dl.dod.cyber.mil/wp-content/uploads/stigs/zip/U_Red_Hat_Enterprise_Linux_7_V2R3_STIG.zip[STIG checklist]?*
2020
2021 The downloaded guidance contains rule descriptions, but it doesn't contain OVAL checks which could be used for evaluation by OpenSCAP. You can find guidances with implemented OVAL checks and also with remediations at https://github.com/ComplianceAsCode/content[ComplianceAsCode] project, which contains wide range of profiles.
2022
2023 *How can I create a tailoring file if I can't install SCAP Workbench?*
2024
2025 Use the `autotailor` tool which allows you to create tailoring files using command line options.
2026 For more information, please refer to section <<_tailoring,Tailoring>>.
2027
2028 *I try to apply a tailoring file, but OpenSCAP still evaluates rules that I have unselected. How can I enforce my changes of the profile?*
2029
2030 Make sure that you provide the ID of the customized profile in `--profile` option instead of the ID of the original profile.
2031 If you created the tailoring file using `autotailor` and you haven't used the `-p` or `--new-profile-id` option, the ID of the customized profile is the original profile ID with `_customized` suffix appended.
2032 If you created the tailoring file using SCAP Workbench, you were prompted to choose the ID of the customized profile. By default, the ID of the customized profile is the original profile ID with `_customized` suffix appended.
2033 You can find the ID of the customized profile with `oscap info <your_tailoring_file>` command.
2034
2035 *My SCAP source data stream contains rule `security_patches_up_to_date` which needs to download some data from the internet to work.*
2036 *But I'm in an air gapped environment so it can't download it.*
2037 *Can I download it separately and pass it to oscap?*
2038
2039 Yes, it's possible, you can download the file on other computer that is connected to the internet and then copy the file to the system where you run `oscap`.
2040 Instead of the `--fetch-remote-resources` option you will use the `--local-files` option.
2041 This option works only with SCAP 1.3 source data streams. It can't be used with SCAP 1.2 source data streams.
2042 For more information, please refer to section <<_using_external_or_remote_resources,Using external or remote resources>>.
2043
2044 *I have generated a kickstart but the generated file isn't a valid kickstart.*
2045
2046 You are using a wrong `--fix-type` option.
2047 To generate a kickstart, use the `--fix-type kickstart` option.
2048 Do not use `--fix-type anaconda`.
2049 For more information, please refer to section <<_generating_rhel_kickstarts,Generating RHEL Kickstarts>>.