UJP - 技術情報2 : macOS Getekeeper考察 macOS/Gatekeeper

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

Page Top

はじめに anchor.png Edit

 macOSにて,ダウンロードしたアプリケーションを実行しようとした時に「開発元を確認できないため、開けませんでした。」と表示される.ネットを検索すると,この時の会場方法について指南するサイトは多くあるけれど,仕組みについて説明されたものがなかったので,まとめてみる.

Page Top

現象の確認 High Sierraを利用 anchor.png Edit

 ダウンロードしたアプリのインストーラ(.pkg方式)を実行しようとすると,次のようなダイアログが出る.

index.php?page=view&file=7181&macOSgatekeeper01.png

 これはマルウェア(ウイルスなどの悪意のあるソフトウェアの総称)を誤ってダウンロードしても意図せずに実行しないように制御しているのだが,この機能がmacOSのGatekeeper.

 このようにブロックされたアプリは,[システム環境設定]の[セキュリティとプライバシー]を開くと確認できる.

index.php?page=view&file=7180&macOSgatekeeper02.png

 ここで[このまま開く]ボタンを押下すると,次のようなダイアログが表示される.

index.php?page=view&file=7183&macOSgatekeeper03.png

 先ほどとはメッセージが変わった.一度許可すると,「常に許可」される.

 今回の場合はインストーラなので,いくらでもインストールが可能.(普通は何度もインストールしないか)

 これで[開く]を選択すると,プログラムが実行される.

index.php?page=view&file=7182&macOSgatekeeper04.png

 今回の場合,pkgファイルなのでインストールが実行できる.

Page Top

macOS 10.14 Mojaveでの動作 anchor.png Edit

 macOSはバージョンアップの都度,デフォルト設定を強化していて,MojaveでのmacOS Gatekeeperのダウンロードしたアプリケーションの実行許可は,次のようにApp Storeから限定とされている.

index.php?page=view&file=7189&macOSgatekeeper05mojave.jpg

 この状態でアプリケーションの実行を行う.

index.php?page=view&file=7186&macOSgatekeeper06mojave.png

 ダイアログにも,控えめにApp Storeのみと書かれている.

index.php?page=view&file=7190&macOSgatekeeper07mojave.jpg

 このまま実行する.  

index.php?page=view&file=7184&macOSgatekeeper08mojave.png

 ダウンロードしたアプリケーションを開こうとすると,管理者権限が必要になる.

Page Top

High SierraからMojaveへバージョンアップした時のデフォルトの違い anchor.png Edit

 Mojave(10.14)ではダウンロードしたアプリケーションの実行許可は,App Storeになっている.

index.php?page=view&file=7191&macOSgatekeeper09mojave.png

 以前のHigh Sierra(10.13)では,「確認済みの開発元からのアプリケーションを許可」がデフォルトになっていたが,Mojaveへバージョンアップした場合は,デフォルトはHigh Sierraの設定が継承される.

Page Top

確認済みの開発元とはなんなのか anchor.png Edit

 Appleが承認したアプリケーションベンダを「確認済みの開発元」というが,これはDeverloperに登録し,Developer IDを取得している事が求められている.

 このDeveloper IDで署名したアプリに限り,Cloudkit,Apple Push Notificationsという機能を実装できるという飴と鞭戦略もある模様.

Page Top

ダウンロードしたpkgの証明書を確認する anchor.png Edit

 ダウンロードしたpkgが持っている証明書は,pkgutilを使うことで確認できる.

 次の例では,MicrosoftのサイトからダウンロードしたMicrosoft Teamsのパッケージファイルを確認.

$ pkgutil --check-signature Downloads/Teams_osx.pkg🆑
Package "Teams_osx.pkg":
   Status: signed by a certificate trusted by Mac OS X
   Certificate Chain:
    1. Developer ID Installer: Microsoft Corporation (UBF8T346G9)
       SHA1 fingerprint: F3 13 36 F7 FF AC 5E 8B 2E 9B 1C 7A 88 84 B0 96 02 0A 4C 19
       -----------------------------------------------------------------------------
    2. Developer ID Certification Authority
       SHA1 fingerprint: 3B 16 6C 3B 7D C4 B7 51 C9 FE 2A FA B9 13 56 41 E3 88 E1 86
       -----------------------------------------------------------------------------
    3. Apple Root CA
       SHA1 fingerprint: 61 1E 5B 66 2C 59 3A 08 FF 58 D1 4A E2 24 52 D1 98 DF 6C 60

$

 MicrosoftのDeveloper IDが登録されている.

Page Top

ダウンロードしたDMGファイルをspctlコマンドで確認する anchor.png Edit

 DMGファイルは,Disk Imageファイル.昔のフロッピーディスクを貸そうかしていた頃から使われているけれど,macOS用のアプリを入手した際に,DMGファイル形式でダウンロードされるものも多い.

 このDMGファイルの署名を確認する.

 DMGファイルは,spctlコマンドを用いる.

 まずは,コマンドの使い方の確認.

$ spctl🆑
System Policy Basic Usage:
       spctl --assess [--type type] [-v] path ... # assessment
       spctl --add [--type type] [--path|--requirement|--anchor|--hash] spec ... # add rule(s)
       spctl [--enable|--disable|--remove] [--type type] [--path|--requirement|--anchor|--hash|--rule] spec # change rule(s)
       spctl --status | --master-enable | --master-disable # system master switch

Kernel Extension User Consent Usage:
    spctl kext-consent <action>         ** Modifications only available in Recovery OS **
        status
            Print whether kernel extension user consent is enabled or disabled.
        enable
            Enable requiring user consent for kernel extensions.
        disable
            Disable requiring user consent for kernel extensions.
        add <team-id>
            Insert a new Team Identifier into the list allowed to load kernel extensions without user consent.
        list
            Print the list of Team Identifiers allowed to load without user consent.
        remove <team-id>
            Remove a Team Identifier from the list allowed to load kernel extensions without user consent.
$
今回は,Microsoft Office互換ソフトのLibreOfficeをダウンロードしたものを使って検証する.
$ spctl -a -t open --context context:primary-signature -v Downloads/LibreOffice_6.4.4_MacOS_x86-64.dmg🆑
Downloads/LibreOffice_6.4.4_MacOS_x86-64.dmg: rejected
source=no usable signature🈁
$

 有効な署名は無いと表示された.

 次のサンプル.

$ spctl -a -t open --context context:primary-signature -v Downloads/IINA.v1.0.4.dmg🆑
Downloads/IINA.v1.0.4.dmg: rejected
source=Developer ID🈁
$

 これはDeveloper IDで署名されていると

Page Top

インストールしたMac Appの開発元を確認する anchor.png Edit

 すでにインストールされているアプリが,Appleに証明されているか確認する.

 調べたいアプリを,codesignコマンドで指定する.

 まずは,App Storeからインストールした,Monosnapを.

$ codesign --display -vvv /Applications/Monosnap.app🆑
Executable=/Applications/Monosnap.app/Contents/MacOS/Monosnap
Identifier=com.monosnap.monosnap
Format=app bundle with Mach-O thin (x86_64)
CodeDirectory v=20200 size=58133 flags=0x200(kill) hashes=1809+5 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=03bb860ec5dfca4c5b75e649edf9554c60587adc
Hash choices=sha256
CDHash=03bb860ec5dfca4c5b75e649edf9554c60587adc
Signature size=4617
Authority=Apple Mac OS Application Signing🈁
Authority=Apple Worldwide Developer Relations Certification Authority
Authority=Apple Root CA
Info.plist entries=36
TeamIdentifier=8DEE75ARD7
Sealed Resources version=2 rules=13 files=427
Internal requirements count=1 size=224
$

 次に,pkgファイルをダウンロードしてインストールしたMicrosoft Teamsを確認.

$ codesign --display -vvv /Applications/Microsoft\ Teams.app🆑
Executable=/Applications/Microsoft Teams.app/Contents/MacOS/Teams
Identifier=com.microsoft.teams
Format=app bundle with Mach-O thin (x86_64)
CodeDirectory v=20500 size=383 flags=0x10000(runtime) hashes=3+5 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha1=de20994eafa3411c1c5e35679925ca09ec1a94c7
CandidateCDHash sha256=ef8f97a75abc383dff7936fdd5d8e395aefbf3a8
Hash choices=sha1,sha256
CDHash=ef8f97a75abc383dff7936fdd5d8e395aefbf3a8
Signature size=9061
Authority=Developer ID Application: Microsoft Corporation (UBF8T346G9)🈁
Authority=Developer ID Certification Authority
Authority=Apple Root CA
Timestamp=2020/04/02 7:48:09
Info.plist entries=18
TeamIdentifier=UBF8T346G9
Runtime Version=10.12.0
Sealed Resources version=2 rules=13 files=129
Internal requirements count=1 size=180
$

 次に,OSに付属しているSafariを確認.

$ codesign --display -vvv /Applications/Safari.app🆑
Executable=/Applications/Safari.app/Contents/MacOS/Safari
Identifier=com.apple.Safari
Format=app bundle with Mach-O thin (x86_64)
CodeDirectory v=20100 size=321 flags=0x2000(library-validation) hashes=3+5 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=ab20751f33bbb1371b91a81ea316e297901bcc3e
Hash choices=sha256
CDHash=ab20751f33bbb1371b91a81ea316e297901bcc3e
Signature size=4485
Authority=Software Signing
Authority=Apple Code Signing Certification Authority🈁
Authority=Apple Root CA
Info.plist entries=40
TeamIdentifier=not set
Sealed Resources version=2 rules=13 files=1932
Internal requirements count=1 size=64
$

 んー.どこ見れば良いのかよくわからん.今日はここまで.


Front page   Edit Diff Backup Upload Copy Rename Reload   New Page Page list Search Recent changes   Help   RSS of recent changes (RSS 1.0) RSS of recent changes (RSS 2.0) RSS of recent changes (RSS Atom)
Counter: 1799, today: 1, yesterday: 1
Last-modified: 2020-05-29 (Fri) 16:39:32 (JST) (2181d) by nobuaki

広告スペース
Google