From 3151b63cb68be8fa80a271cdf5632fa7946e4d31 Mon Sep 17 00:00:00 2001 From: Marta Rybczynska Date: Wed, 1 Nov 2023 07:26:14 +0100 Subject: dev-manual: extend the description of CVE patch preparation Extend the description on how to prepare a patch for a CVE issue. Add a more illustrative and current example of how to modify the patch file. Add an example of how to use CVE_STATUS. (From yocto-docs rev: f982f6be6b52ba0915b2e6f712270dec5dde64fc) Signed-off-by: Marta Rybczynska Reviewed-by: Michael Opdenacker Signed-off-by: Richard Purdie --- documentation/dev-manual/vulnerabilities.rst | 111 ++++++++++++++++++++++----- 1 file changed, 91 insertions(+), 20 deletions(-) (limited to 'documentation') diff --git a/documentation/dev-manual/vulnerabilities.rst b/documentation/dev-manual/vulnerabilities.rst index c492b62ffd..1bc2a85929 100644 --- a/documentation/dev-manual/vulnerabilities.rst +++ b/documentation/dev-manual/vulnerabilities.rst @@ -129,31 +129,97 @@ NVD about CVE entries can be provided through the `NVD contact form `:: +an example from the :oe_layerindex:`ffmpeg recipe for dunfell `:: SRC_URI = "https://www.ffmpeg.org/releases/${BP}.tar.xz \ + file://mips64_cpu_detection.patch \ + file://CVE-2020-12284.patch \ file://0001-libavutil-include-assembly-with-full-path-from-sourc.patch \ - file://fix-CVE-2020-20446.patch \ - file://fix-CVE-2020-20453.patch \ - file://fix-CVE-2020-22015.patch \ - file://fix-CVE-2020-22021.patch \ - file://fix-CVE-2020-22033-CVE-2020-22019.patch \ - file://fix-CVE-2021-33815.patch \ + file://CVE-2021-3566.patch \ + file://CVE-2021-38291.patch \ + file://CVE-2022-1475.patch \ + file://CVE-2022-3109.patch \ + file://CVE-2022-3341.patch \ + file://CVE-2022-48434.patch \ + " + +The recipe has both generic and security-related fixes. The CVE patch files are named +according to the CVE they fix. + +When preparing the patch file, take the original patch from the upstream repository. +Do not use patches from different distributions, except if it is the only available source. + +Modify the patch adding OE-related metadata. We will follow the example of the +``CVE-2022-3341.patch``. + +The original `commit message `__ +is:: + + From 9cf652cef49d74afe3d454f27d49eb1a1394951e Mon Sep 17 00:00:00 2001 + From: Jiasheng Jiang + Date: Wed, 23 Feb 2022 10:31:59 +0800 + Subject: [PATCH] avformat/nutdec: Add check for avformat_new_stream + + Check for failure of avformat_new_stream() and propagate + the error code. + + Signed-off-by: Michael Niedermayer + --- + libavformat/nutdec.c | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + + +For the correct operations of the ``cve-check``, it requires the CVE +identification in a ``CVE:`` tag of the patch file commit message using +the format:: -A good practice is to include the CVE identifier in both the patch file name -and inside the patch file commit message using the format:: + CVE: CVE-2022-3341 - CVE: CVE-2020-22033 +It is also recommended to add the ``Upstream-Status:`` tag with a link +to the original patch and sign-off by people working on the backport. +If there are any modifications to the original patch, note them in +the ``Comments:`` tag. + +With the additional information, the header of the patch file in OE-core becomes:: + + From 9cf652cef49d74afe3d454f27d49eb1a1394951e Mon Sep 17 00:00:00 2001 + From: Jiasheng Jiang + Date: Wed, 23 Feb 2022 10:31:59 +0800 + Subject: [PATCH] avformat/nutdec: Add check for avformat_new_stream + + Check for failure of avformat_new_stream() and propagate + the error code. + + Signed-off-by: Michael Niedermayer + + CVE: CVE-2022-3341 + + Upstream-Status: Backport [https://github.com/FFmpeg/FFmpeg/commit/9cf652cef49d74afe3d454f27d49eb1a1394951e] + + Comments: Refreshed Hunk + Signed-off-by: Narpat Mali + Signed-off-by: Bhabu Bindu + --- + libavformat/nutdec.c | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +A good practice is to include the CVE identifier in the patch file name, the patch file +commit message and optionally in the recipe commit message. CVE checker will then capture this information and change the CVE status to ``Patched`` in the generated reports. @@ -161,8 +227,13 @@ in the generated reports. If analysis shows that the CVE issue does not impact the recipe due to configuration, platform, version or other reasons, the CVE can be marked as ``Ignored`` by using the :term:`CVE_STATUS` variable flag with appropriate reason which is mapped to ``Ignored``. -As mentioned previously, if data in the CVE database is wrong, it is recommend to fix those -issues in the CVE database directly. +The entry should have the format like:: + + CVE_STATUS[CVE-2016-10642] = "cpe-incorrect: This is specific to the npm package that installs cmake, so isn't relevant to OpenEmbedded" + +As mentioned previously, if data in the CVE database is wrong, it is recommended +to fix those issues in the CVE database (NVD in the case of OE-core and Poky) +directly. Note that if there are many CVEs with the same status and reason, those can be shared by using the :term:`CVE_STATUS_GROUPS` variable. -- cgit v1.2.3-54-g00ecf