Share
Embed
Confidential VM 時代の今こそ、OS を丸ごと形式検証しよう〜Ironclad Apps (OSDI '14) 再訪〜
2026年11月27日に開催された、「Confidential Computing勉強会」の登壇資料です。
▼イベントの詳細
https://acompany.connpass.com/event/407013/
Annual Pro sale · Save $30
Have presentations of your own?
Share with private links, password protection, and more control over your work.
Transcript
40 slides
-
Confidential Confidential VM VM 時代の今こそ、 時代の今こそ、 OS OS を丸ごと形式検証しよう を丸ごと形式検証しよう
〜 Ironclad Apps (OSDI ’14) 再訪 〜 〜 〜 Ironclad Ironclad Apps Apps (OSDI (OSDI ’14) ’14) 再訪 再訪 〜 〜 〜 Ironclad Apps (OSDI ’14) 再訪 〜 椎名 峻平(Acompany AI Lab) 2026.11.27 Confidential Computing 勉強会 #1 © Acompany Co., Ltd. 1 -
01 背景 Intel SGX は終了し、Confidential VM の時代へ Intel SGX Confidential
VM アプリケーション TEE (Confidential VM) TEE 保護されない プログラム プログラム OS アプリケーション ゲスト OS ホスト / ハイパーバイザ プログラムレベルの隔離 TEE 上で OS を丸ごと動かす 独自の SDK を用いた開発が必要 Intel TDX, AMD SEV-SNP など 2026 年 10 月に廃止方針を発表1 既存ソフトウェアの改変不要 しかしセキュリティは…? © Acompany Co., Ltd. 1 Intel, Transition Paths for Intel® SGX Applications to Intel® TDX (2026-10-09) 2 -
01 背景 Confidential VM のセキュリティ OS 全体が信頼の対象となる(TCB に含まれる)ため、SGX と比べて攻撃界面が増大 TEE
(Confidential VM) アプリケーション 依存ライブラリ・ツール すべて信頼対象! ゲスト OS(Linux など) 想定される脅威: × Linux カーネルの脆弱性 権限昇格により root 権限を奪われる メモリへの直接アクセス ホスト / ハイパーバイザ サプライチェーン攻撃 依存ライブラリやツールに悪意あるコードが混入 設定ミスによる侵入 SSH などの設定不備で第三者が OS にログイン … © Acompany Co., Ltd. 3 -
01 背景 OS・アプリケーション全体の安全性をどう検証するか? 一般的な対策 形式検証 Linux や依存ライブラリの脆弱性情報を追い かけ、いち早くパッチを適用 仕様を形式的に記述し、実装が仕様を満たす ことを機械的に検証
実装・設定内容を専門家が徹底的にレビュー 具体的なテストケースに依存せず、論理で 安全性を保証することが可能 テストの数・コーナーケースを増やす AI 脆弱性診断の活用 … などなど、アドホックな対策が必要 TEE を使っていない場合と大きく 変わらない…? © Acompany Co., Ltd. 仕様のレビューは必須 仕様が TCB に含まれ、実装は TCB から 外せる(検証ツール自体の実装は TCB) 堅牢なソフトウェアを作れそう。 しかし OS 含めたシステム全体を 形式検証するのは現実的? 4 -
01 背景 近年の AI による形式検証・証明 従来は専門家でも莫大な時間がかかっていた形式化・証明の記述が、高性能な AI によって大幅に効率化 Anthropic Microsoft
Research 既存ライブラリのバイナリ検証 Proof-Driven Development Kit 既存ライブラリのバイナリを 直接検証、一定の安全性を証明 煩雑な証明の記述は AI が担い、 Rocq で検証 LLMs are making formal software verification feasible at a much larger scale (2026-10-22) © Acompany Co., Ltd. Google DeepMind AlphaProof Code AI が仕様・実装・証明の 作成を支援する 開発フレームワーク Signal の暗号通信実装の バイナリを直接検証し、 機密性・認証などを証明 Rust 製 Web アプリの ログイン処理を Verus で検証 AI が証明を記述、Lean で検証 Formally verifying agent-written full-stack web apps with PDD Kit (2026-11-05) AlphaProof Code: Verifying Signal’s Security at the Machine-Code Level (2026-11-10) 5 -
01 背景 OS を丸ごと形式検証する、というアプローチ AI が証明記述を担う現代では、OS 全体の形式検証も現実的な手段に? OS カーネルを丸ごと形式検証する研究は以前から存在(seL4 など)
seL4:2009 年に C 言語レベルの正しさを検証1、 2013 年にバイナリのレベルの意味論まで拡張2 しかし証明コストが高く、機能も限定的 seL4 の 2009 年の検証では約 20 人年と報告(検証ツールなどの開発を含む) 対象は小さなマイクロカーネルで、ドライバやネットワークなども含む、Linux 相当の OS 全体の 検証とは大きな隔たり 今回は、OS・アプリ全体の形式検証を可能にする Ironclad Apps (OSDI ‘14)3 に注目 OS・ライブラリ・ドライバまで含む実行バイナリ全体が、アプリの仕様を満たすことを検証 seL4 ではカーネル自体の安全性(隔離の保証など)が目的で、アプリ含めた全体の証明は対象外 © Acompany Co., Ltd. 1 seL4: Formal Verification of an OS Kernel (SOSP ‘09) 2 Translation Validation for a Verified OS Kernel (PLDI ‘13) 3 Ironclad Apps: End-to-End Security via Automated Full-System Verification (OSDI ‘14) 6 -
02 Ironclad Apps (OSDI ‘14) 紹介 Ironclad Apps (OSDI ‘14)
概要 Microsoft Research、ペンシルベニア大学、 コーネル大学の研究者による共同研究 OS からアプリまで を一貫して形式検証。 ランタイム・ライブラリ・ドライバも含む Dafny で仕様・実装を記述し、仕様を満たす ことを x86 アセンブリのレベルで保証 リモートアテステーション で、 検証済みコードの実行を利用者が確認 TEE ではなく TPM を用いる SGX 製品化(2015 年)以前の研究(!) 4 種類のアプリを実装し、評価 © Acompany Co., Ltd. Ironclad Apps: End-to-End Security via Automated Full-System Verification Chris Hawblitzel, Jon Howell, Jacob R. Lorch, Arjun Narayan† , Bryan Parno, Danfeng Zhang , Brian Zill Microsoft Research † University of Pennsylvania Abstract An Ironclad App lets a user securely transmit her data to a remote machine with the guarantee that every instruction executed on that machine adheres to a formal abstract specification of the app’s behavior. This does more than eliminate implementation vulnerabilities such as buffer overflows, parsing errors, or data leaks; it tells the user exactly how the app will behave at all times. We provide these guarantees via complete, low-level software verification. We then use cryptography and secure hardware to enable secure channels from the verified software to remote users. To achieve such complete verification, we developed a set of new and modified tools, a collection of techniques and engineering disciplines, and a methodology focused on rapid development of verified systems software. We describe our methodology, formal results, and lessons we learned from building a full stack of verified software. That software includes a verified kernel; verified drivers; verified system and crypto libraries including SHA, HMAC, and RSA; and four Ironclad Apps. 1 Introduction Today, when Alice submits her personal data to a remote service, she has little assurance that her data will remain secure. At best, she has vague legal guarantees provided by the service’s privacy policy and the hope that the owner will follow industry best practices. Even then, a vulnerable OS, library, or application may undermine the service provider’s best intentions [51]. In theory, complete formal verification of the service’s code would replace this tenuous position with the strong mathematical guarantee that the service precisely matches Alice’s formally specified security expectations. Unfortunately, while software verification provides strong guarantees [4, 6, 8, 17, 39], the cost is often high [25, 35, 36]; e.g., seL4 took over 22 person-years of effort to verify a microkernel. Some strong guarantees have been obtained in much less time, but those guarantees depend on unverified lower-level code. For example, past work produced a verified TLS implementation [9] and a proof of correctness for RSA-OAEP [7]. In both cases, though, they assumed the crypto libraries, their runtimes (e.g., .NET), and the OS were correct. Cornell University does not assume that any piece of server software is correct. (2) The proof covers the assembly code that gets executed, not the high-level language in which the app is written. Thus, it assumes that the hardware is correct, but assumes nothing about the correctness of the compiler or runtime. (3) The verification demonstrates remote equivalence: that to a remote party the app’s implementation is indistinguishable from the app’s high-level abstract state machine. Verifiable remote equivalence dictates the behavior of the entire system in every possible situation. Thus, this approach provides stronger guarantees than type checkers or tools that look for classes of bugs such as buffer overflows or bounds errors. Our proof of remote equivalence involves proving properties of both functional correctness and information flow; we do the latter by proving noninterference, a relationship between two runs of the same code with different inputs. We then show how remote equivalence can be strengthened to secure remote equivalence via Trusted Computing [3, 53]. Specifically, the app verifiably uses secure hardware, including a TPM [63], to convince a remote client that its public key corresponds to a private key known only to the app. The client uses the public key to establish a secure channel, thereby achieving security equivalent to direct communication with the abstractly specified app [30]. Another goal of our work is to make it feasible to build Ironclad Apps with modest developer effort. Previous efforts, such as seL4 [35] or VCC [13], took tens of personyears to verify one software layer, so verifying an entire stack using these techniques may be prohibitive. To reduce developer effort, we use state-of-the-art tools for automated software verification, such as Dafny [39], Boogie [4], and Z3 [17]. These tools need much less guidance from developers than interactive proof assistants used in previous work [35, 52]. However, many in the verification community worry that automated verification cannot scale to large software and that the tools’ heuristics inevitably lead to unstable verification results. Indeed, we encountered these challenges, and dealt with them in multiple ways: via two new tools (§3.4); via modifications to existing verification Ironclad Apps: End-to-End Security via Automated Full-System Verification (OSDI ‘14) 8 -
02 Ironclad Apps (OSDI ‘14) 紹介 リモートアテステーションでアプリの性質を検証 通常のアテステーション Ironclad におけるアテステーション
遠隔サービス 遠隔サービス 起動の証明 起動の証明 利用者 データの送信 バイナリ 性質は不明 特定のバイナリの OS が起動したことを確認 そのバイナリの性質は、 アテステーションだけではわからない 渡したデータがどう使われるかまでは 検証できない 利用者 データの送信 バイナリ 形式検証済み 仕様を満たすことを、バイナリのレベルまで 形式検証 アテステーションでそのバイナリの起動を 確認 渡したデータが仕様の通りに処理される ことを確認可能 TEE でも同様に、アテステーションと形式検証の組み合わせが重要 © Acompany Co., Ltd. 9 -
02 Ironclad Apps (OSDI ‘14) 紹介 一般的な形式検証(通常の Dafny の場合) アプリ開発者が
Dafny 言語で記述 仕様 実装 高水準の仕様 高水準言語による実装 Dafny の検証器 判定結果 機械語による実装 (x86) 信頼する要素 © Acompany Co., Ltd. コンパイラ ツール 10 -
02 Ironclad Apps (OSDI ‘14) 紹介 一般的な形式検証(通常の Dafny の場合) 仕様
実装 仕様は人が徹底レビュー アプリ開発者が Dafny 言語で記述 高水準の仕様 高水準言語による実装 仕様の抜け・誤りがあれば、 検証に通ってもバグは発生(仕様バグ) Dafny の検証器 判定結果 機械語による実装 (x86) 信頼する要素 © Acompany Co., Ltd. コンパイラ ツール 10 -
02 Ironclad Apps (OSDI ‘14) 紹介 一般的な形式検証(通常の Dafny の場合) アプリ開発者が
Dafny 言語で記述 仕様 実装 高水準の仕様 高水準言語による実装 Dafny の検証器 コンパイラ 判定結果 機械語による実装 (x86) 信頼する要素 ツール 実装は信頼対象から外せる 信頼できる検証器が「この実装は仕様を満たす」と判定すれば、 人がソースコードを読んでその性質を確かめる必要はない。 © Acompany Co., Ltd. 10 -
02 Ironclad Apps (OSDI ‘14) 紹介 一般的な形式検証(通常の Dafny の場合) アプリ開発者が
Dafny 言語で記述 仕様 実装 高水準の仕様 高水準言語による実装 Dafny の検証器 判定結果 コンパイラ 機械語による実装 (x86) 信頼する要素 ツール コンパイラは信頼対象 ソースの検証に通っても、コンパイラのバグでバイナリの挙動が変わりうる 最適化やコード生成の実装も信頼するため、TCB は大きくなりやすい © Acompany Co., Ltd. 10 -
02 Ironclad Apps (OSDI ‘14) 紹介 Ironclad におけるバイナリレベルの形式検証 アプリ開発者が Dafny
言語で記述 仕様 実装 高水準の仕様 高水準言語による実装 仕様変換器(DafnySpec) 検証可能なアセンブリ言語による実装 (BoogieX86) 低水準の仕様 検証器 アセンブラ・リンカ 判定結果 機械語による実装 (x86) 信頼する要素 © Acompany Co., Ltd. コンパイラ(DafnyCC) ツール 11 -
02 Ironclad Apps (OSDI ‘14) 紹介 Ironclad におけるバイナリレベルの形式検証 仕様 実装
コンパイラは信頼しなくてよい アプリ開発者が 高水準の仕様 Dafny x86 言語で記述 のアセンブリレベルで仕様との一致を検証 コンパイラ実装にバグがあった場合は検証が通らない 仕様変換器(DafnySpec) (検証を通すための注釈の挿入など独自実装は必要) コンパイラ(DafnyCC) 検証可能なアセンブリ言語による実装 (BoogieX86) 低水準の仕様 検証器 アセンブラ・リンカ 判定結果 機械語による実装 (x86) 信頼する要素 © Acompany Co., Ltd. 高水準言語による実装 ツール 11 -
02 Ironclad Apps (OSDI ‘14) 紹介 Ironclad におけるバイナリレベルの形式検証 アプリ開発者が Dafny
言語で記述 仕様 実装 高水準の仕様 高水準言語による実装 仕様変換器(DafnySpec) 検証可能な x86 のサブセット コンパイラ(DafnyCC) 先行研究 Verve で使用した BoogieX86 を使用 モデル定義が実機の動作を正しく表すことは 低水準の仕様 検証器として信頼する部分 検証器 アセンブラ・リンカ 判定結果 機械語による実装 (x86) 信頼する要素 © Acompany Co., Ltd. 検証可能なアセンブリ言語による実装 (BoogieX86) ツール 11 -
02 Ironclad Apps (OSDI ‘14) 紹介 Ironclad におけるバイナリレベルの形式検証 アプリ開発者が Dafny
言語で記述 仕様 実装 高水準の仕様 高水準言語による実装 仕様変換器(DafnySpec) コンパイラ(DafnyCC) 検証可能なアセンブリ言語による実装 (BoogieX86) 低水準の仕様 判定結果が true なら、高水準の仕様を満たすバイナリであると保証される 検証器 アセンブラ・リンカ 判定結果 機械語による実装 (x86) 信頼する要素 © Acompany Co., Ltd. ツール 11 -
Total 02 Ironclad Apps (OSDI ‘14) 紹介 3546 6971 33203
41566 10726 76606 TCB (Trusted Computing Base) の行数比較 Table 1: System Line Counts and Verification Times. Asm 通常の Dafny コンパイラを信頼する場合に比べ、TCB が小さい LOC includes both compiled Dafny and hand-written assembly. 通常のコンパイラ(Dafny → C#) 32419 (通常の Dafny では信頼対象) Ironclad 独自のコンパイラ(信頼対象外) Dafny DafnyCC DafnySpec BoogieX86 SymDiff 4292 4718 2182 8402 0 10000 in TCB Ironclad の信頼対象。計 15,302 行 20000 30000 40000 Figure 6: Tool Line Counts. 32,419 SLOC in the original Dafny-to-C# compiler, let alone the code for the C# compiler. Our DafnyCC tool is © Acompany Co., Ltd. ※ Boogie と Z3 も信頼対象だが、図の行数には含まれない。 12 -
02 Ironclad Apps (OSDI ‘14) 紹介 OS 含むソフトウェアスタックを丸ごと形式検証 App (PassHash,
Notary, TrInc, or DiffPriv) Std. Lib App Common UDP/IP Datatypes RSA Ethernet SHA-1,256 BigNum Network Driver TPM Driver Core Math OS: late launch, IOMMU, segmentation, page tables, GC Figure 5: System Overview. annotations, spread throughout the code, as lemmas that build to the final high-level theorems. To convey the work necessary to complete the verifi- © Acompany Co., Ltd. 各アプリに期待する振る舞いを ory that the IOMMU allows devices to see, can Dafny の状態機械で形式的に定義 store non-secret data O. In §3.6’s terminology, non-s means that OL = OR . More specifically, we require the left and right executions generate the same sequ 暗号ライブラリやドライバも、 of device stores: the same values to the same addre 仕様を形式化して実装を検証 modulo timing and liveness. To prove OL = OR , we annotate our implementat input and output paths with relational annotations. T input output paths includeOS)を用い、 the application event l Verveand (著者らの先行研究の OS 実装含めた形式検証 and the networking stack. For example, the Etherne and UDP layers maintain relational properties on pac Lemma 8 K EY IN TPM. Apps correctly extend a p key into the TPM’s PCR 19. The private key is gener using TPM randomness and never leaves the platform 13 Lemma 9 ATTESTATION . Apps generate a correct -
02 Ironclad Apps (OSDI ‘14) 紹介 検証した 4 つのサービス Notary
文書を処理した順序を証明 TrInc(Trusted Incrementer) 監査ログに使える利用者別カウンタ 依頼ごとに共通のカウンタを進め、その値と 文書のハッシュに署名 利用者ごとにカウンタを管理し、現在値以上 への更新だけを受け付ける 複数の文書に対して一意な順序付けが可能 サービスは更新前後の値とメッセージに署名 → 本発表の例として用いる PassHash パスワード照合用のハッシュを生成 DiffPriv 差分プライバシーを満たす集計 パスワードにサービス内の秘密値を加えて ハッシュ化 統計量にノイズを加え、個々の記録の内容を 推測しにくくする 流出したハッシュだけでパスワード候補の 照合は困難 1 行の書き換えで集計値が変わる幅(感度、 sensitivity)の上界を検証 © Acompany Co., Ltd. 14 -
02 Ironclad Apps (OSDI ‘14) 紹介 Notary の具体例: 状態機械で仕様を表す Advance
(Notarize) 秘密鍵で入力メッセージとカウンタに署名して返す counter += N (≧ 1) Initialize 鍵ペア( keys )を生成 counter = 0 Uninitialized © Acompany Co., Ltd. Running 状態 s = (keys, counter) ※ 以降の説明も含め、論文の例を少し改変・簡略化して示す。 15 -
02 Ironclad Apps (OSDI ‘14) 紹介 Notary の具体例: 初期化(Initialize)の仕様 正しく生成した鍵ペアを持ち、カウンタを
0 から始める Dafny datatype NotaryState = State(keys: RSAKeyPair, counter: nat) predicate InitializeCorrect(s: NotaryState) { KeyGenerationCorrect(s.keys) && s.counter == 0 } KeyGenerationCorrect :乱数に基づく鍵生成の条件をまとめた述語。 © Acompany Co., Ltd. 16 -
02 Ironclad Apps (OSDI ‘14) 紹介 Notary の具体例: Notarize の仕様
カウンタを単調増加させ、秘密鍵で出力に署名する Dafny datatype NotaryState = State(keys: RSAKeyPair, counter: nat) datatype NotaryOutput = Output(statement: seq<int>, signature: seq<int>) predicate NotarizeCorrect( s: NotaryState, s': NotaryState, in_msg: seq<int>, out_msg: NotaryOutput) { ByteSeq(in_msg) && s.keys == s'.keys && s.counter < s'.counter && out_msg.statement == Encode(s'.counter) + in_msg && out_msg.signature == Sign(s.keys, out_msg.statement) } © Acompany Co., Ltd. 17 -
02 Ironclad Apps (OSDI ‘14) 紹介 Notary の具体例: Notarize の仕様
カウンタを単調増加させ、秘密鍵で出力に署名する Dafny datatype NotaryState = State(keys: RSAKeyPair, counter: nat) datatype NotaryOutput = Output(statement: seq<int>, signature: seq<int>) predicate NotarizeCorrect( s: NotaryState, s': NotaryState, 操作前の状態 s と操作後の状態 s' の間の関係を考える in_msg: seq<int>, out_msg: NotaryOutput) { ByteSeq(in_msg) && s.keys == s'.keys && s.counter < s'.counter && out_msg.statement == Encode(s'.counter) + in_msg && out_msg.signature == Sign(s.keys, out_msg.statement) } © Acompany Co., Ltd. 17 -
02 Ironclad Apps (OSDI ‘14) 紹介 Notary の具体例: Notarize の仕様
カウンタを単調増加させ、秘密鍵で出力に署名する Dafny datatype NotaryState = State(keys: RSAKeyPair, counter: nat) datatype NotaryOutput = Output(statement: seq<int>, signature: seq<int>) predicate NotarizeCorrect( s: NotaryState, s': NotaryState, 操作前の状態 s と操作後の状態 s' の間の関係を考える in_msg: seq<int>, out_msg: NotaryOutput) { ByteSeq(in_msg) && s.keys == s'.keys 鍵は変化せず、カウンタの値は前より大きくなる && s.counter < s'.counter && out_msg.statement == Encode(s'.counter) + in_msg && out_msg.signature == Sign(s.keys, out_msg.statement) } © Acompany Co., Ltd. 17 -
02 Ironclad Apps (OSDI ‘14) 紹介 Notary の具体例: Notarize の仕様
カウンタを単調増加させ、秘密鍵で出力に署名する Dafny datatype NotaryState = State(keys: RSAKeyPair, counter: nat) datatype NotaryOutput = Output(statement: seq<int>, signature: seq<int>) predicate NotarizeCorrect( s: NotaryState, s': NotaryState, in_msg: seq<int>, out_msg: NotaryOutput) 入力 in_msg と出力 out_msg の間の関係を考える { ByteSeq(in_msg) && s.keys == s'.keys && s.counter < s'.counter && out_msg.statement == Encode(s'.counter) + in_msg && out_msg.signature == Sign(s.keys, out_msg.statement) } © Acompany Co., Ltd. 17 -
02 Ironclad Apps (OSDI ‘14) 紹介 Notary の具体例: Notarize の仕様
カウンタを単調増加させ、秘密鍵で出力に署名する Dafny datatype NotaryState = State(keys: RSAKeyPair, counter: nat) datatype NotaryOutput = Output(statement: seq<int>, signature: seq<int>) predicate NotarizeCorrect( s: NotaryState, s': NotaryState, in_msg: seq<int>, out_msg: NotaryOutput) 入力 in_msg と出力 out_msg の間の関係を考える { ByteSeq(in_msg) && s.keys == s'.keys && s.counter < s'.counter 出力 statement( counter , && out_msg.statement == Encode(s'.counter) + in_msg && out_msg.signature == Sign(s.keys, out_msg.statement) in_msg )は秘密鍵で署名される } © Acompany Co., Ltd. 17 -
02 Ironclad Apps (OSDI ‘14) 紹介 Notary の具体例: 状態機械全体の仕様 個々の遷移(Initialize,
Notarize)の仕様をつなぎ、状態機械全体の仕様を定める 状態と初期化 状態の更新 datatype NotaryStateMachine = Machine(initialized: bool, state: NotaryState) ghost method {:axiom} Advance( s': NotaryState, in_msg: seq<int>, out_msg: NotaryOutput) returns (released_signature: seq<int>) requires current.initialized; requires public(in_msg); requires public(s'.counter); requires NotarizeCorrect( current.state, s', in_msg, out_msg); modifies this`current; ensures current == old(current)[state := s']; ensures DeclassifiedSignature( released_signature, out_msg.signature); ghost var {:readonly} current: NotaryStateMachine; ghost method {:axiom} Initialize(s: NotaryState) requires !current.initialized; requires InitializeCorrect(s); modifies this`current; ensures current == Machine(true, s); 詳細な説明は skip するが、雰囲気だけ紹介 © Acompany Co., Ltd. 18 -
02 Ironclad Apps (OSDI ‘14) 紹介 Notary の具体例: 状態機械全体の仕様 個々の遷移(Initialize,
Notarize)の仕様をつなぎ、状態機械全体の仕様を定める 状態と初期化 状態の更新 datatype NotaryStateMachine = Machine(initialized: bool, state: NotaryState) ghost method {:axiom} Advance( s': NotaryState, in_msg: seq<int>, out_msg: NotaryOutput) returns (released_signature: seq<int>) requires current.initialized; requires public(in_msg); requires public(s'.counter); requires NotarizeCorrect( current.state, s', in_msg, out_msg); modifies this`current; ensures current == old(current)[state := s']; Notarize の predicate ensures DeclassifiedSignature( released_signature, out_msg.signature); ghost var {:readonly} current: NotaryStateMachine; ghost method {:axiom} Initialize(s: NotaryState) requires !current.initialized; requires InitializeCorrect(s); modifies this`current; ensures current == Machine(true, s); 初期化の predicate 先ほど説明した、この 2 つの状態遷移をつなげたい © Acompany Co., Ltd. 18 -
02 Ironclad Apps (OSDI ‘14) 紹介 Notary の具体例: 状態機械全体の仕様 個々の遷移(Initialize,
Notarize)の仕様をつなぎ、状態機械全体の仕様を定める 状態と初期化 状態の更新 datatype NotaryStateMachine = Machine(initialized: bool, state: NotaryState) ghost method {:axiom} Advance( s': NotaryState, in_msg: seq<int>, out_msg: NotaryOutput) returns (released_signature: seq<int>) requires current.initialized; requires public(in_msg); requires public(s'.counter); requires NotarizeCorrect( current.state, s', in_msg, out_msg); modifies this`current; ensures current == old(current)[state := s']; ensures DeclassifiedSignature( released_signature, out_msg.signature); ghost var {:readonly} current: NotaryStateMachine; ghost method {:axiom} Initialize(s: NotaryState) requires !current.initialized; requires InitializeCorrect(s); modifies this`current; ensures current == Machine(true, s); グローバルな状態 current を介して、状態遷移がつながる (操作後の状態 s' が次の初期状態 current.state になる) © Acompany Co., Ltd. 18 -
02 Ironclad Apps (OSDI ‘14) 紹介 秘密が漏洩しないことの保証 状態遷移の仕様に加え、秘密が漏洩しないことも保証したい 例えば、実装で秘密鍵の 1
ビット secret_bit でカウンタの増加量を決めることも可能: var next_counter := s.counter + 1 + secret_bit; 増加量は 1 か 2 なので、単調増加という仕様は満たす しかし、増加量を見ると 秘密鍵の 1 ビットが漏洩 秘密鍵に依存した値が出力されないことを保証する必要 → noninterference(非干渉性) 一方、署名自体は秘密鍵に依存するため、明示的に許可する仕組みが必要 © Acompany Co., Ltd. 19 -
02 Ironclad Apps (OSDI ‘14) 紹介 Noninterference(非干渉性)の定義 入力が同じなら、秘密の値に依存せず必ず同じ出力になる 定義 1(非干渉性)
公開入力 𝐼 と秘密 𝑆 に対する観測出力を 𝑂 = 𝐹 (𝐼, 𝑆) とする。 任意の 2 つの実行 𝐿, 𝑅 の出力 𝑂𝐿 = 𝐹 (𝐼𝐿 , 𝑆𝐿 )、𝑂𝑅 = 𝐹 (𝐼𝑅 , 𝑆𝑅 ) が次を満たす。 ∀𝑆𝐿 , 𝑆𝑅 : 𝐼𝐿 = 𝐼𝑅 ⇒ 𝑂𝐿 = 𝑂𝑅 前のカウンタの例は 𝐹 (10, 0) = 11、𝐹 (10, 1) = 12 となり、この条件に反する。 Ironclad ではこのように表現 method F(I: int, S: int) returns (O: int) requires public(I); // 入 力 の 一 致 を 仮 定 ensures public(O); // 出 力 の 一 致 を 証 明 public(x) は 𝑥𝐿 = 𝑥𝑅 を表す注釈1 © Acompany Co., Ltd. 1 Dafny のレベルでは検証されず、仕様変換後に SymDiff ツールを使ってアセンブリの段階で検証 20 -
02 Ironclad Apps (OSDI ‘14) 紹介 秘密に依存した値の出力許可(Declassification) 例えば、秘密鍵に依存した署名の出力を明示的に許可することが可能 状態の更新(再掲) ghost
method {:axiom} Advance( s': NotaryState, in_msg: seq<int>, out_msg: NotaryOutput) returns (released_signature: seq<int>) requires current.initialized; 入力メッセージとカウンタは公開値。 requires public(in_msg); requires public(s'.counter); 秘密鍵には public を指定せず、秘密として扱う。 requires NotarizeCorrect( current.state, s', in_msg, out_msg); modifies this`current; ensures current == old(current)[state := s']; NotarizeCorrect が定めた応答の署名だけを ensures DeclassifiedSignature( released_signature, out_msg.signature); declassify の対象に指定して開示 © Acompany Co., Ltd. 21 -
02 Ironclad Apps (OSDI ‘14) 紹介 検証の最終目標: Remote equivalence ネットワーク越しに利用者が受け取る応答は、仕様どおりの状態機械に基づく出力として説明できる
系 1(Remote equivalence) 同じ公開入力なら、実装が利用者に返す値を 仕様の状態機械とネットワーク で再現できる。 状態機械は実装と同じ秘密を使う。ネットワークはその秘密を知らず、応答を改変できる。 各アプリで証明する 3 つの性質 入力の非干渉性(input noninterference) declassify に渡す公開引数は秘密に依存しない。 機能的正しさ(functional correctness) declassify する値は状態機械の出力と一致する。 出力の非干渉性(output noninterference) 外部出力は公開値と declassify した値のみから決まる。 © Acompany Co., Ltd. 22 -
02 Ironclad Apps (OSDI ‘14) 紹介 (補足)Remote equivalence の保証範囲 状態機械の出力と利用者に対する返答が一致することまでは証明に含まれない
実装内部の状態遷移が仕様に従うことを検証するが、その外側で利用者に対してデタラメな出力を 返すことは可能 実際に Notary の reply を固定の値 [42] に変更しても、検証を通過した 一方で、情報フローの制約は保証する(noninterference) (declassification を迂回する)秘密に依存した出力は検証で正しく弾かれる TrInc の例ではカウンタの値を署名して返しているので、安全性は保たれる 「署名の検証が成功したならば、その値は状態機械の仕様に沿って生成されたものである」と言える 署名せず、単にインクリメントした値を返すだけの仕様では不十分(デタラメな値を返すことが可能) declassification は、秘密に依存した出力を許可するという以上に、状態機械の出力と利用者への 返答を繋ぐ役割が大きい © Acompany Co., Ltd. 23 -
02 Ironclad Apps (OSDI ‘14) 紹介 性能評価 未検証の場合に比べ、応答時間は最大 189 倍。
コンパイラ DafnyCC は独自実装であり、特に RSA の実装には最適化の余地あり。 最大 189 倍 遅い Operation Dominant step Ironclad Unverified Slowdown Notary notarize Compute RSA signature 934 ms ±0 ms 8.88 ms ±0.68 ms 105 TrInc create Compute reciprocal of RSA modulus 4.96 ms ±0.03 ms 866 µs ±507 µs 5.72 TrInc advance Compute RSA signature 1.01 s ±0.00 s 12.1 ms ±0.2 ms 83.6 PassHash hash Compute SHA-256 hash 276 µs ±10 µs 159 µs ±3 µs 1.73 DiffPriv initialize db None, just network overhead 168 µs ±2 µs 155 µs ±3 µs 1.08 DiffPriv add row Decrypt RSA-encrypted row 944 ms ±17 ms 8.85 ms ±0.06 ms 107 DiffPriv query Compute noise with BigInts 126 ms ±19 ms 668 µs ±36 µs 189 Table 3: App benchmarks. Latency of different request types, as seen by a client on the same network switch, for Ironclad Apps and unverified variants written in C#. Ranges shown are 95% confidence intervals for the mean. © Acompany Co., Ltd. Op Param Ironclad OpenSSL C#/.NET servers, we wrote unverified variants of our apps in C# 24 -
03 今後の展望 近年の形式検証ツールの発展 SMT による自動検証 型理論に基づく定理証明支援系 SMT ソルバによって制約充足問題を解く Rocq(旧 Coq)、Isabelle/HOL、Lean
など Ironclad では Dafny / Boogie / Z3 を使用 高階述語論理(HOL)や Curry–Howard 対応の 理論を基盤に、高度な数学や実装の性質を証明 仕様や補題から推論を自動化し、証明記述を 比較的少なくできる Ironclad 論文では 3 人年(seL4 は>20 人年) 一方で、右に比べて表現能力は限定的 AI が Lean で未解決問題を AI が解く事例が話題に 近年では Rust 上で形式検証が可能な Verus が注目 © Acompany Co., Ltd. 人間による証明記述の負担が大きい点が 課題だったが、証明記述を AI が担える今、世間の 注目を集めている Lean では証明済みの定理ライブラリである Mathlib (数学)に加えて CSLib(計算機科学)の整備も 始まっており、実装の検証に使える基盤も拡充 いずれもそれ単体ではバイナリレベルの実装まで検証したことにはならない (コンパイラツールチェーンを信頼する)ため、コンパイラ自体を形式検証(CompCert など)したり、 信頼境界を明確にする必要 26 -
03 今後の展望 Confidential VM + 形式検証:2 つの方向性 特権モニタを検証(VeriSMo1など) 全体を検証(Ironclad 型)
TEE(Confidential VM) TEE(Confidential VM) 既存のアプリケーション 全体を形式検証 Linux カーネル(低い権限) アプリケーション 権限分離 ライブラリ・ドライバ 特権モニタ(高い権限) ここだけ形式検証 必要な OS 機能 VeriSMo では Rust の Verus で形式検証 unikernel 的に、OS・アプリを一体で検証 CVM が提供する権限分離(AMD SEV-SNP の VPML など)を活用 アプリ固有の性質を証明可能 Linux カーネルの上で既存プログラムを動かせる 形式検証可能な形でのソフトウェア再実装が前提 形式検証のコスト大 カーネルが侵害されても、形式検証された 特権モニタが一定の安全性を保証 証明できる性質は限定的(アプリ非依存) © Acompany Co., Ltd. 1 VeriSMo: A Verified Security Module for Confidential VMs (OSDI ’24) 27 -
03 今後の展望 まとめ 「Confidential Computing × 形式検証」の可能性 Confidential VM では
TCB が肥大しがちだが、形式検証を効果的に用いれば TCB を大きく削減可能。 システムの外側を Confidential Computing で守り、内側を形式検証で守る。 実装・証明は AI 任せで良いが、仕様の正しさは人間の責任 実装が仕様を満たすことは機械的に検証可能だが、仕様自体が誤っていればバグは残る。 具体的にどのような性質を検証できているか人間がチェックする必要がある。 どのレベルまで形式検証するかが重要な Design Choice 一言に「形式検証した」と言っても、OS・ライブラリ・コンパイラへの信頼に応じて保証範囲は異なる。 Ironclad は OS・ライブラリ・アプリ全体をバイナリレベルまで形式検証した事例。 AI が証明を支援できる今、このような全体検証にも改めて取り組む価値があるのでは? © Acompany Co., Ltd. 28