詳解: クラウドサプライチェーンのパイプライン攻撃

Oct 28, 2021
2 minutes
... views

Unit 42の最新のクラウド脅威レポートには、弊社のあるお客様(SaaSプロバイダ)のCI/CD(継続的インテグレーション/継続的デリバリー)パイプラインに対して実施されたレッドチーム演習の概要が含まれています。このお客様からのご依頼は、弊社リサーチャーに攻撃者の考えにならってSaaSプロバイダの開発運用(DevOps)プロセスに潜む脆弱性と設定ミスをあぶりだしてほしい、ということでした。レッドチーム演習では、現実の脅威を模倣し、既知の攻撃手法に対するセキュリティ能力を評価するため、SolarWindsのOrionサプライチェーン攻撃で使用された戦略と手法を手本としました。リサーチャーがインサイダー脅威役を演じます。目標はCI/CDパイプラインのコンポーネントを改変するに足るアクセス権を取得し、最終的にサプライチェーン攻撃を行える状況を作り出すことです。

演習でこのリサーチャーは組織のクラウド環境で管理者アクセス権(いわゆる「God Mode」)の取得に成功しました。その要因は社内のGitLabリポジトリに保存されていた、ハードコードされた26個のIAM (IDとアクセスの管理)キーペアです。(IAMキーペアとは、セキュリティ資格情報のセット(公開鍵と秘密鍵)であり、パブリック クラウド インスタンスに接続する際の身元証明に使用できます。IAMキーペアは文字通りクラウド環境への鍵であるため、キーペアへのアクセスは保護が必要です。特に、特権を持つロールに関連するキーペアは厳重に保護する必要があります。)

このSaaSプロバイダの場合、組織の開発者アカウントであれば誰でもGitLab環境の全リポジトリにアクセスできる状態でした。リサーチャーは、GitLabリポジトリに保存されていたいくつかのキーペアを使用して、組織のクラウド環境での権限を昇格させ、CI/CDパイプラインの侵害が可能なレベルの権限を得ることに成功しています。これにより、数百どころか数千の下流の顧客が影響を受ける可能性がありました。

リサーチャーが特定した50件以上のAWSアカウントのうち、Amazon GuardDuty (構成したAWSアカウントを絶えず監視して有害な活動を検出するAWSセキュリティツール)とPrisma Cloudプラットフォームの監視対象になっていたアカウントは1件だけでした。他の49件以上のAWSアカウントでは、こうしたセキュリティ対策が有効化されていなかったのです。幸運にも、組織のセキュリティ オペレーション センター(SOC)は、監視していた1件のAWSクラウドアカウントを通じて、リサーチャーの活動の一部を検出することに成功しています。

弊社では、近年現実に発生しているサプライチェーン攻撃を注意深く警戒しています。たとえば、「SolarStorm」と呼ばれるSolarWindsへの攻撃では、SaaSプロバイダのCI/CDパイプラインが標的となり、数千の下流の顧客が侵害を受けています。この種の重大な攻撃が実際に発生していることを考えると、今回のレッドチーム演習から得られた知見は重要であり、CI/CDアーキテクチャを運用するすべての組織に広めるべきものです。

以下のセクションではクラウドベースのSaaSプロバイダをターゲットとしたサプライチェーン攻撃がどのように進行するのかについての知見を提供します。解説には今回のレッドチーム演習でUnit 42のリサーチャーが使用した戦略と手法(クラウド脅威レポートでも解説)の概要が含まれます。また、演習自体がSolarWindsサプライチェーン攻撃の一部をモデルとしたものです。こうした情報を提供することで、いかにしてパイプラインが標的となり、機密情報が盗まれ、環境の侵害に発展する状況が生じるかについての展望を、読者やクラウドベースのCI/CDパイプラインのアーキテクトに提供できれば幸いです。攻撃について説明したら、最後のセクションでCI/CDパイプラインへの攻撃の被害を軽減する方法について助言を行います。

CI/CDパイプラインの侵害

レッドチーム演習において、リサーチャーはSaaSプロバイダのCI/CDパイプラインを侵害できることを実証しました。ですが、これは具体的に何を意味するのでしょうか。ベンダのサプライチェーン、あるいはそのCI/CDパイプラインが侵害された時、裏側では何が起こっているのでしょうか。この疑問に答えるため、まずはCI/CDパイプラインによる開発チャネルが業界標準とみなされている理由を解説します。

SaaSベンダはCI/CDパイプラインを使用することで、サービスやアプリケーションを迅速に開発する能力を実現しています。CI/CDパイプラインのおかげで、ベンダは最先端のプラットフォームを短時間で刷新・構築できるだけでなく、万が一脆弱性や設定ミスが発見された場合に、アプリケーションのコンポーネントの修正やパッチ適用を短時間で実施できるのです。また、他のモジュラーコンポーネントと連携して機能する、小型でモジュール化の度合いが高いコンポーネントを構築し、より大規模で堅牢なアプリケーションエコシステムを形成することも可能です。さらに、ベンダのエンジニアチームがモジュール方式を採用し、CI/CDパイプラインワークフローを利用すると、モノリシックなアプリケーション全体を再ビルドする必要がなくなり、アプリケーションの単一コンポーネントに対するビルド、更新、パッチ適用を短時間で行えるようになります。

顧客がアプリケーションを自社のニーズに合わせて扱えるように、ベンダ企業はしばしば製品/アプリケーションをコンテナ化されたエンティティのセットとして提供します。各コンテナは大規模なアプリケーションを構成する単一のコンポーネントを保持しており、コンテナを組み合わせることでアプリケーション機能のエコシステムを生み出すのです。また、アプリケーションがサポートするインフラについても、ベンダによるコンテナ化が一般的です。例としては、ネットワーク メッシュ インフラの構成やユーザー、ロール、ポリシーのIAM構成などで、時にはUIオプションもコンテナ化されます。こうしたコンテナ化された個別のアプリケーションプラグインは、パッケージ化されてから外部リポジトリにアップロードされます。顧客は必要なアプリケーション本体と関連プラグインをこのリポジトリからダウンロードして、自分のクラウド環境でカスタマイズ可能なアプリケーションを構築できます。

ここで、悪意ある攻撃者が登場します。攻撃者の中には、ベンダのCI/CDパイプラインを侵害し、アプリケーションのコンテナ化されたエコシステムの中に悪意あるコードを挿入するという明確な目標の下で、計画的にSaaSベンダを狙う者も存在します。図1は、SaaSベンダのCI/CDパイプラインの侵害に使用される可能性がある8段階の活動を示したものです。攻撃者の最終目標はベンダのクラウド環境に足掛かりを築いた上で、ベンダの環境を利用して悪意あるコードを挿入したアプリケーションやプラグインを下流の組織に配信することにあります。こうなると、SolarWinds攻撃の影響が広範囲に及んだように、セキュリティ侵害を受ける環境の数は劇的に増加します。

攻撃者がCI/CDパイプラインの侵害に使用する可能性がある8段階の活動: 1)偵察(GitHub/GitLab、DockerHub、Artifact Hubなどの検索) 2)初期アクセス(アクセスIDとキー/セッショントークン、コンテナアクセス権、マウントされたコンテナソケット、マウントされたボリューム、共有名前空間の探索) 3)横方向の移動(クラウド環境の内部で横方向に移動し、CI作成プロセスを突き止める 4)CIパイプラインを標的とする 5)CIパイプラインをポイズニングする(選択した標的のコンテナイメージをポイズニング) 6)ポイズニングされたコンテナを被害者がダウンロード 7)ビーコン 8)攻撃者のキーボードアクセス
図1: 8段階のサプライチェーン侵害活動

ステップ1 – 偵察

まず、攻撃者は組織の活動状況を確認する必要があります。確認後、組織の従業員と顧客に関係する既知のIaC (コードとしてのインフラストラクチャ)リポジトリをすべてスキャンします。良く使われるIaCリポジトリとしては、GitLab/GitHub、ArtifactHub、Docker Hub、Quay、Google Container Registry (GCR)、Amazon Elastic Container Registry (ECR)があります。こうしたサービスの外部/内部レジストリには、攻撃活動に利用できる情報が含まれることがあります。Unit 42のリサーチャーが実施したレッドチーム演習では、ハードコードされたAWS IAMアクセスID 26個と、関連するキーペアまたはセッショントークンの発見に成功しています。ほとんどのキーペアは非アクティブ状態でしたが、一部のキーペアはクラウド環境へのアクセス権の取得に利用できるものでした。IAM資格情報の適切な保護は組織にとって重要な課題です。Unit 42による別の調査で、安全なIAM設定を導入していないクラウド環境の著しい増加が確認されていることも、その重要性を裏付けます。

ステップ2 – 初期アクセス

攻撃者は、ベンダのクラウドインフラへのアクセス権の取得を試みます。そしてその手段として、ベンダの既知のクラウドインフラの弱点を悪用します。あるいは、今回のレッドチーム演習で実演したように、もっと簡単な手法が使用される可能性もあります。今回の演習では、偵察フェーズで発見した、ハードコードされたIAMアクセスキーペアを使用することで、クラウド環境に造作もなくログインできました。この他にも初期アクセスには、ベンダのIaCテンプレートの設定ミスを利用する方法や、クラウドでホストされているアプリケーションやコンテナの脆弱性を利用する方法が以前から使用されています。

ステップ3 – ラテラルムーブ

攻撃者がクラウドでホストされているシステムへのアクセス権を取得すると、次に、組織のCIパイプラインを突き止めようとして、アクセスを拡大するプロセスが始まります。クラウド環境でのラテラルムーブは、従来のオンプレミスインフラでのラテラルムーブと同様ですが、コンテナエスケープ活動の存在だけが異なります。この活動で攻撃者は物理的に分離されたシステムへ水平移動するのではなく、仮想システムと、その仮想システムをホストしている物理システムの間を移動します。

コンテナエスケープの際に攻撃者はコンテナプロセスからコンテナのホストシステムへのラテラルムーブを試みます。そのため、攻撃者に追加の権限を与えてしまうと、その後の活動を許すばかりか、活動を容易にしてしまいます。コンテナエスケープは、たとえば、Kubernetes (k8s)クラスタで稼働している公開Webサーバープロセス「から」、当該k8sコンテナをホスト中のシステム「への」移動を指します。使用されるエスケープ手法は、k8sクラスタ上の設定ミスや脆弱性といった複数の要因によって変わりますが、ホストとコンテナが共有するボリューム、ライブラリ、名前空間を利用する場合や、コンテナに付与された過剰な権限の利用を伴う場合があります。さらに、コンテナそのものがIAMキーペアをホストしている場合、クラウドシステムをホストしているクラウドプラットフォームへの直接ログインを攻撃者に許してしまう可能性があります。コンテナエスケープ、IAMキーペアの探索、同じホストマシンの他のコンテナへの接続のいずかの手段によって、攻撃者はラテラルムーブと新しいクラウドインフラの探索を実現します。

このプロセスを通じて、攻撃者にCIパイプラインの所在を突き止められる可能性があります。

ステップ4 - CIパイプラインを標的とする

攻撃者が組織のCIパイプラインの所在を突き止めたら、次は、CIパイプラインの管理サービスへのアクセス権を取得する必要があります。ステップ3のラテラルムーブと同様、次のいずれかのアプローチが必要です。

  • CI管理サービスの脆弱性または設定ミスを悪用する。
  • 前段の活動(ステップ1~3)で侵害または窃盗によって取得した資格情報を使用して、CIプラットフォームへのアクセス権を持つ正規ユーザーになりすます能力。

ステップ5 - CIパイプラインのポイズニング

攻撃者がCIパイプラインへのアクセス権を取得したことで、さまざまな方法でCIパイプラインを攻撃できるようになりました。代表例がSaaSアプリケーションのコンポーネントの「ポイズニング」です。ポイズニングしたコンポーネントを使用して、アプリケーションのコンポーネントにバックドア機能を組み込むなどの悪意ある活動を行うことで、攻撃者は下流の顧客環境に侵入できるようになります。SolarWinds攻撃の事例では、Orionアプリケーション用のネットワーキング プラグイン モジュールに有害なバックドアが組み込まれていました。ネットワーク接続機能をアプリケーションのコンポーネントに組み込むことで、攻撃者は悪意あるコードをベンダの公式アプリケーションパッケージに紛れ込ませることに成功したのです。さらにこの攻撃では、悪意あるパッケージに正規の電子署名を行うことにも成功したため、有害なコンテンツがさらに厳重に隠ぺいされることになりました。その後、ベンダの顧客基盤がポイズニングされたパッケージを利用できる状態になれば、攻撃者は待つだけです。

ステップ6 - クライアントがポイズニングされたパッケージをダウンロード

ポイズニングされたパッケージをクライアントがダウンロードします。顧客はこのパッケージを正規のパッケージだと認識するでしょうから、クラウドやオンプレミスのインフラにパッケージを組み込んでしまい、攻撃目標への不正アクセスを許すことになります。

ステップ7 - C2インフラへの有害なビーコン

ポイズニングされたパッケージがインストールされると、攻撃者の悪意あるコードがコマンド&コントロール(C2)インフラにビーコンを送信するとともに、顧客の侵害されたクラウドインフラ上でバックドアを開きます。

ステップ8 - 攻撃者がキーボードアクセスを取得

サプライチェーン攻撃の新たな犠牲者の存在を、ビーコンが攻撃者に通知します。攻撃者はバックドアから侵害されたクラウドインスタンスやコンテナに侵入します。ここから、攻撃者は偵察、ラテラルムーブ、権限昇格の第二ラウンドを開始しますが、ここまでの活動との違いは、顧客の侵害されたインフラの内部を対象とする点です。目標に応じて、攻撃者は好きなだけ活動を行います。具体的には、知的財産の窃盗、恐喝(ランサムウェアなどを利用)、データ破壊などです。

以上、8つのステップを通じて、IAMキーペアを安全性の低い方法で保管する等の一見ささいなミスを糸口として、多数の組織のクラウドインフラに広範な被害をもたらす攻撃が起こりうることを説明しました。

SolarWinds – ビルド環境のセキュリティ対策の失敗

Unit 42のリサーチャーはレッドチーム演習を立案する際に、SolarWinds Orionのセキュリティ侵害を手本としました。この攻撃を成功に導いた要因を学び、リサーチャーが演習を実施する上での知見を得てから、SaaSベンダのCI/CDパイプラインがどのように侵害される可能性があるかを実演したのです。最終的にこの種のセキュリティ侵害は、下流に存在する無数の組織が自社環境に有害なバックドアを意図せず受け入れてしまうことにつながります。

1社のSaaSベンダのセキュリティ侵害から始まり、最低でも18,000社が侵害された可能性がある攻撃の流れを図2に示します。この図は急激な増加パターンのモデルを図示したもので、先述の攻撃ステップに従っています。攻撃者の一連の活動を通じて、1社のSaaSベンダに対する悪意ある改ざんが、下流の組織に拡散するおそれがあることが分かります。

1社のSaaSベンダに対するセキュリティ侵害が、多数の組織のセキュリティ侵害につながるおそれがあることを示す、急激な増加のモデル1)キーの設定ミス 2)横方向の移動 3)CI/CDパイプラインの絞り込み 4)CIパイプラインのポイズニング 5)サービスプロバイダ 6)被害を受けた組織 7)繰り返し
図2: 急激な増加のモデル

SolarWindsに対する攻撃も、このモデルを通して見ることができます。2020年12月13日、FireEyeはUNC2452と名付けた未知の攻撃者による侵害とデータ流出に関する情報を公開しました。Unit 42のリサーチャーはこのイベントと関連する活動を追跡し、攻撃グループをSolarStormと名付けました。そして、確認された手口、セキュリティ侵害インジケーター(IOC)、適切な行動指針をUnit 42 ATOM Viewerで公開しています。FireEyeによると、SolarStormが世界各国の組織の侵害に用いた手口はサプライチェーン攻撃であり、トロイの木馬化したSolarWinds Orion Platform用の更新ファイルが使用されていました(図3)。

SolarWinds Orionに対する攻撃経路1)SolarWindsのCIパイプライン 2)SolarWinds.Orion.Core.BusinessLayer.dll、デジタル証明書、バックドア 3)SolarWinds Orion COREホットフィックス#5パッケージ 4)被害者のSolarWindsシステム 5)コマンド&コントロール 6)攻撃者のキーボードアクセス
図3: SolarWinds Orionに対する攻撃経路

SolarStormはSolarWinds Orionプロジェクト向けのサプライチェーン業務だけをターゲットとし、ITのパフォーマンスと統計情報を監視するソフトウェアに狙いを定めました。そして、デジタル署名された正規の.dllファイルである「SolarWinds.Orion.Core.BusinessLayer.dll」を改ざんしたのです。この.dllファイルは、SolarWindsのプロセス「SolarWinds.BusinessLayerHost(x64).exe」に開かれるSolarWinds Orionプラグインとして動作するファイルです。その後、デジタル署名された.dllファイルが、SolarWinds Orion用の正規ホットフィックス#5のパッケージに追加されます(CORE-2019.4.5220.20574-SolarWinds-Core-v2019.4.5220-Hotfix5.msp)。要するに、組み込まれた「正規の」.dllファイルが、ソフトウェアサプライチェーンをトロイの木馬化する手段になったのです。サプライチェーンの感染がSolarWindの顧客に広がると、感染した環境にバックドアからアクセスできるようになります。ホットフィックスが最初にリリースされた2020年3月以降、バックドア活動はほとんど気づかれませんでした。その理由はC2トラフックが正規のOrion Improvement Programトラフィックに偽装されていたためです。

CI/CDパイプラインに対する攻撃の被害を軽減するには

各組織が今回のレッドチーム演習で行った活動に対処して被害を軽減できるように、Unit 42は以下の手順を推奨します。

開発者のアクセス権の制限: 開発者のアクセス権をCIリポジトリの内部から、CIリポジトリでの作業で開発者が直接使用するリポジトリだけに制限します。

  • 開発者アカウントのアクセス権を、各人の業務に必要なリポジトリだけに制限することで、機密データ漏えい対策が容易になります。アクセスを制限していれば、IAMキーペアの設定ミスをレッドチーム担当者に発見されなかったかもしれません。

コンテナとIaCテンプレートのスキャン: 開発サイクル全体でコンテナとIaCテンプレートをスキャンして設定ミスと脆弱性の有無をチェックします。

  • Prisma CloudのBridgeCrewやオープンソースのCheckovなどのツールでコンテナとIaCテンプレートを漏れなくスキャンして、設定ミスと脆弱性を発見することで、セキュアなクラウドインフラの構築を支援できます。また、悪意ある攻撃者が自社環境に足場を築くことを阻止する上でも効果的です。

ドリフト検出の導入: すべてのIaCとコンテナイメージを対象としたドリフト検出を導入します。

  • ドリフト検出とは、時間の経過に伴うコンテナやIaCテンプレートの改変をセキュリティチームに警告するプロセスです。Prisma Cloudの場合、BridgeCrewのスキャン機能にドリフト機能が追加されています

CI/CDインフラを監視して挙動の変化を検出: 開発者とネットワークトラフィックのパターンから、CI/CDインフラを監視して挙動の変化を検出します。

  • レッドチーム演習では、Amazon GuardDutyとPrisma Cloudが設定された1件のアカウントのおかげで、SaaSベンダのSOCがリサーチャーの活動の一部を突き止めることに成功しました。しかしながら、全アカウントで保護を有効化する以外にも、リサーチャーの活動の捕捉に使用できる検出メカニズムは他にも複数あったはずです。たとえば、Prisma Cloudの異常検出機能を使用していれば、ネットワーク上の偵察活動や異常なユーザーアクティビティに関するアラートをセキュリティチームが受け取れていたでしょう。

レッドチーム演習で明らかになった知見と、クラウドインフラを保護する方法の詳細は、「Unit 42クラウド脅威レポート2021年2H」をご覧ください。


The Anatomy of an Attack Against a Cloud Supply Pipeline

Oct 11, 2021
13 minutes
... views

The most recent Unit 42 Cloud Threat Report contains the high-level results of a red team exercise performed against a SaaS customer’s continuous integration and continuous development (CI/CD) pipeline. In other words, a customer asked our researchers to think like attackers, with the aim of revealing vulnerabilities and misconfigurations in their development operations (DevOps) processes. During the red team exercise, researchers took guidance from the strategies and techniques used by the attackers behind the SolarWinds Orion supply chain attack, in order to emulate a real-world threat and assess the security practices against known attacker techniques. The researchers posed as insider threats with the intent of gaining sufficient access to modify components of the CI/CD pipeline, resulting in a potential supply chain attack.

Researchers were able to achieve administrator access, aka “God Mode,” within the organization’s cloud environment due to the hardcoding of 26 identity and access management (IAM) key pairs being stored within an internal GitLab repository. (IAM key pairs are a set of security credentials – a public key and a private key – that can be used to prove identity when connecting to a public cloud instance. Since these are literally keys to a cloud environment, access to them should be safeguarded, especially if they correspond to privileged roles.)

In the case of the SaaS customer, every repository within the GitLab environment was accessible to any of the organization’s developer accounts. Some of the key pairs stored in the GitLab repository allowed researchers to escalate their permissions within the organization’s cloud environment to the extent that they would be capable of compromising the CI/CD pipeline, potentially resulting in hundreds, if not thousands, of downstream clients being affected.

Only one out of more than 50 total AWS accounts identified by the researchers was being monitored by Amazon GuardDuty (an AWS security tool that continuously monitors configured AWS accounts for malicious activity) and the Prisma Cloud platform. The organization did not have these security measures enabled on their other 49+ AWS accounts. Luckily, the organization’s security operations center (SOC) was able to detect a portion of the researchers’ actions through that one monitored AWS cloud account.

We are keenly aware of recent real-world supply chain attacks such as SolarStorm, the attack on SolarWinds, which targeted a SaaS provider’s CI/CD pipeline and compromised thousands of downstream clients. Given that we have seen major attacks of this nature in the wild, the findings from this red team exercise are significant and should be conveyed to all organizations that operate a CI/CD architecture.

The following sections will give readers insight into how a supply chain attack targeting a cloud-based SaaS provider could be carried out. By outlining the strategies and techniques Unit 42 researchers performed during their own red team exercise (as was described within the Cloud Threat Report), and which was itself modeled in part on the SolarWinds supply chain attack, this hopefully gives readers and architects of cloud-based CI/CD pipelines a view into how their own pipelines can be targeted and mined for sensitive information leading to the compromise of their environments. After the description of the attack, the final section provides guidance for how to mitigate attacks on the CI/CD pipeline.

 

Compromising the CI/CD Pipeline

In the red team exercise, our researchers showed they could compromise the customer’s CI/CD pipeline – but what exactly does that mean? What happens behind the scenes when a vendor’s supply chain, or its CI/CD pipeline, is compromised? To answer this question, let us first understand why CI/CD pipeline development channels are considered the industry standard.

SaaS vendors use CI/CD pipelines to provide rapid deployment capabilities for their services and applications. This allows the vendor to quickly innovate and build market-leading platforms, but it also allows the vendor to quickly fix or patch components of the application should vulnerabilities or misconfigurations be identified. Using the CI/CD pipeline allows organizations to build smaller, more modular components that function congruently with other modular components, forming a larger and more robust application ecosystem. Additionally, building in a modular fashion, and by using the CI/CD pipeline workflow, allows the vendor’s engineering teams to quickly build, update or patch singular components of the application instead of requiring them to completely rebuild a more monolithic application.

In order for customers to use applications as intended, vendor organizations will offer their product/application as a set of containerized entities. Each of these containers holds a singular component of the larger application that, when combined, creates the application’s functional ecosystem. Typically, vendors will also containerize an application’s supporting infrastructures such as network mesh infrastructure configurations; user, roles or policy IAM configurations; or even user interface options. Each of these individual containerized application plug-ins is then packaged and uploaded to an external repository, where thousands of customers can download the application and any of the associated plug-ins they require to build their customizable application within their own cloud environments.

This brings us to malicious attackers. Some attackers deliberately target SaaS vendors with the specific mission of compromising that vendor’s CI/CD pipeline to insert malicious code into a portion of the application’s containerized ecosystem. Figure 1 illustrates an eight-step operation an attacker could use to compromise a SaaS vendor’s CI/CD pipeline and ultimately gain a foothold in the vendor’s cloud environment and what’s worse, use that vendor’s environment to send poisoned applications or plugins to downstream organizations resulting in the exponential growth of compromised victim environments, as was seen within the fallout of the SolarWinds attack.

Eight steps attackers could use to compromise a CI/CD pipeline: 1) Reconnaissance (searching GitHub/GitLab, DockerHub, Artifact Hub, etc.), 2) Initial Access (seeking access ID and keys/session tokens, container access rights, mounted container sockets, mounted volumes, shared namespaces), 3) Lateral movement (Moving laterally inside of the cloud environment to locate the CI creation process; 4) Target CI Pipeline, 5) Poison CI Pipeline (Poison select target container images), 6) Victims download poisoned containers, 7) Beacon, 8) Attacker keyboard access.
Figure 1. Eight-step supply chain compromise operation.

Step 1 – Reconnaissance

First, attackers need to identify how an organization operates. Attackers will find and then scan any known Infrastructure as Code (IaC) repositories associated with the customer and any employees who work for them. Common IaC repositories are GitLab/GitHub, ArtifactHub, Docker Hub, Quay, Google Container Registry (GCR) and Amazon Elastic Container Registry (ECR). Each of these registries, either internal or external, can contain information that can be used during an offensive operation. During the red team exercise carried out by the Unit 42 researchers, we were able to uncover 26 hardcoded AWS IAM access IDs and their associated key pair or session token. While most of the key pairs were inactive, there were some that allowed the researchers to gain access to the cloud environment. Properly securing IAM credentials is a key concern for organizations as Unit 42 researchers have also found significant increases in the number of cloud environments not implementing secure IAM configurations.

 

Step 2 – Initial Access

The attackers will attempt to gain access to the vendor’s cloud infrastructure by leveraging weaknesses in the vendor's known cloud infrastructure. Or – as was the case with the red team exercise – attackers may take advantage of an easier way in. In the red team exercise, the researchers were able to simply log into the cloud environment using the hardcoded IAM access key pairs identified during the reconnaissance phase. Initial access will traditionally include leveraging misconfigurations within the vendor’s IaC templates, or vulnerabilities within the cloud-hosted applications and containers.

 

Step 3 – Lateral Movement

Once attackers have gained access to a cloud-hosted system, they will begin the process of expanding that access by attempting to locate the organization’s CI pipeline. Lateral movement within a cloud environment is similar to lateral movement within a traditional on-prem infrastructure, aside from the presence of container escape operations. For these operations, instead of moving laterally to physically separate systems, the attacker is moving between a virtual system and the physical system hosting that virtual system.

During a container escape, the attacker will attempt to move laterally from the container process to the container host system, allowing them additional privileges making future operations both possible and easier. For example, this could mean moving from a public-facing web server process running within a Kubernetes (k8s) cluster to the system which is hosting that k8s container. The escape technique used depends upon several factors, such as misconfigurations or vulnerabilities within the k8s cluster, but it could include leveraging shared volumes, libraries or namespaces between the host and the container, or it could involve taking advantage of overprivileged container rights. Additionally, the container itself may host IAM key pairs which could allow the attacker to simply log directly into the cloud platform hosting the cloud systems. By either escaping the container, discovering IAM key pairs or connecting to other containers within the same hosting machine, attackers can move laterally and discover new cloud infrastructure.

Through this process, attackers can find their way to the CI pipeline.

 

Step 4 – Target CI Pipeline

Once attackers locate the organization’s CI pipeline, they will need to acquire access to the CI pipeline management service. Similar to step 3’s lateral movement operations, this will require one of the following approaches:

  • The exploitation of a vulnerability or misconfiguration within the CI management service.
  • The ability to masquerade as a legitimate user with access to the CI platform by using compromised or stolen credentials obtained during previous operations (steps 1-3).

 

Step 5 – Poison CI Pipeline

The attackers now have access to the CI pipeline and can affect it in various ways, including “poisoning” components of the SaaS application. A poisoned component can be used to perform malicious actions such as building backdoor functionality into one or more of the application’s components, allowing attackers to enter downstream client environments. In the case of the SolarWinds attack, the attackers built a malicious backdoor into the networking plug-in module for the Orion application. By building network connectivity operations into the application’s components, attackers have an opportunity to integrate their malicious code into the vendor’s official application packaging. In the case of the SolarWinds attack, the attackers were even able to sign their malicious package with a legitimate digital signature, which further masked their malicious content. The poisoned package is then made available to the vendor’s customer base, and all the attackers need to do is wait.

 

Step 6 – Client Uploads Poisoned Images

The poisoned package is downloaded by a client. Since the customer is likely to perceive it as legitimate, the customer will build that package into their cloud or on-prem infrastructure – giving attackers the access they’ve been working toward.

 

Step 7 – Malicious Beacons to C2 Infrastructure

Once the poisoned package has been installed, the attackers’ malicious code will send a beacon to the attackers’ malicious command and control infrastructure (C2) and also open a backdoor within the compromised customer’s cloud infrastructure.

 

Step 8 – Attacker Gains Keyboard Access

The beacon signals to the attackers that there are new victims of their supply chain attack. The attackers will enter the compromised cloud instance or container through the backdoor. From here, the attackers will begin another round of reconnaissance, lateral movement and privilege escalation; however, now they will be looking within the compromised customer’s infrastructure. The attackers will perform any number of activities depending upon their mission set. This can include intellectual property theft, extortion (such as through ransomware), data destruction and so on.

These eight steps show how, from a seemingly innocuous mistake such as insecure storage of IAM key pairs, attackers can build to a far-reaching attack on the cloud infrastructures of many organizations.

 

SolarWinds – Failure to Secure the Build Environment

Unit 42 researchers took the SolarWinds Orion compromise as the north star when designing our red team operation. Understanding how the attackers successfully performed that attack informed how the researchers performed our operation – demonstrating how a SaaS vendor’s CI/CD pipeline can be compromised. A compromise of this nature could ultimately lead to tens of thousands of downstream organizations unwittingly becoming the recipient of malicious backdoors into their environments.

To offer an illustration of how, starting by compromising one SaaS vendor, attackers could compromise at least 18,000 unique organizations, see Figure 2. This lays out a model for an exponential growth pattern, following the steps described above, through which a malicious modification of a single SaaS vendor can spread to downstream organizations.

An exponential growth model for how attackers can start by compromising one SaaS vendor and compromise many organizations as a result. 1) Misconfigured Key, 2) Lateral movement, 3) Target CI/CD pipeline, 4) Poison CI pipeline, 5) Service providers, 6) victim organizations, 7) repeat.
Figure 2. Exponential growth model.

The attack on SolarWinds can be viewed through the lens of this model. On Dec. 13, 2020, FireEye released information related to a breach and data exfiltration originating from an unknown actor FireEye called UNC2452. Unit 42 researchers tracked this event and related activity and labeled the group SolarStorm. Unit 42 published the observed techniques, indicators of compromise (IoCs) and relevant courses of action in the Unit 42 ATOM Viewer. According to FireEye, SolarStorm compromised organizations across the globe via a supply chain attack that consists of a trojanized update file for the SolarWinds Orion Platform (see Figure 3).

Path of attack against SolarWinds Orion. 1) SolarWinds CI Pipeline, 2) SolarWinds, Orion, Core, Business Layer dll, digital certificate, backdoor, 3) SolarWinds Orion CORE HotFix #5 Package, 4) Victim's SolarWinds system, 5) command and control, 6) Attacker keyboard access.
Figure 3. Path of attack against SolarWinds Orion.

SolarStorm specifically targeted supply chain operations for SolarWinds’ Orion project, singling out their IT performance and statistics monitoring software. From there, SolarStorm threat actors modified the legitimate and digitally signed .dll file, SolarWinds.Orion.Core.BusinessLayer.dll. This .dll behaved as a SolarWinds Orion plug-in which was opened by the SolarWinds process, SolarWinds.BusinessLayerHost(x64).exe. The .dll file, having now been digitally signed, was added to the legitimate HotFix #5 package for SolarWinds Orion (CORE-2019.4.5220.20574-SolarWinds-Core-v2019.4.5220-Hotfix5.msp). The embedded “legitimate” .dll file essentially became a trojanized software supply chain technique. Once the supply chain infection was propagated to SolarWind customers, it provided backdoor access to infected environments. The backdoor operations went largely unnoticed, from as early as March 2020 when the HotFix was first released, as the C2 traffic masqueraded as legitimate Orion Improvement Program traffic.

 

How to Mitigate Attacks on the CI/CD Pipeline

In order for other organizations to combat and remediate the actions taken during this red team exercise, Unit 42 recommends the following steps:

Limit developer access to internal CI repositories to only those repositories which will be directly used by the developer working on that repository.

  • Limiting the access of a developer account to only the repositories required for a specific job will assist in preventing sensitive data leakage. Limiting access could have prevented the red team operators from identifying misconfigured IAM key pairs.

Scan containers and IaC templates for misconfigurations and vulnerabilities throughout the development cycle.

  • Scanning all containers and IaC templates for misconfigurations or vulnerabilities using tools like Prisma Cloud’s BridgeCrew, or the open-source tool Checkov, can assist organizations in building secure cloud infrastructure and prevent malicious actors from finding footholds in their environment.

Implement drift detection across all IaC and container images.

  • Drift detection is the process of alerting security teams to the modification of containers or IaC templates over time. Prisma Cloud now has drift detection built into its BridgeCrew scanning operations.

Monitor CI/CD infrastructure for behavior changes from developers and network traffic patterns.

  • In the red team exercise, the SaaS vendor’s SOC did identify some of the researchers’ activities thanks to a single account configured with Amazon GuardDuty and Prisma Cloud. However, there were several additional detection mechanisms that could have been used to catch the researchers – aside from being sure protections are enabled on all accounts. By using anomaly detection from Prisma Cloud, the security team could have been alerted to network reconnaissance operations or unusual user activity.

To learn more about what our red team exercise revealed – and how to protect your cloud infrastructure – download the Unit 42 Cloud Threat Report, 2H 2021.


Subscribe to the Blog!

Sign up to receive must-read articles, Playbooks of the Week, new feature announcements, and more.