【仕様変更】一部のCloudTrailのログでSourceIPAddressとUserAgentが”AWS Internal”になる件

2022.05.19

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

中山です

とあるCloudTrailの仕様変更について、気がついていない方が多いのではないかと思いましてこの記事を書いています。

結論

  • AWS Management Console等のProxy client経由で行われるAWS APIへのアクセスについて、CloudTrailのログに含まれるsourceIPAddressおよびuserAgentの情報が"AWS Internal"に置き換わる。
  • この仕様変更が2022年2月24日から展開されている。

変更された仕様について

CloudTrailのDocument historyには以下の記載があります。

Starting Feb 24, 2022, AWS CloudTrail began changing the userAgent and sourceIPAddress field values in any event that originated from an AWS Management Console session where a proxy client was used. For these events, CloudTrail replaces the values of the userAgent and sourceIPAddress fields with AWS Internal. CloudTrail made this change to standardize how it logs information for service actions across all AWS services. For more information, see CloudTrail record contents.

Document history

CloudTrailのレコードの詳細を説明するページを見ると、sourceIPAddressおよびuserAgentに関して以下の様な説明が追加されていました。

sourceIPAddress
The IP address that the request was made from. For actions that originate from the service console, the address reported is for the underlying customer resource, not the console web server. For services in AWS, only the DNS name is displayed. CloudTrail redacts the value of sourceIPAddress and replaces it with AWS Internal if the request was made with a proxy client (such as the AWS Management Console), and sessionCredentialFromConsole is present with a value of true.

CloudTrail record contents

userAgent
The agent through which the request was made, such as the AWS Management Console, an AWS service, the AWS SDKs or the AWS CLI. This field has a maximum size of 1 KB; content exceeding that limit is truncated. The following are example values:
- (一部割愛)
- AWS Internal – CloudTrail redacts the value of userAgent and replaces it with AWS Internal if the request was made with a proxy client (such as the AWS Management Console), and sessionCredentialFromConsole is present with a value of true.

CloudTrail record contents

これによれば、Management Console等を経由した操作ログではsource IP AddressおよびUser AgentがAWS Internalに置き換わる(AWS CLI / SDKを経由したアクセスは従来通り)ようです。

確認してみた

本当にそうなのか確認してみました。

社内開発環境として運用しているアカウントからECRのDescribeImagesの実行ログを抽出してみました。 DescribeImagesを選んだ意図は無く、最初にピックアップしたのがこのイベントだっただけです。

変更開始前の2022年2月22日は以下の様になっていました。 まだSource IP AddressとUser Agentが具体的に記載されています。

※認証に関連する識別子およびIPアドレス、リソース名などは適宜置換しています。

{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "AssumedRole",
        "principalId": "AROAXXXXXXXXXXXXXXXXX:user01",
        "arn": "arn:aws:sts::123456789012:assumed-role/user01/user01",
        "accountId": "123456789012",
        "accessKeyId": "ASIAXXXXXXXXXXXXXXXX",
        "sessionContext": {
            "sessionIssuer": {
                "type": "Role",
                "principalId": "AROAXXXXXXXXXXXXXXXXX",
                "arn": "arn:aws:iam::123456789012:role/user01",
                "accountId": "123456789012",
                "userName": "user01"
            },
            "webIdFederationData": {},
            "attributes": {
                "creationDate": "2022-02-22T00:19:21Z",
                "mfaAuthenticated": "true"
            }
        }
    },
    "eventTime": "2022-02-22T00:29:52Z",
    "eventSource": "ecr.amazonaws.com",
    "eventName": "DescribeImages",
    "awsRegion": "ap-northeast-1",
    "sourceIPAddress": "203.0.113.1",
    "userAgent": "aws-internal/3 aws-sdk-java/1.12.157 Linux/4.9.280-0.1.ac.225.84.332.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.322-b06 java/1.8.0_322 vendor/Oracle_Corporation cfg/retry-mode/standard",
    "requestParameters": {
        "registryId": "123456789012",
        "repositoryName": "organization01/repository01",
        "maxResults": 1000
    },
    "responseElements": null,
    "requestID": "878c84dd-85ea-4b89-abd1-5d5ae6ae4cc7",
    "eventID": "f6dfca46-c466-4a9b-8e7a-2b8e11db7fcb",
    "readOnly": true,
    "resources": [
        {
            "accountId": "123456789012",
            "ARN": "arn:aws:ecr:ap-northeast-1:123456789012:repository/organization01/repository01"
        }
    ],
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "recipientAccountId": "123456789012",
    "eventCategory": "Management"
}

これに対して、3月17日に記録されていた同じイベントは以下の様になっていました。 sourceIPAddress および userAgentAWS Internal で置換され、併せて "sessionCredentialFromConsole": "true" が記録されていることを確認できました。

{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "AssumedRole",
        "principalId": "AROAXXXXXXXXXXXXXXXXX:user01",
        "arn": "arn:aws:sts::123456789012:assumed-role/user01/user01",
        "accountId": "123456789012",
        "accessKeyId": "ASIAYYYYYYYYYYYYYYYY",
        "sessionContext": {
            "sessionIssuer": {
                "type": "Role",
                "principalId": "AROAXXXXXXXXXXXXXXXXX",
                "arn": "arn:aws:iam::123456789012:role/user01",
                "accountId": "123456789012",
                "userName": "user01"
            },
            "webIdFederationData": {},
            "attributes": {
                "creationDate": "2022-03-17T01:31:31Z",
                "mfaAuthenticated": "true"
            }
        }
    },
    "eventTime": "2022-03-17T01:32:27Z",
    "eventSource": "ecr.amazonaws.com",
    "eventName": "DescribeImages",
    "awsRegion": "ap-northeast-1",
    "sourceIPAddress": "AWS Internal",
    "userAgent": "AWS Internal",
    "requestParameters": {
        "registryId": "123456789012",
        "repositoryName": "organization01/repository02",
        "nextToken": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "maxResults": 1000
    },
    "responseElements": null,
    "requestID": "953a3b2c-84bc-419b-b312-6bc78e0f6569",
    "eventID": "bf8c830c-6d06-4f08-a249-396b0223ae15",
    "readOnly": true,
    "resources": [
        {
            "accountId": "123456789012",
            "ARN": "arn:aws:ecr:ap-northeast-1:123456789012:repository/organization01/repository02"
        }
    ],
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "recipientAccountId": "123456789012",
    "eventCategory": "Management",
    "sessionCredentialFromConsole": "true"
}

以上のようにドキュメントの記載にあるような変化を確認できました。

想定される影響について(推測)

この仕様変更による影響の有無および程度に関しては様々だと思いますが、以下の様なものが想定されると思います。あくまでも推測なので、実際の影響の有無は個別にご確認をお願いします。

  • 問題のあるアクティビティを検知した際にオペレーターがログを確認ないしは分析している なおかつ その際にSource IP Address および User Agentを参照している場合
  • 何らかのSIEMや脅威インテリジェンスと連携し、malicious IPからのアクセスを検知するシステムを運用している場合
  • その他、source IP AddressやUser Agentを参照している運用業務・分析システム

影響の緩和策(例)

一例ですが、同じ作業主体によるサインインイベント(ConsoleSignInEvent等)のログに記録されるSource IP Address / User Agentを参照することが考えられます。

具体的には、Switch Roleを利用した運用を行っている場合には userIdentity.arnuserIdentity.sessionContext.attributes.creationDate あたりを利用してサインインイベント(SwitchRole)を特定することができます。 以下のクエリはAthenaでSwitchRoleイベントを特定する例となります。

SELECT *
FROM "cloudtrail"."cloudtrail_logs"
WHERE timestamp >= '2022/03/17'
	AND timestamp < '2022/03/18'
	AND userIdentity.arn = 'arn:aws:sts::123456789012:assumed-role/user01/user01' # userIdentity.arn
	AND eventname = 'SwitchRole'
	AND eventtime = '2022-03-17T01:31:31Z' # userIdentity.sessionContext.attributes.creationDate

結果は割愛しますが、1件のSwitch Roleイベントのログを抽出することができ、そのログにはSource IP AddressおよびUser Agentが記載されていました。

Athenaでテーブルを作成する方法等は以下のドキュメントで紹介されています。

IAMの利用方法によっては(SwitchRoleを利用していない場合は)ConsoleLoginイベントなど他のイベントを特定するべきケースもあると思うので、個別にご確認ください。

まとめ

今回の仕様変更は事前のアナウンス無しで実施されていたこと / これまでできていたことができなくなる可能性があることなど、「影響を受けていることに気がついていない」利用者が多いかもしれないと思いましたのでブログにまとめました。

AWSサービスからのアクセスだけでなく、作業主体が人間であるイベントの場合でもSource IP AddressおよびUser Agentが AWS Internal になるのはそれなりに影響が大きいのではないかと推察しました。 個人的にはサービスの改善や発展のために必要なのであれば仕様の変更や機能の廃止などは積極的に実施してほしいと思うのですが、この類の変更に関しては事前の通知がほしいなぁと思いました。

その他の参考情報