

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 預防跨服務混淆代理人
<a name="security-iam-cwim-confused-deputy"></a>

混淆代理人是由不同實體強制執行動作的實體 (服務或帳戶)。這種類型的冒充可能發生跨帳戶和跨服務。

為了防止混淆代理人， AWS 提供工具，協助您使用可存取 中資源的服務主體來保護所有 服務的資料 AWS 帳戶。本節重點介紹 Internet Monitor 特定跨服務預防混淆代理人；但是，您可以在《IAM 使用者指南》的[混淆代理人問題](https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html)一節，了解此主題的更多資訊。**

若要限制 IAM 授予網路監視器存取 資源的許可，建議您在資源政策[https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceaccount](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceaccount)中使用全域條件內容金鑰 [https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourcearn](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourcearn) 和 。

如果您同時使用這兩個全域條件內容索引鍵，且`aws:SourceArn`值包含 AWS 帳戶 ID，則 `aws:SourceAccount`中的值和 AWS 帳戶 `aws:SourceArn`必須在相同政策陳述式中使用相同的 AWS 帳戶 ID。

對於 Internet Monitor，您可以指定 `aws:SourceAccount` 的帳戶 ID，以及 `aws:SourceArn` 的監視器 ARN。對於跨服務存取，您也可以使用適用於 `aws:SourceArn` 的監視器 ARN。

**注意**  
範混淆代理人問題的最有效方法是使用 `aws:SourceArn` 全域條件內容金鑰，以及資源的**完整 ARN**。如果不知道資源的完整 ARN，或者如果您指定多個資源，請使用 `aws:SourceArn` 全域條件內容金鑰，同時使用 ARN 未知部分的萬用字元 (`*`) 。例如 `arn:aws:internetmonitor:us-east-1:{{111122223333}}:*`。

以下是承擔角色政策的範例，其中顯示如何預防混淆代理人問題。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": {
    "Sid": "ConfusedDeputyPreventionExamplePolicy",
    "Effect": "Allow",
    "Principal": {
      "Service": "internetmonitor.amazonaws.com"
    },
    "Action": "sts:AssumeRole",
    "Condition": {
      "ArnLike": {
        "aws:SourceArn": "arn:aws:internetmonitor:us-east-1:{{111122223333}}:monitor/confused-deputy-monitor"
      },
      "StringEquals": {
        "aws:SourceAccount": "111122223333"
      }
    }
  }
}
```

------