diff options
| -rw-r--r-- | documentation/dev-manual/common-tasks.rst | 69 | ||||
| -rw-r--r-- | documentation/ref-manual/classes.rst | 16 | ||||
| -rw-r--r-- | documentation/ref-manual/variables.rst | 13 |
3 files changed, 97 insertions, 1 deletions
diff --git a/documentation/dev-manual/common-tasks.rst b/documentation/dev-manual/common-tasks.rst index 7fa0df4d39..37077d72d4 100644 --- a/documentation/dev-manual/common-tasks.rst +++ b/documentation/dev-manual/common-tasks.rst | |||
| @@ -11131,6 +11131,75 @@ Enabling vulnerabily tracking in recipes | |||
| 11131 | The :term:`CVE_PRODUCT` variable defines the name used to match the recipe name | 11131 | The :term:`CVE_PRODUCT` variable defines the name used to match the recipe name |
| 11132 | against the name in the upstream `NIST CVE database <https://nvd.nist.gov/>`__. | 11132 | against the name in the upstream `NIST CVE database <https://nvd.nist.gov/>`__. |
| 11133 | 11133 | ||
| 11134 | Editing recipes to fix vulnerabilities | ||
| 11135 | -------------------------------------- | ||
| 11136 | |||
| 11137 | To fix a given known vulnerability, you need to add a patch file to your recipe. Here's | ||
| 11138 | an example from the :oe_layerindex:`ffmpeg recipe</layerindex/recipe/47350>`:: | ||
| 11139 | |||
| 11140 | SRC_URI = "https://www.ffmpeg.org/releases/${BP}.tar.xz \ | ||
| 11141 | file://0001-libavutil-include-assembly-with-full-path-from-sourc.patch \ | ||
| 11142 | file://fix-CVE-2020-20446.patch \ | ||
| 11143 | file://fix-CVE-2020-20453.patch \ | ||
| 11144 | file://fix-CVE-2020-22015.patch \ | ||
| 11145 | file://fix-CVE-2020-22021.patch \ | ||
| 11146 | file://fix-CVE-2020-22033-CVE-2020-22019.patch \ | ||
| 11147 | file://fix-CVE-2021-33815.patch \ | ||
| 11148 | |||
| 11149 | The :ref:`cve-check <ref-classes-cve-check>` class defines two ways of | ||
| 11150 | supplying a patch for a given CVE. The first | ||
| 11151 | way is to use a patch filename that matches the below pattern:: | ||
| 11152 | |||
| 11153 | cve_file_name_match = re.compile(".*([Cc][Vv][Ee]\-\d{4}\-\d+)") | ||
| 11154 | |||
| 11155 | As shown in the example above, multiple CVE IDs can appear in a patch filename, | ||
| 11156 | but the :ref:`cve-check <ref-classes-cve-check>` class will only consider | ||
| 11157 | the last CVE ID in the file name as patched. | ||
| 11158 | |||
| 11159 | The second way to recognize a patched CVE ID is when a line matching the | ||
| 11160 | below pattern is found in any patch file provided by the recipe:: | ||
| 11161 | |||
| 11162 | cve_match = re.compile("CVE:( CVE\-\d{4}\-\d+)+") | ||
| 11163 | |||
| 11164 | This allows a single patch file to address multiple CVE IDs at the same time. | ||
| 11165 | |||
| 11166 | Of course, another way to fix vulnerabilities is to upgrade to a version | ||
| 11167 | of the package which is not impacted, typically a more recent one. | ||
| 11168 | The NIST database knows which versions are vulnerable and which ones | ||
| 11169 | are not. | ||
| 11170 | |||
| 11171 | Last but not least, you can choose to ignore vulnerabilities through | ||
| 11172 | the :term:`CVE_CHECK_PN_WHITELIST` and :term:`CVE_CHECK_WHITELIST` | ||
| 11173 | variables. | ||
| 11174 | |||
| 11175 | Implementation details | ||
| 11176 | ---------------------- | ||
| 11177 | |||
| 11178 | Here's what the :ref:`cve-check <ref-classes-cve-check>` class does to | ||
| 11179 | find unpatched CVE IDs. | ||
| 11180 | |||
| 11181 | First the code goes through each patch file provided by a recipe. If a valid CVE ID | ||
| 11182 | is found in the name of the file, the corresponding CVE is considered as patched. | ||
| 11183 | Don't forget that if multiple CVE IDs are found in the file name, only the last | ||
| 11184 | one is considered. Then, the code looks for ``CVE: CVE-ID`` lines in the patch | ||
| 11185 | file. The found CVE IDs are also considered as patched. | ||
| 11186 | |||
| 11187 | Then, the code looks up all the CVE IDs in the NIST database for all the | ||
| 11188 | products defined in :term:`CVE_PRODUCT`. Then, for each found CVE: | ||
| 11189 | |||
| 11190 | - If the package name (:term:`PN`) is part of | ||
| 11191 | :term:`CVE_CHECK_PN_WHITELIST`, it is considered as patched. | ||
| 11192 | |||
| 11193 | - If the CVE ID is part of :term:`CVE_CHECK_WHITELIST`, it is | ||
| 11194 | considered as patched too. | ||
| 11195 | |||
| 11196 | - If the CVE ID is part of the patched CVE for the recipe, it is | ||
| 11197 | already considered as patched. | ||
| 11198 | |||
| 11199 | - Otherwise, the code checks whether the recipe version (:term:`PV`) | ||
| 11200 | is within the range of versions impacted by the CVE. If so, the CVE | ||
| 11201 | is considered as unpatched. | ||
| 11202 | |||
| 11134 | The CVE database is stored in :term:`DL_DIR` and can be inspected using | 11203 | The CVE database is stored in :term:`DL_DIR` and can be inspected using |
| 11135 | ``sqlite3`` command as follows:: | 11204 | ``sqlite3`` command as follows:: |
| 11136 | 11205 | ||
diff --git a/documentation/ref-manual/classes.rst b/documentation/ref-manual/classes.rst index 49905f2725..a98a64c432 100644 --- a/documentation/ref-manual/classes.rst +++ b/documentation/ref-manual/classes.rst | |||
| @@ -404,6 +404,22 @@ cross-compilation tools used for building SDKs. See the | |||
| 404 | section in the Yocto Project Overview and Concepts Manual for more | 404 | section in the Yocto Project Overview and Concepts Manual for more |
| 405 | discussion on these cross-compilation tools. | 405 | discussion on these cross-compilation tools. |
| 406 | 406 | ||
| 407 | .. _ref-classes-cve-check: | ||
| 408 | |||
| 409 | ``cve-check.bbclass`` | ||
| 410 | ===================== | ||
| 411 | |||
| 412 | The ``cve-check`` class looks for known CVEs (Common Vulnerabilities | ||
| 413 | and Exposures) while building an image. This class is meant to be | ||
| 414 | inherited globally from a configuration file:: | ||
| 415 | |||
| 416 | INHERIT += "cve-check" | ||
| 417 | |||
| 418 | You can also look for vulnerabilities in specific packages by passing | ||
| 419 | ``-c cve_check`` to BitBake. You will find details in the | ||
| 420 | ":ref:`dev-manual/common-tasks:checking for vulnerabilities`" | ||
| 421 | section in the Development Tasks Manual. | ||
| 422 | |||
| 407 | .. _ref-classes-debian: | 423 | .. _ref-classes-debian: |
| 408 | 424 | ||
| 409 | ``debian.bbclass`` | 425 | ``debian.bbclass`` |
diff --git a/documentation/ref-manual/variables.rst b/documentation/ref-manual/variables.rst index 1150940133..f6d248a193 100644 --- a/documentation/ref-manual/variables.rst +++ b/documentation/ref-manual/variables.rst | |||
| @@ -1471,11 +1471,22 @@ system and gives an overview of their function and contents. | |||
| 1471 | variable only in certain contexts (e.g. when building for kernel | 1471 | variable only in certain contexts (e.g. when building for kernel |
| 1472 | and kernel module recipes). | 1472 | and kernel module recipes). |
| 1473 | 1473 | ||
| 1474 | :term:`CVE_CHECK_PN_WHITELIST` | ||
| 1475 | The list of package names (:term:`PN`) for which | ||
| 1476 | CVEs (Common Vulnerabilities and Exposures) are ignored. | ||
| 1477 | |||
| 1478 | :term:`CVE_CHECK_WHITELIST` | ||
| 1479 | The list of CVE IDs which are ignored. Here is | ||
| 1480 | an example from the :oe_layerindex:`Python3 recipe</layerindex/recipe/23823>`:: | ||
| 1481 | |||
| 1482 | # This is windows only issue. | ||
| 1483 | CVE_CHECK_WHITELIST += "CVE-2020-15523" | ||
| 1484 | |||
| 1474 | :term:`CVE_PRODUCT` | 1485 | :term:`CVE_PRODUCT` |
| 1475 | In a recipe, defines the name used to match the recipe name | 1486 | In a recipe, defines the name used to match the recipe name |
| 1476 | against the name in the upstream `NIST CVE database <https://nvd.nist.gov/>`__. | 1487 | against the name in the upstream `NIST CVE database <https://nvd.nist.gov/>`__. |
| 1477 | 1488 | ||
| 1478 | The default is ${:term:`BPN`}. If it does not match the name in NIST CVE | 1489 | The default is ${:term:`BPN`}. If it does not match the name in the NIST CVE |
| 1479 | database or matches with multiple entries in the database, the default | 1490 | database or matches with multiple entries in the database, the default |
| 1480 | value needs to be changed. | 1491 | value needs to be changed. |
| 1481 | 1492 | ||
