Adversaries may abuse serverless computing, integration, and automation services to execute arbitrary code in cloud environments. Many cloud providers offer a variety of serverless resources, including compute engines, application integration services, and web servers.
Adversaries may abuse these resources in various ways as a means of executing arbitrary commands. For example, adversaries may use serverless functions to execute malicious code, such as crypto-mining malware (i.e. Resource Hijacking).(Citation: Cado Security Denonia) Adversaries may also create functions that enable further compromise of the cloud environment. For example, an adversary may use the IAM:PassRole permission in AWS or the iam.serviceAccounts.actAs permission in Google Cloud to add Additional Cloud Roles to a serverless cloud function, which may then be able to perform actions the original user cannot.(Citation: Rhino Security Labs AWS Privilege Escalation)(Citation: Rhingo Security Labs GCP Privilege Escalation)
Serverless functions can also be invoked in response to cloud events (i.e. Event Triggered Execution), potentially enabling persistent execution over time. For example, in AWS environments, an adversary may create a Lambda function that automatically adds Additional Cloud Credentials to a user and a corresponding CloudWatch events rule that invokes that function whenever a new user is created.(Citation: Backdooring an AWS account) This is also possible in many cloud-based office application suites. For example, in Microsoft 365 environments, an adversary may create a Power Automate workflow that forwards all emails a user receives or creates anonymous sharing links whenever a user is granted access to a document in SharePoint.(Citation: Varonis Power Automate Data Exfiltration)(Citation: Microsoft DART Case Report 001) In Google Workspace environments, they may instead create an Apps Script that exfiltrates a user's data when they open a file.(Citation: Cloud Hack Tricks GWS Apps Script)(Citation: OWN-CERT Google App Script 2024)
T1648「Serverless Function」(サーバーレス関数) は、AWS Lambda、Google Cloud Functions、Azure Functionsなどの FaaS(Function as a Service) 環境を悪用して、悪意のあるコードを実行する手法です。
クラウドネイティブな環境において、サーバーの管理を必要としない「関数」の仕組みを攻撃の足がかりや実行基盤として利用します。
この手法で攻撃者は、「短時間実行・自動スケール・隠蔽性の高い攻撃インフラ」を実現します。
コード実行:
既存の関数を書き換える、あるいは新しい関数を作成して、内部ネットワークへのスキャンやデータ窃取を実行します。
スケーラブルな攻撃:
クラウドの計算リソースを大量に消費し、分散型のDDoS攻撃やパスワード総当たり(ブルートフォース)攻撃を高速に実行します。
検知の回避:
サーバーレス関数は実行が終わるとインスタンスが消滅(エフェメラル)するため、従来のサーバー監視ツールやフォレンジック調査では証拠が残りにくい性質があります。
永続化への足がかり:
クラウド内の特定のイベント(S3へのファイル保存など)をトリガーにして自動起動するように設定し、潜伏し続けます。
攻撃者はまず、クラウド環境(AWS/GCP/Azure)の認証情報や、関数をデプロイできる権限を入手する必要があります。
権限の奪取:
漏洩したアクセスキーの入手、あるいはCI/CDパイプラインの脆弱性を突き、サーバーレス関数を操作できる権限(例:lambda:UpdateFunctionCode)を得ます。
悪意のあるコードの注入:
トリガーの設定:
実行と持ち出し:
関数が起動すると、環境変数からクラウドの認証情報を盗んだり、内部ネットワークにあるデータベースをスキャンしたりして、結果を外部へ送信します。
「関数のコード」と「関数に与える権限」の両方を守ることが重要です。
IAM権限の最小化:
関数に対して、実行に必要最低限の権限(Least Privilege)のみを付与します。特に「他の関数を書き換える権限」や「広範なデータへのアクセス権」を厳格に管理します。
コードスキャンと署名:
デプロイされる関数のコードに脆弱性がないかスキャンし、信頼できるソースからのコードのみを実行できるように「コード署名(Code Signing)」を導入します。
環境変数の保護:
APIキーやパスワードなどの機密情報を環境変数に直接書かず、Secrets Managerなどの専用サービスを利用して実行時に安全に取得するようにします。
ランタイム監視とロギング:
CloudWatch Logs や専用のクラウドセキュリティツールを用いて、関数の異常な実行時間、頻度、外部通信、タイムアウトの多発などを監視します。
「サーバーレス」という盲点:
従来のウイルス対策ソフトやEDRをインストールする「OS」が存在しないため、クラウドプロバイダーが提供するログや専用のセキュリティ製品(CWPP/CNAPP)での監視が不可欠です。
短命なプロセス:
実行が数秒で終わるため、攻撃が発生した瞬間にリアルタイムで検知・ブロックしないと、後から調査しても「犯行現場(インスタンス)」がすでに消えていることが多いです。
CWE-284: Improper Access Control:
クラウドのIAM設定ミスにより、意図しないユーザーに関数の作成・更新を許してしまう問題。
CWE-912: Managed Service API with Insecure Functions:
管理APIを通じて、サーバーレス環境の強力な実行能力を悪用される設計上の不備。
CWE-522: Insufficiently Protected Credentials:
関数の環境変数などに未暗号化の認証情報を保存してしまう不備。
Denonia:
AWS Lambdaを標的とした初のマルウェアとして報告されました。サーバーレス環境で仮想通貨のマイニングを行うために設計されていました。
CVE-2022-2385(など各クラウドの脆弱性):
サーバーレス環境自体の脆弱性により、他のユーザーの関数やデータにアクセスできてしまう可能性(マルチテナントの隔離不備)が稀に報告され、修正されています。
Event Injection:
脆弱性のある関数に対して、不正なイベントデータ(細工されたJSONなど)を送り込み、関数内でOSコマンドを実行させる攻撃(SQLインジェクションのサーバーレス版のようなもの)が多くの研究者によって指摘されています。
サーバーレス環境における「異常」を検知するには、「普段の実行時間のベースライン」を知ることが重要です。普段300msで終わる関数が、突然10秒(上限いっぱい)まで動くようになった場合、それは内部で攻撃ツールが動作している兆候かもしれません。
この攻撃手法を利用する脅威アクターは登録されていません。