Skip to content

fix(cloudtrail): do not attach s3 bucket permission when orgId is not set for organization trail#30490

Closed
sarisia wants to merge 1 commit intoaws:mainfrom
sarisia:cloudtrail-missing-orgid
Closed

fix(cloudtrail): do not attach s3 bucket permission when orgId is not set for organization trail#30490
sarisia wants to merge 1 commit intoaws:mainfrom
sarisia:cloudtrail-missing-orgid

Conversation

@sarisia
Copy link
Copy Markdown
Contributor

@sarisia sarisia commented Jun 7, 2024

Issue # (if applicable)

no open issue

Reason for this change

Organization trail without orgId attaches improper s3 bucket policy
which allows cloudtrail to write to /AWSLogs/undefined/* prefix.

                        {
                            "Action": "s3:PutObject",
                            "Condition": {
                                "StringEquals": {
                                    "s3:x-amz-acl": "bucket-owner-full-control",
                                    "aws:SourceArn": {
                                        "Fn::Join": [
                                            "",
                                            [
                                                "arn:",
                                                {
                                                    "Ref": "AWS::Partition"
                                                },
                                                ":cloudtrail:us-east-1:123456789012:trail/undefined"
                                            ]
                                        ]
                                    }
                                }
                            },
                            "Effect": "Allow",
                            "Principal": {
                                "Service": "cloudtrail.amazonaws.com"
                            },
                            "Resource": {
                                "Fn::Join": [
                                    "",
                                    [
                                        {
                                            "Fn::GetAtt": [
                                                "TrailS30071F172",
                                                "Arn"
                                            ]
                                        },
                                        "/AWSLogs/undefined/*"
                                    ]
                                ]
                            }
                        }

(there is also another bug which trail name becomes undefined, which is addressed in #30489 based on this PR)

Description of changes

  • do not attach s3 bucket policy if isOrganizationTrail is set and orgId is not set
    • generate warning if attaching s3 bucket policy is skipped

Description of how you validated changes

  • added unit test

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Jun 7, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team June 7, 2024 20:39
@github-actions github-actions bot added the p2 label Jun 7, 2024
Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@sarisia
Copy link
Copy Markdown
Contributor Author

sarisia commented Jun 7, 2024

Exemption Request: deploying this requires AWS organization management account

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Jun 7, 2024
@sarisia sarisia marked this pull request as ready for review June 7, 2024 21:00
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 7, 2024
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

@sarisia sarisia force-pushed the cloudtrail-missing-orgid branch from e70c347 to 5b8134d Compare June 29, 2024 06:06
@sarisia
Copy link
Copy Markdown
Contributor Author

sarisia commented Jun 29, 2024

Could someone please review this? Thanks

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 5b8134d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

@aws-cdk-automation aws-cdk-automation added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Jul 7, 2024
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

The pull request linter fails with the following errors:

❌ Fixes must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing Exemption Request and/or Clarification Request.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jul 7, 2024

⚠️ The sha of the head commit of this PR conflicts with #30778. Mergify cannot evaluate rules on this PR. ⚠️

mergify bot pushed a commit that referenced this pull request Dec 12, 2025
… set for organization trail (#30778)

Recreate #30490 

### Issue # (if applicable)

no open issue

### Reason for this change



Organization trail without `orgId` attaches improper s3 bucket policy
which allows cloudtrail to write to `/AWSLogs/undefined/*` prefix.

```json
                        {
                            "Action": "s3:PutObject",
                            "Condition": {
                                "StringEquals": {
                                    "s3:x-amz-acl": "bucket-owner-full-control",
                                    "aws:SourceArn": {
                                        "Fn::Join": [
                                            "",
                                            [
                                                "arn:",
                                                {
                                                    "Ref": "AWS::Partition"
                                                },
                                                ":cloudtrail:us-east-1:123456789012:trail/undefined"
                                            ]
                                        ]
                                    }
                                }
                            },
                            "Effect": "Allow",
                            "Principal": {
                                "Service": "cloudtrail.amazonaws.com"
                            },
                            "Resource": {
                                "Fn::Join": [
                                    "",
                                    [
                                        {
                                            "Fn::GetAtt": [
                                                "TrailS30071F172",
                                                "Arn"
                                            ]
                                        },
                                        "/AWSLogs/undefined/*"
                                    ]
                                ]
                            }
                        }
```



### Description of changes



- do not attach s3 bucket policy if `isOrganizationTrail` is set and `orgId` is not set
  - generate warning if attaching s3 bucket policy is skipped

### Description of how you validated changes



- added unit test

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
pahud pushed a commit to pahud/aws-cdk that referenced this pull request Jan 24, 2026
… set for organization trail (aws#30778)

Recreate aws#30490 

### Issue # (if applicable)

no open issue

### Reason for this change



Organization trail without `orgId` attaches improper s3 bucket policy
which allows cloudtrail to write to `/AWSLogs/undefined/*` prefix.

```json
                        {
                            "Action": "s3:PutObject",
                            "Condition": {
                                "StringEquals": {
                                    "s3:x-amz-acl": "bucket-owner-full-control",
                                    "aws:SourceArn": {
                                        "Fn::Join": [
                                            "",
                                            [
                                                "arn:",
                                                {
                                                    "Ref": "AWS::Partition"
                                                },
                                                ":cloudtrail:us-east-1:123456789012:trail/undefined"
                                            ]
                                        ]
                                    }
                                }
                            },
                            "Effect": "Allow",
                            "Principal": {
                                "Service": "cloudtrail.amazonaws.com"
                            },
                            "Resource": {
                                "Fn::Join": [
                                    "",
                                    [
                                        {
                                            "Fn::GetAtt": [
                                                "TrailS30071F172",
                                                "Arn"
                                            ]
                                        },
                                        "/AWSLogs/undefined/*"
                                    ]
                                ]
                            }
                        }
```



### Description of changes



- do not attach s3 bucket policy if `isOrganizationTrail` is set and `orgId` is not set
  - generate warning if attaching s3 bucket policy is skipped

### Description of how you validated changes



- added unit test

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants