내용으로 건너뛰기

How I can limit my role trust policy to a corporate CIDR range?

0

I have a role defined which is cross account assumed by a central technical user

Account A - techuser

Account B - role2assume

In the trust policy of the role2assume I limit the "sts:AssumeRole" to the user from Account A in conjunction with an external ID. Now I want to further limit the assumption to a specific IP CIDR within our corporate network (only access via VPN). Following Policy returns with the error "No private IP CIDR allowed", where as https://aws.amazon.com/de/blogs/security/establishing-a-data-perimeter-on-aws/ states that SourceIP can contain a corporate Network range.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::<ACCOUNTA>:user/techuser"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "sts:ExternalId": "<EXTERNALID>"
                }
            }
        },
	{
            "Effect": "Deny",
            "Action": "*",
            "Resource": "*",
            "Condition": {
                "NotIpAddress": {
                    "aws:SourceIp": "10.0.0.0/16"
                },
                "Bool": {
                    "aws:ViaAWSService": "false"
                }
            }
        }
    ]
}

질문됨 2년 전480회 조회

2개 답변
4

Hello.

"aws:SourceIp" can be controlled using a public IP address, but cannot be controlled using a private IP address.
In other words, you cannot restrict connections from private IP addresses.
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceip

Use this key to compare the requester's IP address with the IP address that you specify in the policy. The aws:SourceIp condition key can only be used for public IP address ranges.

전문가

답변함 2년 전

전문가

검토됨 2년 전

전문가

검토됨 2년 전

0

Okay, so the documentation in the link I shared is an way misleading?

Is there any other way to limit access to a private CIDR range? We adopted this approach https://learnaws.cloud/gitlab/securely-deploy-from-gitlab-to-aws-using-iam-assume-roles/ and want to further limit access to the role only to the Gitlab instances running locally.

답변함 2년 전

  • Your private IPs are only visible inside your private network. If you call an AWS API endpoint on the public internet, you won't be sending the request over the internet from your private IP. You'll be sending it from a public NAT address of your corporate firewall, and that's the IP you'll be showing to AWS. As Riku Kobayashi correctly explained, you'll either need to put your internet-facing NAT addresses of your firewall in the aws:SourceIp condition clause, or set up VPC endpoints reachable from your internal network and use aws:SourceVpc or aws:SourceVpce to restrict access.

  • The phrase "corporate address range" in the document is quite correct but it refers to the IP addresses your corporation uses to connect to the relevant AWS service endpoint. Usually, you'll do that over the public internet, and the corporate address range is the public IP or range of them used for NATing on your firewall. You can also do it over an internal network connection, such as over a VPN, to a VPC with the relevant endpoint, but in general, that's a relatively advanced and unusual setup that you'd know about.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠