{"id":2041,"date":"2025-01-17T14:47:25","date_gmt":"2025-01-17T22:47:25","guid":{"rendered":"https:\/\/wp.c9h.org\/cj\/?p=2041"},"modified":"2025-02-19T14:42:55","modified_gmt":"2025-02-19T22:42:55","slug":"security-concerns-regarding-openssh-mac-sha1-in-debian","status":"publish","type":"post","link":"https:\/\/wp.c9h.org\/cj\/?p=2041","title":{"rendered":"Security concerns regarding OpenSSH mac sha1 in Debian"},"content":{"rendered":"<p>What is HMAC?<\/p>\n<p>HMAC stands for Hash-Based Message Authentication Code. It&#8217;s a specific way to use a cryptographic hash function (like SHA-1, SHA-256, etc.) along with a secret key to produce a unique &#8220;fingerprint&#8221; of some data. This fingerprint allows someone else with the same key to verify that the data hasn&#8217;t been tampered with.<\/p>\n<p>How HMAC Works<\/p>\n<p>Keyed Hashing: The core idea is to incorporate the secret key into the hashing process. This is done in a specific way to prevent clever attacks that might try to bypass the security.<br \/>\nInner and Outer Hashing: HMAC uses two rounds of hashing. First, the message and a modified version of the key are hashed together. Then, the result of that hash, along with another modified version of the key, are hashed again. This two-step process adds an extra layer of protection.<\/p>\n<p>HMAC in OpenSSH<\/p>\n<p>OpenSSH uses HMAC to ensure the integrity of messages sent back and forth during an SSH session. This prevents an attacker from subtly modifying data in transit.<\/p>\n<p>HMAC-SHA1 with OpenSSH: Is it Weak?<\/p>\n<p>SHA-1 itself is considered cryptographically broken. This means that with enough computing power, it&#8217;s possible to find collisions (two different messages that produce the same hash). However, HMAC-SHA1 is generally still considered secure for most purposes. This is because exploiting weaknesses in SHA-1 to break HMAC-SHA1 is much more difficult than just finding collisions in SHA-1.<\/p>\n<p>Should you use it?<\/p>\n<p>While HMAC-SHA1 might still be okay for now, it&#8217;s best practice to move to stronger alternatives like HMAC-SHA256 or HMAC-SHA512. OpenSSH supports these, and they provide a greater margin of safety against future attacks.<\/p>\n<p>In Summary<\/p>\n<p>HMAC is a powerful tool for ensuring data integrity. Even though SHA-1 has weaknesses, HMAC-SHA1 in OpenSSH is likely still safe for most users. However, to be on the safe side and prepare for the future, switching to HMAC-SHA256 or HMAC-SHA512 is recommended.<\/p>\n<p>Following are instructions for creating dataproc clusters with sha1 mac support removed:<\/p>\n<p>I can appreciate an excess of caution, and I can offer you some code to produce Dataproc instances which do not allow HMAC authentication using sha1.<\/p>\n<p>Place code similar to this in a <a href=\"https:\/\/cloud.google.com\/compute\/docs\/instances\/startup-scripts\/linux\">startup script<\/a> or an <a href=\"https:\/\/cloud.google.com\/dataproc\/docs\/concepts\/configuring-clusters\/init-actions\">initialization action<\/a> that you reference when creating a cluster with <a href=\"https:\/\/github.com\/LLC-Technologies-Collier\/dataproc-repro\/blob\/d6641dd936c2dc812704239002c695e964ffedda\/shared-functions.sh#L62\">gcloud dataproc clusters create<\/a>:<\/p>\n<pre>\n#!\/bin\/bash\n# remove mac specification from sshd configuration\nsed -i -e 's\/^macs.*$\/\/' \/etc\/ssh\/sshd_config\n# place a negative MACs specification in the \/etc\/ssh\/sshd_config.d\/ config directory\nmkdir -p \/etc\/ssh\/sshd_config.d\nssh -Q mac | perl -e \\\n  '@mac=grep{ chomp; \/sha1\/ }<STDIN>; print(\"MACs -\", join(\",\",@mac), $\/)' >> \\\n  \/etc\/ssh\/sshd_config.d\/disable-mac-sha1.conf\n# reload the new ssh service configuration\nsystemctl reload ssh.service\n<\/pre>\n<p>If this code is hosted on GCS, you can refer to it with <\/p>\n<pre>--initialization-actions=CLOUD_STORAGE_URI,[...]<\/pre>\n<p>or<\/p>\n<pre>--metadata startup-script-url=CLOUD_STORAGE_URI,[...]<\/pre>\n\n<div class=\"twitter-share\"><a href=\"https:\/\/twitter.com\/intent\/tweet?via=cjamescollier\" class=\"twitter-share-button\">Tweet<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>What is HMAC? HMAC stands for Hash-Based Message Authentication Code. It&#8217;s a specific way to use a cryptographic hash function (like SHA-1, SHA-256, etc.) along with a secret key to produce a unique &#8220;fingerprint&#8221; of some data. This fingerprint allows someone else with the same key to verify that the data hasn&#8217;t been tampered with. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[328,322,313,307,124,17,79,316,330,317,47,225,232,102,329,261,166,8],"tags":[],"class_list":["post-2041","post","type-post","status-publish","format-standard","hentry","category-328","category-bookworm","category-bullseye","category-buster","category-cryptography","category-debian","category-free-software","category-gcp","category-google-cloud-dataproc","category-google-cloud-support","category-linux","category-nist","category-nsa","category-open-source","category-openssh","category-production","category-software","category-work"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1YDIB-wV","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/posts\/2041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2041"}],"version-history":[{"count":5,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/posts\/2041\/revisions"}],"predecessor-version":[{"id":2051,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=\/wp\/v2\/posts\/2041\/revisions\/2051"}],"wp:attachment":[{"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.c9h.org\/cj\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}