$30 off During Our Annual Pro Sale. View Details »

AWS KMSだけじゃない鍵管理

bc/web3@loft
July 03, 2023
120

AWS KMSだけじゃない鍵管理

bc/web3@loft

July 03, 2023
Tweet

Transcript

  1. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    AWS KMSだけじゃない鍵管理

    View Slide

  2. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    名前
    中武 優樹(なかたけ ゆうき) aka ザビオ
    Twitter: @zabbiozabbio
    所属
    Sr. Blockchain/Web3
    Specialist Solutions Architect
    前職
    DeNA -> スタートアップ -> AWS
    好きなAWSサービス
    Amazon Managed Blockchain, AWS KMS
    ⾃⼰紹介
    最近の興味
    EIP-4844、EIP-6551、zkRollup

    View Slide

  3. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    みなさん鍵管理してますか?
    KMS使ってますか?

    View Slide

  4. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    AWS Key Management Service
    • 暗号鍵の管理を⼀元化
    • 鍵の機密性、可⽤性を確保
    • アクセスニーズに合わせて⾃動的にスケール
    • 様々なAWSサービスとのインテグレーション
    • 2019年11⽉にsecp256k1を含む公開鍵を
    サポート。Sign API で鍵を取り出すことなく
    データへの署名が可能に
    フルマネージドの暗号鍵管理サービス
    Data Key 1
    Amazon
    S3 Object
    Amazon EBS
    Volume
    Amazon
    Redshift
    Cluster
    Data Key 2 Data Key 3
    AWS KMS

    View Slide

  5. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    ありがとうございます
    https://speakerdeck.com/odanado/tokyo-blockchain-tech-meetup-2022
    https://pages.awscloud.com/rs/112-TZM-766/images/CUS-34_AWS-Summit-2022_double-jump.tokyo.pdf
    and more…

    View Slide

  6. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    ただしこのあたりは課題
    • AWS KMSはsecp256k1楕円曲線をサポートしていますが、bls12-
    381(Ethereum 2)のような代替曲線には対応していません。
    • 鍵管理のためのマルチテナントコンポーネントは、
    コンプライアンス要件を満たせない可能性があります。
    • KMSキー(ブロックチェーンアカウント)は、その使用量とは関
    係なく、鍵1つにつき月額1ドルの課金が発生します。
    • Ethereum用のgethやFantom用のoperaのような提供されている
    ブロックチェーンクライアントは、AWS KMSのネイティブサポー
    トを持っておらず、秘密鍵がファイルシステム上で利用可能であ
    ることが必要です

    View Slide

  7. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    AWS Nitro Enclaves
    • 隔離されたコンピュート環境
    • 実行時にエンクレーブ内で実行されるコードの検証
    • エンクレーブハッシュ(暗号証明)に基づくKMSの
    きめ細かい権限管理
    • ソフトウェアで実装されたハードウェアセキュリ
    ティモジュール(HSM)に似ている
    そうだ Nitro Enclaves使えるじゃん

    View Slide

  8. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    Nitro Enclavesの概要
    高度な機密情報の保護や安全措置のための分離されたコンピューティング環境
    • 独⾃のカーネル・CPU・メモリを持つ仮想マシン
    • 外部とのネットワーク通信、永続ストレージ、イ
    ンタラクティブアクセスの機能が無く、攻撃対象
    領域を⼤幅に削減
    • 親インスタンスとのみセキュアなローカル接続
    • ⾃組織内のシステム管理者、開発者、OS、アプ
    リケーションによるアクセスから、機密データ処
    理を分離
    セキュアな分離
    柔軟性のある
    リソース割当て
    様々なワークロードを
    サポート
    EC2 インスタンス
    Users 3rd Party
    Libraries
    Applications OS Encrypte
    d data
    Plaintext
    for
    processing
    Enclaves
    (分離された処理領域)
    Secure local channel

    View Slide

  9. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    AWS Nitro Enclaves の起動までの流れ
    • AWS Nitro Enclaves SDK : Enclaveアプリケーション開発や既存アプリケーションをEnclaveで動
    かすためのライブラリ。 オープンソースとして提供。
    • Enclave image file (.eif) : Linux OS、ライブラリ、Enclaveアプリケーションを含んだファイル。
    Enclave起動に必要。
    • AWS Nitro Enclaves CLI : Enclaveを作成・終了などの管理や .eifファイルを作成するコマンドラ
    インツール。親インスタンスにインストールし実行する
    Enclave Image File (.eif)
    Application
    Docker
    build
    Docker file
    Docker Image
    4 vCPU
    Memory : 8 GiB
    C5.xlarge
    C5.xlarge
    Nitro
    CLI
    Nitro
    CLI
    2 vCPU
    Memory : 4 GiB
    2 vCPU
    Memory : 4 GiB
    .eif作成
    Enclave起動
    親インスタンス 親インスタンス
    Application
    Enclave
    Nitro
    CLI

    View Slide

  10. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    EC2 HOST
    Nitro Hypervisor
    暗号化証明(Cryptographic attestation)と構成証明ドキュ
    メント
    • Enclaveで許可されたコードのみが実行されているこ
    とを証明する仕組み
    • Nitro Hypervior内のNitroSecureModule(NSM)に対し
    てリクエストすることで、Nitro Hypervisorから署名
    された構成証明ドキュメントを取得。 Enclave内か
    らのみ取得可能
    • 外部サービス/アプリは、Enclaveからのリクエスト
    に付与される構成証明ドキュメントを参照しリクエ
    スト元Enclaveが許可されたEnclaveかを判断可能
    Parent instance Nitro Enclave
    署名された
    構成証明ドキュメント
    App
    https://github.com/aws/aws-nitro-enclaves-sdk-c
    https://github.com/aws/aws-nitro-enclaves-nsm-api/blob/main/docs/attestation_process.md
    NSM

    View Slide

  11. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    AWS Key Management Service (KMS)との統合
    • AWS Service integration
    • Enclaves内でAWS Nitro Enclaves SDKを使用しKMSの
    操作が可能
    • KMS操作はEnclavesの暗号的構成証明プロセスと密に
    連携
    • KMSは、Enclaveから送信された構成証明ドキュメント
    の内容 ( PCRとハッシュ)がKMSのキーポリシーと一致
    することを確認し、鍵へのアクセスを許可
    • 親インスタンスからのアクセスは構成証明ドキュメン
    トが無いためアクセスできない
    • EnclavesからKMSへの通信はKMS proxyと親インスタ
    ンスのネットワークを通じてセキュアに行われる。
    KMS ProxyはNitro CLIに同梱され、親インスタンスで
    実行
    https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave-concepts.html#term-proxy
    https://docs.aws.amazon.com/kms/latest/developerguide/services-nitro-enclaves.html
    AWS Key Management
    Service
    Parent instance Nitro Enclave
    KMS Proxy 署名された
    構成証明ドキュメント
    App App
    Acces
    s
    署名された
    構成証明ドキュメント
    NSM

    View Slide

  12. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    例:KMSを使った機密データ処理の流れ
    AWS Key Management
    Service
    Parent instance Nitro Enclave
    KMS Proxy
    構成証明
    ドキュメント
    暗号化された
    データキー
    署名された
    構成証明ドキュメント
    NSM
    Amazon S3
    暗号化され

    機密データ
    暗号化され

    データキー
    1 データストアにある暗号化した機密データと暗号
    化されたデータキーをEnclaves 内に読込み
    暗号化されたデータキーの復号リクエストを
    KMSへ送信。構成証明ドキュメントも送付
    KMS はEnclaveの身元を検証した後、データ
    キーを復号してEnclaveに返す
    署名された構成証明ドキュメントを取得
    2
    3
    4
    5 復号したデータキーで機密データを復号し、平
    文の機密データに対する演算処理を行う
    Amazon RDS
    2
    3
    4
    復号したデータキー
    5
    復号された
    機密データ
    1

    View Slide

  13. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    AWS Cloud
    VPC
    Private subnet Public subnet
    AWS Secrets Manager AWS Key Management
    Service (AWS KMS)
    Amazon Elastic Container
    Registry (Amazon ECR)
    AWS Systems Manager
    AWS Lambda
    AWS Management
    Console
    NLB
    ASG
    Internet gateway
    EC2 EC2
    AWS Nitro
    Enclaves
    AWS Nitro
    Enclaves
    Amazon Managed
    Blockchain
    Private subnet
    Overview Architecture

    View Slide

  14. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark. 15
    Amazon EC2 instance
    Nitro enclave
    vsock-proxy
    (systemd)
    signing_server
    http_server
    AWS KMS
    vsock
    Attestation
    document
    AWS Secrets
    Manager
    signing_enclave
    Watchdog
    (systemd)
    Actor
    kmstools-enclave-cli

    View Slide

  15. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    KMS vs Nitroenclaves
    • トータルコスト
    • 充分なコンピュータリソースが必要
    • マネージドな範囲
    • より厳格なコンプライアンス

    View Slide

  16. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    Sample code はこちら
    https://github.com/aws-samples/aws-nitro-enclave-blockchain-
    wallet

    View Slide

  17. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Confidential and Trademark.
    Thank you!
    Good key management Life!

    View Slide