Skip to content

ncesnagoya/scudo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scudo

Starting the demo

このデモでは、Scudoを使用して自動車OTA Updateにおけるソフトウェアサプライチェーンを保護します。

環境情報

Virtual Box v7.2.4
Vagrant v2.4.9 Ubuntu v22.04
Python 3.10

環境構築

こちらを参照しVagrantfileを実行します。(https://www.nces.i.nagoya-u.ac.jp/gitlab/autosec/uptane/dockerfiles/-/tree/main/scudo-demo?ref_type=heads)

git格納先

Ubuntuへのログイン方法

ログイン画面でユーザー選択時に画面右下の歯車アイコンをクリック。「Ubuntu on Xorg」を選択し、ログインする。

前処理

画面の左上部にターミナルを立ち上げ、以下のコマンドを実行します。

cd scudo
bash run_scudo_prep.sh

in-toto demo CI

in-totoは、セキュアなソフトウェアサプライチェーンの開発プロセスを実現します。

in-toto正常系の実行

in-totoのデモ(正常系)を一括で実行します(実行はすべてdevelopターミナル)。

./run_intoto.sh

個別に実行する場合

  1. Stepを実行
# Step(code, build, package)を全て実行
./run_intoto.sh --stepall

もしくは個別で実行

# Step code を実行
./run_intoto.sh --code

# Step build を実行
./run_intoto.sh --build

# Step package を実行
./run_intoto.sh --package
  1. final product を作成
./run_intoto.sh --createfp
  1. Inspection を実行
./run_intoto.sh --inspect
  1. 更新ファイルをUptaneリポジトリに格納
./run_intoto.sh --addartifact

補足:"--stepall"以外の引数指定時、2つ目の引数に"--all"を指定すると以降の処理がすべて実行される (例) ./run_intoto.sh --build --all (Step build〜更新ファイルをUptaneリポジトリに格納まですべて実行)

in-toto demoの初期化

in-totoのデモ実行前に初期化をします。※run_scudo_prep.sh実行後は初期化不要

# develop ターミナルにて実行
./run_intoto_prep.sh --delete

in-toto攻撃の実行

セミナー用の攻撃5種類, ソフトウェアサプライチェーン脅威の表に沿った攻撃6種類。各攻撃実行前にはin-toto demoの初期化が必要。

セミナー用

1. ソースコードの置き換え攻撃

Step codeのmaterialsであるソースコードを改ざんする

# attackerターミナルにて実行
attacker/attack_intoto_source_code_compromise.sh

# develop ターミナルにて実行
./run_intoto.sh --code

2. ソースコードとメタデータの置き換え攻撃

Step codeのmaterialsであるソースコードとLink metadataを改ざんする

# attackerターミナルにて実行
attacker/attack_intoto_metadata_compromise.sh --link

# develop ターミナルにて実行
./run_intoto.sh --code

3. ソースコードとメタデータの置き換え攻撃(鍵流出あり)

Step codeのmaterialsであるソースコードとLink metadata(鍵流出あり)を改ざんする

# attackerターミナルにて実行
attacker/attack_intoto_metadata_compromise.sh --key_compromise_link

# develop ターミナルにて実行
./run_intoto.sh

4. メタデータの置き換え攻撃

Layout fileを改ざんする

# attackerターミナルにて実行
attacker/attack_intoto_metadata_compromise.sh --layout

# develop ターミナルにて実行
./run_intoto.sh --code

5. メタデータの置き換え攻撃(鍵流出あり)

Layout file (鍵流出あり) を改ざんする

# attackerターミナルにて実行
attacker/attack_intoto_metadata_compromise.sh --key_compromise_layout

# develop ターミナルにて実行
./run_intoto.sh

補足.in-totoをメインで実行する場合

ターミナル立ち上げ, 初期化の実行. 以下のコマンドを実行すると、in-toto用ターミナル2つ, Uptane用ターミナル1つ, attacker用ターミナル1つが立ち上がり、初期化を実行します.

./run_intoto_prep.sh

デモの実行手順

  1. ターミナル名「supplyer02」にて以下のコマンドを実行. Step code, Step buildを実行.
# Step code を実行
./run_intoto.sh --code

# Step build を実行
./run_intoto.sh --build
  1. ターミナル名「supplyer01」にて以下のコマンドを実行. Step package, final products作成を実行.
# Step package を実行
./run_intoto.sh --package

# final products を作成
./run_intoto.sh --createfp
  1. ターミナル名「uptane」にて以下のコマンドを実行. inspectionを実行し, artifactをUptaneリポジトリに格納.
# Inspection を実行
./run_intoto.sh --inspect

# 更新ファイルをUptaneリポジトリに格納
./run_intoto.sh --addartifact
  1. ターミナル名「uptane」にてコマンドを実行. Uptaneリポジトリの起動.Uptaneデモの操作は以下「Uptane demo」以降を参照し、実行ターミナルから実行する.
# uptaneリポジトリの起動
./run_intoto_prep.sh --start_u

Uptene demo

UptaneはセキュアなOTA Updateを実現します。

Uptene正常系の実行

uptaneのデモ(正常系)を一括で実行します(実行はすべてdevelopターミナル)。

./run_uptane.sh

個別に実行する場合

  1. Directorリポジトリtargetファイルの初期化
./run_uptane_prep.sh --clear_vehicle_targets
  1. リポジトリで新たな更新ファイルに対してメタデータを作成 A~Dいずれかを実行
# A imageファイル: firmware.img
./run_uptane.sh --deliveringA

# B imageファイル: update.bin
./run_uptane.sh --deliveringB
    # B-imagerepo
    ./run_uptane.sh --delivering_imagerepo
    # B-directorrepo
    ./run_uptane.sh --delivering_director
# C imageファイル: firmware.img(secondaryA), firmware2.img(secondaryB)
./run_uptane.sh --deliveringC_imagerepo
./run_uptane.sh --deliveringC_director

# D imageファイル: update.txt
./run_uptane.sh --deliveringD
  1. 自動車ECU更新
# primary, secondary_a, secondary_b を順に更新
./run_uptane.sh --update

もしくは個別で更新

# primary のみ更新
./run_uptane.sh --update_p
# secondary_a のみ更新
./run_uptane.sh --update_sA
# secondary_b のみ更新
./run_uptane.sh --update_sB

Uptene攻撃の実行

攻撃の種類は全部で3種類

Arbitrary software attack

  • 鍵流出なし 更新ファイルとメタデータを準備
# develop ターミナルにて実行
./run_uptane_prep.sh --clear_vehicle_targets
./run_uptane.sh --deliveringA

攻撃実行

# attackerターミナルにて実行
attacker/attack_uptane_arbitrary_software.sh --without_key_attack

PrimaryECUの更新

# develop ターミナルにて実行
./run_uptane.sh --update_p

攻撃からの回復

# develop ターミナルにて実行
./run_uptane_prep.sh --recovery_from_without_asa
  • 鍵流出片方(Directorの鍵が流出) 更新ファイルとメタデータを準備
# develop ターミナルにて実行
./run_uptane_prep.sh --clear_vehicle_targets
./run_uptane.sh --deliveringA

攻撃実行

# attackerターミナルにて実行
attacker/attack_uptane_arbitrary_software.sh --key_compromise_dirctor

PrimaryECUの更新

# develop ターミナルにて実行
./run_uptane.sh --update_p

攻撃からの回復 正常系の「1. Directorリポジトリtargetファイルの初期化」と「2. リポジトリで新たな更新ファイルに対してメタデータを作成」を実行。もしくは続けて以下のコマンドを実行して鍵流出両方を実行する。

# attackerターミナルにて実行
attacker/attack_uptane_arbitrary_software.sh --key_compromise_imagerepo
# develop ターミナルにて実行
./run_uptane.sh --update
  • 鍵流出両方 更新ファイルとメタデータを準備
# develop ターミナルにて実行
./run_uptane_prep.sh --clear_vehicle_targets
./run_uptane.sh --deliveringA

攻撃実行

# attackerターミナルにて実行
attacker/attack_uptane_arbitrary_software.sh --key_compromise

PrimaryECUの更新

# develop ターミナルにて実行
./run_uptane.sh --update

Rollback attack

更新ファイルとメタデータを準備

# develop ターミナルにて実行
./run_uptane_prep.sh --clear_vehicle_targets
./run_uptane.sh --deliveringB

攻撃実行

# attackerターミナルにて実行
attacker/attack_uptane_rollback.sh

PrimaryECUの更新

# develop ターミナルにて実行
./run_uptane.sh --update_p

攻撃からの回復

# develop ターミナルにて実行
./run_uptane_prep.sh --recovery_from_rollback_attack

Mix-and-match attack

更新ファイルとメタデータを準備

# develop ターミナルにて実行
./run_uptane_prep.sh --clear_vehicle_targets
./run_uptane.sh --deliveringC_imagerepo
./run_uptane.sh --deliveringC_director

攻撃実行

# attackerターミナルにて実行
attacker/attack_uptane_mixandmatch.sh

PrimaryECUの更新

# develop ターミナルにて実行
./run_uptane.sh --update

攻撃からの回復

# develop ターミナルにて実行
./run_uptane_prep.sh --recovery_from_mix_and_match_attack 

Uptane デモの初期化

すべて完了後は初期化することで再度デモの実行が可能

# develop ターミナルにて実行
./run_uptane_prep.sh

Uptane デモの終了

デモを終了し、ターミナルを削除する

# develop ターミナルにて実行
./run_scudo_prep.sh --uptane_clean

ディレクトリ構成

Inside the demo directory you will find four directories: owner_ecu01, functionary_build, functionary_code, functionary_import, functionary_package and final_product. デモで利用する鍵は各リポジトリに用意済み

tree  # If you don't have tree, try 'find .' instead
# the tree command gives you the following output
# .
# ├── README.md
# ├── attacker              攻撃用のファイルを格納(in-toto/uptane)
# ├── director              Uptane directorリポジトリ用のファイルを格納
# ├── imagerepo             Uptane imageリポジトリ用のファイルを格納
# ├── in_toto               in-totoデモ用ライブラリ
# │   ├── demo             鍵等格納
# │   ├── in_toto          
# ├── log                   実行ログ
# ├── oem_repo              in-totoのfinal productを格納しinspection実行
# ├── suppliers_repo        in-totoのStep実行に必要なファイルを格納
# ├── primary               UptaneプライマリECUに必要なファイルを格納
# ├── secondary             UptaneセカンダリECUに必要なファイルを格納
# ├── uptane                Uptaneデモ用ライブラリ
# │   ├── demo             鍵等格納
# │   ├── uptane
# ├── timeserver            Timeserverのデモ用ファルを格納
# ├── setup_vms        環境構築用
# ├── check_metadata.py     in-totoのLayout file/Link metadataの中身を確認可能
# ├── run_intoto.py         in-totoデモ実行用ファイル
# ├── run_intoto.sh         in-totoコマンド
# ├── run_intoto_prep.sh    in-totoコマンド(初期化用)
# ├── run_scudo_prep.sh     Scudoコマンド(初期化用)
# ├── run_uptane.py         Uptaneデモ実行用ファイル
# ├── run_uptane.sh         Uptaneコマンド
# ├── run_uptane_prep.sh    Uptaneコマンド(初期化用)
# ├── dev-requirements.txt  環境構築用
# ├── setup_vms.sh      環境構築用
# └── setup.py              環境構築用

*Note: デモで主に利用するディレクトリツリー

複数VM用のセットアップ手順

VMのセットアップ(複数VM用)

以下のスクリプトを実行すると、①VM間の鍵交換、②developVMで.ssh/config作成、③各VMの/etc/hostsの作成を実行します。

bash setup_vms.sh

単体VMと複数VMでの実行の切り替え

デフォルトは単体VM用となっています。

# 複数VM実行用に切り替え
bash setup_vms.sh --replace_multi

# 単体VM実行用に切り替え
bash setup_vms.sh --replace_single

in-totoその他の攻撃

ソフトウェアサプライチェーン脅威の表より

※ sshpasのインストールが必要

sudo apt update
sudo apt install -y sshpass

Surreptitious Changes (意図しないコード変更を含むソフトウェアを生成)

  • 鍵流出なし
# attackerターミナルにて実行
attacker/ecu01/attack_intoto_surreptitious_changes.sh

# develop ターミナルにて実行
./run_intoto.sh --code
  • 鍵流出あり
# attackerターミナルにて実行
attacker/ecu01/attack_intoto_surreptitious_changes.sh --key-compromise-layout

# develop ターミナルにて実行
./run_intoto.sh

Omitted Steps (作業の省略)

  • 鍵流出なし
# attackerターミナルにて実行
attacker/ecu01/attack_intoto_omitted_steps.sh

# develop ターミナルにて実行
./run_intoto.sh --code
  • 鍵流出あり
# attackerターミナルにて実行
attacker/ecu01/attack_intoto_omitted_steps.sh --key-compromise-layout

# develop ターミナルにて実行
./run_intoto.sh

Compromised Source Code (ソースコードあるいはソースコードのリポジトリ汚染)

# develop ターミナルにて実行
./run_intoto.sh --code

# attackerターミナルにて実行
attacker/ecu01/attack_intoto_compromised_code.sh

# develop ターミナルにて実行
./run_intoto.sh --build

Wrong Functionary Execution (不正な関係者または環境)

# develop ターミナルにて実行
./run_intoto.sh --code

# attackerターミナルにて実行
attacker/ecu01/attack_intoto_wrong_func_execution.sh

# develop ターミナルにて実行
./run_intoto.sh --build

Key Compromise (署名鍵の漏洩)

  • Layout fileの鍵が流出
# develop ターミナルにて実行
./run_intoto.sh --code
./run_intoto.sh --build

# attackerターミナルにて実行
attacker/ecu01/attack_intoto_key_compromise.sh --key-layout

# develop ターミナルにて実行
./run_intoto.sh --package --all
  • Step code の鍵が流出
# develop ターミナルにて実行
./run_intoto.sh --code

# attackerターミナルにて実行
attacker/ecu01/attack_intoto_key_compromise.sh --key-link

# develop ターミナルにて実行
./run_intoto.sh --build --all

Replaying Steps (過去の成果物や署名の再利用)

# attackerターミナルにて実行
attacker/ecu01/attack_intoto_replay.sh

# develop ターミナルにて実行
./run_intoto.sh --code

トラブル時の対処

  • 実行ファイルが見つからない

環境変数のパスが通っていない可能性

export PYTHONPATH=/home/vagrant/scudo:/home/vagrant/scudo/uptane/demo:/home/vagrant/scudo/uptane:/home/vagrant/scudo/uptane/src:/home/vagrant/scudo/uptane/src/tuf;
  • Uptaneデモで新しいメタデータで更新できない

Directorリポジトリで更新用のtargetファイルとして登録する更新ファイルがリセットされていない可能性

# develop ターミナルにて実行
./run_uptane_prep.sh --clear_vehicle_targets

# もしくはリセット(develop ターミナルにて実行)
./run_uptane_prep.sh
  • ターミナルが整列しない

ターミナルのは位置はwmctrlコマンドを利用している. このコマンドは「X11(X Window System)」上で機能する(Linuxのディスプレイサーバプロトコル). Ubuntu22.04ではデフォルトが「Wayland」のため、以下の方法で切り替えが必要.

  1. Ubuntu ログイン画面へ移動
  2. ユーザー選択
  3. 右下の歯車アイコンをクリック
  4. 「Ubuntu on Xorg」を選択してログイン

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published