1# Software Bill of Materials (SBOM) 2 3SBOM is a collection of information of each software component 4you are supplying/building. Similar to a package manager on Linux 5based systems, it holds information of as many software parts as 6possible. This information can be a version, name of the software, URL, 7license information and more. A SBOM can be saved in various formats. 8In coreboot it's saved as "uSWID" file. uSWID is not a standard or 9specification but it doesn't need to be, since it's basically just an 10array/list of CoSWID (Concise Software Identification) files which in 11turn are specified by a RFC specification. CoSWID files are saved in a 12CBOR format. CBOR is like JSON if JSON were a binary format. Similar 13to a package manager the CoSWID format can link multiple softwares 14together. For example on most modern Intel systems FSP is included as 15a dependency of coreboot. That kind of relationship between software 16components (among others) can be expressed in an uSWID file. That makes 17firmware/software much more transparent. One could for example create a 18software that takes a coreboot firmware image as input and 19automatically creates a graph with all software components the coreboot 20image contains and their relationship to each other. 21 22 23## SWID/CoSWID 24 25SWID is a standard hidden behind an ISO paywall. 26It generally identifies/describes Software components. Since SWID files 27are written in XML, they can get too large for devices with network and 28storage constraints. CoSWID is basically SWID but in CBOR binary 29format, which makes it far smaller compared to its big brother. Also, 30CoSWID is a RFC specification (so publicly accessible). Therefore 31CoSWID is the standard used in coreboot SBOM. But one CoSWID file/tag 32can only describe one single software, but since software is usually 33composed of multiple parts (especially in firmware with many binary 34blobs) uSWID was born as a container format to hold multiple CoSWID 35files. It also has a magic value, that makes software capable of 36extracting uSWID/CoSWID data without the need to understand the 37underlying format of the binary (in coreboot it's the CBFS and in EDK2 38it's the COFF). To get a simple overview of how a SWID/CoSWID file 39looks like, just take a look at the various "templates" in src/sbom/. 40There are of course other SBOM specifications out there, but most of 41them are rather blown up and don't support a binary format at all. 42 43 44## coreboot implementation 45 46Quick overview of how things are generated: 47 48![Generation of an SBOM File in coreboot][sbom_generation] 49 50[sbom_generation]: sbom_generation.svg 51 52After all SBOM data has been fetched from all the software components, 53the 'goswid' tool links them all together into one sbom.uswid file. 54Therefore the goswid tool is basically a linker that takes multiple 55CoSWID/SWID files and converts them into one uSWID file. Although the 56image shows only Files in JSON format it is also possible to supply 57them in XML or CBOR format. 58 59The final SBOM file is located inside the CBFS. 60For each software component in coreboot SBOM, there is an option in 61Kconfig (usually called `CONFIG_INCLUDE_[software-name]_SBOM`) to either 62include or not include SBOM metadata for the specified software. 63Furthermore there is a `CONFIG_SBOM_[software-name]_PATH` option which 64contains a path to a SWID/CoSWID file in a format of choice 65(being either JSON, XML or CBOR). `CONFIG_SBOM_[software-name]_PATH` 66option usually defaults to a very generic CoSWID file in JSON format 67(which are stored in src/sbom/). That at least gives minimal 68information like the name of the software and maybe a version. 69But it is always preferred, that the `CONFIG_SBOM_[software-name]_PATH` 70is set to a custom CoSWID/SWID file that contains much more information 71(like version/commit-hash, license, URL, dependencies, ...). 72Therefore using the defaults is by any means to be avoided, since they 73hold very little information or even worse wrong information. 74Furthermore some of these Kconfig options have a suboption 75(usually called `CONFIG_SBOM_[software-name]_GENERATE`) to generate 76some basic SBOM data for the specified software component, in order to 77get at least some bit of information about it by analyzing the binary 78(for binary blobs) or querying information via git (for open source 79projects). This is for example currently done for all payloads. For 80each payload the commit hash used in the build is taken and put into 81the SBOM file. For open-source projects (like all payloads) crucial 82information like the current commit-hash of the payload can easily be 83put into the SBOM file. Extracting information out of binary blobs is a 84bit trickier for obvious reasons. For closed source binary blobs it is 85therefore recommended that vendors and software-engineers create a SBOM 86file as part of their build process and add a path to that SBOM file 87via Kconfig options in coreboot (`CONFIG_SBOM_[software-name]_PATH`). 88That way the final SBOM has much more useful and correct data. 89 90 91## Build coreboot with SBOM 92 93Directly under the 'General setup' Kconfig menu is a 94'Software Bill of Materials (SBOM)' submenu where all options are to 95enable/disable SBOM integration in to the corebeoot build. 96Therefore one can just enable/disable them via `make menuconfig`. 97 98 99## What to do as Developer of a binary blob (which is used in coreboot) 100 1011. Generate a SWID/CoSWID/uSWID File in either JSON, XML or CBOR Format 102as part of your software build process 103 1042. Supply that generated File along with your binary blob (preferably 105not inside the blob) 106 1073. To build coreboot: Add `CONFIG_SBOM_[software-name]_PATH` to your 108defconfig pointing to your [software-name] generated File. 109 110 111## What to do as Developer of an open source project (which is used in coreboot) 112 1131. Generate a SWID/CoSWID/uSWID file in either JSON, XML or CBOR format 114as part of your software's build process. For example in form of a 115Makefile target. 116 1172. Change src/sbom/Makefile.mk (in order to know where to find the 118CoSWID/SWID/uSWID file) as well as the Makefile in coreboot which 119builds said software. For example for GRUB2 that could mean to add a 120Makefile target in payloads/external/GRUB2/Makefile. 121 122 123## Problems 124 125What to do if the binary blob that is included in coreboot's build 126already has a SBOM file embedded in the binary? One could supply the 127path of the software binary itself (e.g. me.bin) as SBOM file path for 128the software in question. Which would basically mean to set 129`CONFIG_SBOM_[software-name]_PATH=/path/to/me.bin`. This is possible 130since the 'goswid' tooling is able to extract uSWID information out of 131an unknown binary format because of uSWIDs magic value. But even if 132coreboot can extract the uSWID data there is still the question of what 133to do next. One can do one of the following: 134 135 - Do not include the Software's SBOM data in the final SBOM of 136 coreboot. Data would not be duplicated, but therefore not included 137 in coreboot SBOM file. 138 139 - Extract the uSWID/CoSWID information from the binary and also 140 include it in the coreboot SBOM. That would mean, that SBOM data 141 is duplicated. 142 143The first solution should in general be preferred, since its no 144problem if SBOM data is located at multiple locations/binaries if they 145don't have a direct dependency on each other. It would be good if 146software that cannot run on its own only supplies the SBOM data along 147with it as kind of extra file instead of embedded in an unknown binary 148blob. coreboot can then just take it and include it in its own SBOM 149file. If on the other hand the binary can function on its own (e.g. EC 150or BMC binary), it is generally preferred that the software supplies 151its own SBOM data and coreboot just simply doesn't include it in its 152own SBOM file. That would make a more or less clear distinction and 153avoids duplication in case the BMC or EC is updated (without updating 154coreboot). The distinction is not always easy and this problem is 155currently not considered in the implementation, since none of the 156software components currently create a SBOM file on their own. 157