Cross-service confused deputy prevention - Amazon Database Migration Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Cross-service confused deputy prevention

The confused deputy problem is a security issue where an entity that doesn't have permission to perform an action can coerce a more-privileged entity to perform the action. In Amazon, cross-service impersonation can result in the confused deputy problem. Cross-service impersonation can occur when one service (the calling service) calls another service (the called service). The calling service can be manipulated to use its permissions to act on another customer's resources in a way it should not otherwise have permission to access. To prevent this, Amazon provides tools that help you protect your data for all services with service principals that have been given access to resources in your account.

We recommend using the aws:SourceArn and aws:SourceAccount global condition context keys in resource policies to limit the permissions that Amazon Database Migration Service gives another service to the resource. If the aws:SourceArn value doesn't contain the account ID, such as an Amazon DMS replication instance name (ARN), you must use both global condition context keys to limit permissions. If you use both global condition context keys and the aws:SourceArn value contains the account ID, the aws:SourceAccount value and the account in the aws:SourceArn value must use the same account ID when used in the same policy statement. Use aws:SourceArn if you want only one resource to be associated with the cross-service access. Use aws:SourceAccount if you want to allow any resource in that account to be associated with the cross-service use.

Amazon DMS supports confused deputy options starting from the 3.4.7 version and higher. For more information, see Amazon Database Migration Service 3.4.7 release notes. If your replication instance uses Amazon DMS version 3.4.6 or lower, make sure that you upgrade to latest version before you set the confused deputy options.

The most effective way to protect against the confused deputy problem is to use the aws:SourceArn global condition context key with the full ARN of the resource. If you don't know the full ARN of the resource or if you are specifying multiple resources, use the aws:SourceArn global context condition key with wildcard characters (*) for the unknown portions of the ARN. For example, arn:aws-cn:dms:*:123456789012:rep:*.

IAM roles to use with Amazon DMS API for cross-service confused deputy prevention

To use the Amazon CLI or the Amazon DMS API for your database migration, you must add the dms-vpc-role and dms-cloudwatch-logs-role IAM roles to your Amazon account before you can use the features of Amazon DMS. For more information, see Creating the IAM roles to use with the Amazon CLI and Amazon DMS API.

The following example shows policies for using the dms-vpc-role role with the my-replication-instance replication instance. Use these policies to prevent the confused deputy problem.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "dms.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "AWS:SourceAccount": "your_account_id" }, "ArnEqual": { "AWS:SourceArn": "arn:aws:dms:your_region:your_account_id:rep:my-replication-instance" } } } ] }

IAM policy to store preflight assessments in Amazon S3 for cross-service confused deputy prevention

To store preassessment results in your S3 bucket, you create an IAM policy that allows Amazon DMS to manage objects in Amazon S3. For more information, see Create IAM resources .

The following example shows a trust policy with confused deputy conditions that are set on an IAM role that allows Amazon DMS to access all tasks and assessment runs under a specified user account.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "dms.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "AWS:SourceAccount": "your_account_id" }, "ArnLike": { "AWS:SourceArn": [ "arn:aws:dms:your_region:your_account_id:assessment-run:*", "arn:aws:dms:region:your_account_id:task:*" ] } } } ] }

Using Amazon DynamoDB as a target endpoint with Amazon DMS for cross-service confused deputy prevention

To use Amazon DynamoDB as a target endpoint for your database migration, you must create the IAM role that allows Amazon DMS to assume and grant access to the DynamoDB tables. Then, use this role when you create your target DynamoDB endpoint in Amazon DMS. For more information, see Using Amazon DynamoDB as a target.

The following example shows a trust policy with confused deputy conditions that are set on an IAM role that allows all Amazon DMS endpoints to access DynamoDB tables.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "dms.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "AWS:SourceAccount": "your_account_id" }, "ArnLike": { "AWS:SourceArn": "arn:aws:dms:your_region:your_account_id:endpoint:*" } } } ] }