GMOサイバーセキュリティbyイエラエ「ネットde診断」向けにcrypt-policiesをカスタマイズしてみた。

シェアする

CentOS8のcrypt-policiesカスタマイズに挑戦。

GMOサイバーセキュリティbyイエラエ「ネットde診断」向けにcrypt-policiesをカスタマイズしてみた。

サイバーセキュリティ、というと大仰ですがサーバのセキュリティチェックを外部から簡単にやってくれるのは凄く助かります。そういうサービスをGMOサイバーセキュリティbyイエラエが「ネットde診断」として提供中。

で、いま出ている診断結果でこれをなんとかしたい。

脆弱な SSH 暗号アルゴリズムのサポート
診断対象の SSH プロトコルにおいて、脆弱な暗号化方式(aes192-ctr)および脆弱な鍵交換方式(diffie-hellman-group14-sha256, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, sntrup761x25519-sha512@openssh.com)および脆弱なメッセージ認証符号(hmac-sha1, hmac-sha1-etm@openssh.com, hmac-sha2-256, hmac-sha2-512, umac-128@openssh.com)をサポートしていることを確認しました。
想定される影響
脆弱な暗号化方式では十分に安全な通信を提供することができないため、通信内容が盗聴および改ざんされる可能性があります。
対策方法
・脆弱な暗号化方式の無効を推奨いたします。 ・脆弱な鍵交換方式の無効を推奨いたします。

CentOS8のセキュリティカスタマイズ

元々サーバ設定はあまり詳しくないのですが、知らないなりに色々見ていると指摘の入っているSSH周りはsshd_configにcipherなどのエントリを追加して、別のファイルをこうするとできますよ、という説明が出てきます。その通りやってみますが全然反映されず。で、さらに調べるとこういう話が。

※ Red Hat/CentOSの8.x系では、crypto-policiesという仕組みが導入され、sshdの起動引数としてシステムで規定された暗号化方式が指定される仕様になりました。
sshdの引数で指定される設定は、設定ファイルよりも優先順位が高いため、OpenSSH設定ファイルの暗号化関連の設定は反映できなくなりました。
https://qiita.com/aqmr-kino/items/8c3306ea8022b0d5cbe4

なんだよー。で、生半可にcrypto-policiesの設定を変更して、

update-crypto-policies -SET FUTURE

とかやって、しばらくサーバを通信不能にしてしまいました。基本的にこの仕組みはLEGACYやDEFAULTといったセキュリティテンプレート?を指定してセキュリティレベルを決める仕組みみたいですが、FUTUREだと止まっちゃうしDEFAULTだとネットde診断で指摘が出るし……カスタマイズってできないの?と調べてみたのがこれ。

https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/8/html/security_hardening/customizing-system-wide-cryptographic-policies-with-subpolicies_using-the-system-wide-cryptographic-policies

debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,ext-info-c
debug2: host key algorithms: ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256
debug2: ciphers ctos: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes128-gcm@openssh.com,aes128-ctr
debug2: ciphers stoc: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes128-gcm@openssh.com,aes128-ctr
debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512
debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib

とりあえずpmodに

mac = -HMAC-SHA1*

と追記して

udpate-crypto-policies --set DEFAULT:IERAE

とすると、

debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512

debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,umac-128@openssh.com,hmac-sha2-512

とhmac-sha1関連が消えました。ちゃんと反映されるにはリブートする必要があるようですがとりあえずまずはここまで。これで1つ1つネットde診断の指摘されている形式を消し込みながら、ちゃんとSSH接続が維持されるかどうかをチェックしてpmodファイルを作っていく、という感じですかね……。

この記事が気に入ったら
いいね!お願いします