{"id":238121,"date":"2022-12-29T08:37:00","date_gmt":"2022-12-29T13:37:00","guid":{"rendered":"https:\/\/wordpress-756359-3782526.cloudwaysapps.com\/?p=238121"},"modified":"2024-09-21T04:53:25","modified_gmt":"2024-09-21T04:53:25","slug":"22-12-29-security-singing","status":"publish","type":"post","link":"https:\/\/www.travis-ci.com\/blog\/22-12-29-security-singing\/","title":{"rendered":"Sign your software with Travis CI"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>Software Supply Chain security is the act of securing the components, activities, and practices involved in creating and deploying software. One of these practices is digitally signing the software by the developers before releasing it. The digital certificate serves the purpose of ensuring that the software has not been tampered with and the receiver can safely download it.<\/p>\n\n\n\n<p>Now, before you deploy your software with a CI\/CD system, you can securely sign it using Travis CI.<\/p>\n\n\n\n<p>After the President of the United States issued the Executive Order in May 2021, the software development industry, and CI\/CD community in particular, are experiencing a significant rise in security awareness and features that improve software vendors\u2019 ability to comply with the Secure Software Supply Chain initiative. Whether you are a small software team or a large, established software provider, you may face the following requirements:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A Software Bill of Materials (SBOM) along with your releases.<\/li>\n\n\n\n<li>Regular security scan reports must be executed.<\/li>\n\n\n\n<li>Software release, be it binary files, source code package, or container image(s) with your application or system, must be securely signed.<\/li>\n<\/ul>\n\n\n\n<p>Modern CI\/CD systems, to ease and automate satisfying the above requirements, integrate with tooling that allows the generation of the required elements in your CI\/CD process. Travis CI is no different.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-securely-signing-software-server-side\">What is securely signing software? (Server Side)<\/h2>\n\n\n\n<p>Let\u2019s take a Docker image for example, signing is the process of digitally signing the Docker images to confirm the software author\u2019s identity, think of it as a PGP key to a degree. It provides assurance that the code has not been altered or compromised. There\u2019s two ways Image Singing can work:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>At the client side.<\/li>\n\n\n\n<li>At the server side.<\/li>\n<\/ul>\n\n\n\n<p>Let\u2019s take you through the process in a graphic of how it would work on the server side:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"806\" src=\"https:\/\/www.travis-ci.com\/wp-content\/uploads\/2022\/12\/210028387-b0c6504e-f690-4a7d-bd20-8b1c2e5deef7-1024x806-1.png\" alt=\"\" class=\"wp-image-240068\" srcset=\"https:\/\/www.travis-ci.com\/wp-content\/uploads\/2022\/12\/210028387-b0c6504e-f690-4a7d-bd20-8b1c2e5deef7-1024x806-1.png 1024w, https:\/\/www.travis-ci.com\/wp-content\/uploads\/2022\/12\/210028387-b0c6504e-f690-4a7d-bd20-8b1c2e5deef7-1024x806-1-300x236.png 300w, https:\/\/www.travis-ci.com\/wp-content\/uploads\/2022\/12\/210028387-b0c6504e-f690-4a7d-bd20-8b1c2e5deef7-1024x806-1-768x605.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Any registry or runtime that claims to have a certain Docker distribution image specification support will be interacting with the various manifest types. Now that you have an idea of how it works on the server-side, it\u2019s worth taking you step-by-step on just how it is the server-side works once more:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The original image (sometimes called the manifest), is firstly hashed by a hashing algorithm, this is usally called \u2018salting\u2019. Salting is simply a randomly chosen bit pattern that is combined with the image before it is hashed by a hashing algorithm, the flow is as follows, if&nbsp;<code>equal<\/code>&nbsp;then image is&nbsp;<code>not<\/code>&nbsp;tampered.<\/li>\n\n\n\n<li>The hashed Docker image we get is then signed by the private key of the developer themselves.<\/li>\n\n\n\n<li>The signed hash docker image is then packed with the original image and digital certificate, which together are also known as an image signing certificate.<\/li>\n\n\n\n<li>Now, it can be uploaded or transferred to the customer.<\/li>\n<\/ul>\n\n\n\n<p>You can in fact query DockerHub about the signatures and signatories status of a repository with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker trust inspect --pretty travisci\/signatures<\/code><\/pre>\n\n\n\n<p>This will list the notaries behind the image.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"client-side\">Client Side<\/h2>\n\n\n\n<p>Now, let\u2019s go through how the process takes place on the client side:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"643\" src=\"https:\/\/www.travis-ci.com\/wp-content\/uploads\/2022\/12\/210028171-e1d8f064-90c8-42b4-974a-26ce3f6c65a4-1024x643-1.png\" alt=\"\" class=\"wp-image-240067\" srcset=\"https:\/\/www.travis-ci.com\/wp-content\/uploads\/2022\/12\/210028171-e1d8f064-90c8-42b4-974a-26ce3f6c65a4-1024x643-1.png 1024w, https:\/\/www.travis-ci.com\/wp-content\/uploads\/2022\/12\/210028171-e1d8f064-90c8-42b4-974a-26ce3f6c65a4-1024x643-1-300x188.png 300w, https:\/\/www.travis-ci.com\/wp-content\/uploads\/2022\/12\/210028171-e1d8f064-90c8-42b4-974a-26ce3f6c65a4-1024x643-1-768x482.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The original Docker image is passed through a hashing algorithm, to get the hash of the image, in other words at this point the image is being \u201csalted.\u201d<\/li>\n\n\n\n<li>The public key is extracted from the certificate and applied to the signed hash of the Docker image to extract the hash of the image, at this point you can see the notaries.<\/li>\n\n\n\n<li>Both the hashes created from steps 1 and 2 are compared, and if both the hashes are the same then the image has not been changed and the signature is considered valid.<\/li>\n\n\n\n<li>At the same time, the image signing certificate is checked to ensure it was signed by a trusted CA. The expiry date of the image signing certificate is checked, and the certificate is also checked against the revocation lists to ensure it is valid.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-sign-your-software-with-travis-ci\">How to sign your software with Travis CI<\/h2>\n\n\n\n<p>Travis CI offers the ability to sign your software using the&nbsp;<em><a href=\"https:\/\/github.com\/sigstore\/cosign\">cosign<\/a><\/em>&nbsp;tool and a key.<\/p>\n\n\n\n<p><em>Cosign<\/em>&nbsp;is a part of the&nbsp;<a href=\"https:\/\/www.sigstore.dev\/\">Sigstore project<\/a>, which helps to ensure the tooling required for the Secure Software Supply Chain.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"have-a-dedicated-key-for-signing-the-software-ready\">Have a dedicated key for signing the software ready<\/h2>\n\n\n\n<p>To sign your software with Travis CI, you need to have a dedicated key ready. To obtain a dedicated key, you have two options:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can upload a passwordless SSH key in PEM format to Travis CI account (either personal or organization settings) &#8211; there\u2019s a new option called \u2018SSH Key for build jobs\u2019 in the settings tab; scroll down to the bottom.<\/li>\n\n\n\n<li>The second option is, you can have a self-managed Hashicorp Vault, to which Travis CI can have access and store key there, available for obtaining by a user associated with Travis CI.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"sign-the-container-image-during-the-build-job\">Sign the container image during the build job<\/h2>\n\n\n\n<p>If you are using a key uploaded to Travis CI, use the following examples:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>keys:\n  - SSH_KEY_FOR_SIGNING # must match the key identifier set in the UI<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>env:\n  secret: \u201c...\u201d # encrypted COSIGN_PASSWORD=...  string; see cosign doc<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>before_script: \n  - travis_key SSH_KEY_FOR_SIGNING cosign.key  # cosign requires the key to be in a file<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>script: \n  - cosign sign --key cosign.key &#91;whatever_the_image_identifier_is]<\/code><\/pre>\n\n\n\n<p>If you prefer to obtain the key directly from Hashicorp Vault during the build job, try the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vault:\n  api_url: &#91;single value endpoint address:port] #mandatory\n  token:\n    secure: \u201c...\u201d #mandatory\n    # This will make the default VAULT_ADDR and VAULT_TOKEN available for cosign.<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>script:\n  - cosign sign --key hashivault:\/\/some-key-identifier &#91;whatever_the_image_identifier_is]<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"deploy-the-release-or-container-image\">Deploy the release or container image<\/h2>\n\n\n\n<p>Once the file or container image is signed, you can deploy it to the designated location, much like you did up until now.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"considerations\">Considerations<\/h2>\n\n\n\n<p>Since the Securely Signing Software is meant to authenticate the release, it is very important to protect the key used for signing. There are certain security considerations, especially for cloud CI\/CD systems, which are a surface of attack for malicious actors. The details will vary between CI\/CD providers, e.g., depending on whether the build logs are public or private, the exact mechanisms used to deliver a key to the jobs, access control, and specific settings.<\/p>\n\n\n\n<p>Please make sure you familiarize yourself with the respective section of our documentation page for Securely Signing Software whenever you consider securely signing your software using Travis CI.<\/p>\n\n\n\n<p>Read more:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.travis-ci.com\/user\/securely-signing-software\">Securely Signing Software documentation page<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.travis-ci.com\/user\/hashicorp-vault-integration\">Hashicorp Vault Integration documentation<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Software Supply Chain security is the act of securing the components, activities, and practices involved in creating and deploying software. One of these practices is digitally signing the software by the developers before releasing it. The digital certificate serves the purpose of ensuring that the software has not been tampered with and the receiver can [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_breakdance_hide_in_design_set":false,"_breakdance_tags":"","footnotes":""},"categories":[16],"tags":[7,19,20,5],"class_list":["post-238121","post","type-post","status-publish","format-standard","hentry","category-news","tag-community","tag-feature","tag-infrastructure","tag-news"],"_links":{"self":[{"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/posts\/238121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/comments?post=238121"}],"version-history":[{"count":1,"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/posts\/238121\/revisions"}],"predecessor-version":[{"id":240069,"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/posts\/238121\/revisions\/240069"}],"wp:attachment":[{"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/media?parent=238121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/categories?post=238121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/tags?post=238121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}