-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(aws): CloudTrail global service events rule #1401
base: master
Are you sure you want to change the base?
Changes from all commits
f1a07b4
0d14b7e
dd5fc30
2af3c7d
24c9036
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ Enable encryption at rest | |
|
||
```yaml--- | ||
Resources: | ||
BadExample: | ||
GoodExample: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my previous comment, the policy script has been updated as part of this PR and this should say GoodExample: |
||
Type: AWS::CloudTrail::Trail | ||
Properties: | ||
IsLogging: true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ Turn on log validation for Cloudtrail | |
|
||
```yaml--- | ||
Resources: | ||
BadExample: | ||
GoodExample: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my previous comment, the policy script has been updated as part of this PR and this should say GoodExample: |
||
Type: AWS::CloudTrail::Trail | ||
Properties: | ||
IsLogging: true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
Enable include global service events for Cloudtrail | ||
|
||
```yaml--- | ||
Resources: | ||
GoodExampleTrail: | ||
Type: AWS::CloudTrail::Trail | ||
Properties: | ||
IncludeGlobalServiceEvents: true | ||
S3BucketName: "my-bucket" | ||
TrailName: "Cloudtrail" | ||
|
||
``` | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
Enable include global service events for Cloudtrail | ||
|
||
```hcl | ||
resource "aws_cloudtrail" "good_example" { | ||
include_global_service_events = true | ||
s3_bucket_name = "abcdefgh" | ||
} | ||
|
||
``` | ||
|
||
#### Remediation Links | ||
- https://registry.terraform.io/providers/rgeraskin/aws2/latest/docs/resources/cloudtrail#include_global_service_events | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
Include Global Service Events is a default value for Cloudtrail and it publishes events from global services that are not region specific such as IAM, STS and CloudFront. It is feasible that a rogue actor compromising an AWS account might want to disable this field to remove trace of their actions. | ||
|
||
### Impact | ||
Events from global services such as IAM are not being published to the log files | ||
|
||
<!-- DO NOT CHANGE --> | ||
{{ remediationActions }} | ||
|
||
### Links | ||
- https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-concepts.html#cloudtrail-concepts-global-service-events | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cloudtrail | ||
|
||
var cloudFormationIncludeGlobalServiceEventsGoodExamples = []string{ | ||
`--- | ||
Resources: | ||
GoodExample: | ||
Type: AWS::CloudTrail::Trail | ||
Properties: | ||
IncludeGlobalServiceEvents: true | ||
S3BucketName: "my-bucket" | ||
TrailName: "Cloudtrail" | ||
`, | ||
} | ||
|
||
var cloudFormationIncludeGlobalServiceEventsBadExamples = []string{ | ||
`--- | ||
Resources: | ||
BadExample: | ||
Type: AWS::CloudTrail::Trail | ||
Properties: | ||
IncludeGlobalServiceEvents: false | ||
S3BucketName: "my-bucket" | ||
TrailName: "Cloudtrail" | ||
`, | ||
} | ||
|
||
var cloudFormationIncludeGlobalServiceEventsLinks = []string{} | ||
|
||
var cloudFormationIncludeGlobalServiceEventsRemediationMarkdown = `` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cloudtrail | ||
|
||
import ( | ||
"github.com/aquasecurity/defsec/internal/rules" | ||
"github.com/aquasecurity/defsec/pkg/providers" | ||
"github.com/aquasecurity/defsec/pkg/scan" | ||
"github.com/aquasecurity/defsec/pkg/severity" | ||
"github.com/aquasecurity/defsec/pkg/state" | ||
) | ||
|
||
var checkIncludeGlobalServiceEvents = rules.Register( | ||
scan.Rule{ | ||
AVDID: "AVD-AWS-0345", | ||
Provider: providers.AWSProvider, | ||
Service: "cloudtrail", | ||
ShortCode: "include-global-service-events", | ||
Summary: "Specifies whether Cloudtrail is publishing events from global services such as IAM to the log files. ", | ||
Impact: "Events from global services such as IAM are not being published to the log files", | ||
Resolution: "Enable include global service events for Cloudtrail", | ||
Explanation: `Include Global Service Events is a default value for Cloudtrail and it publishes events from global services that are not region specific such as IAM, STS and CloudFront. It is feasible that a rogue actor compromising an AWS account might want to disable this field to remove trace of their actions.`, | ||
Links: []string{ | ||
"https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-concepts.html#cloudtrail-concepts-global-service-events", | ||
}, | ||
Terraform: &scan.EngineMetadata{ | ||
GoodExamples: terraformIncludeGlobalServiceEventsGoodExamples, | ||
BadExamples: terraformIncludeGlobalServiceEventsBadExamples, | ||
Links: terraformIncludeGlobalServiceEventsLinks, | ||
RemediationMarkdown: terraformIncludeGlobalServiceEventsRemediationMarkdown, | ||
}, | ||
CloudFormation: &scan.EngineMetadata{ | ||
GoodExamples: cloudFormationIncludeGlobalServiceEventsGoodExamples, | ||
BadExamples: cloudFormationIncludeGlobalServiceEventsBadExamples, | ||
Links: cloudFormationIncludeGlobalServiceEventsLinks, | ||
RemediationMarkdown: cloudFormationIncludeGlobalServiceEventsRemediationMarkdown, | ||
}, | ||
Severity: severity.Medium, | ||
}, | ||
func(s *state.State) (results scan.Results) { | ||
for _, trail := range s.AWS.CloudTrail.Trails { | ||
if trail.IncludeGlobalServiceEvents.IsFalse() { | ||
results.Add( | ||
"Trail is not publishing events from global services such as IAM to the log files.", | ||
trail.IncludeGlobalServiceEvents, | ||
) | ||
} else { | ||
results.AddPassed(&trail) | ||
} | ||
} | ||
return | ||
}, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package cloudtrail | ||
|
||
var terraformIncludeGlobalServiceEventsGoodExamples = []string{ | ||
` | ||
resource "aws_cloudtrail" "good_example" { | ||
include_global_service_events = true | ||
s3_bucket_name = "abcdefgh" | ||
} | ||
`, | ||
} | ||
|
||
var terraformIncludeGlobalServiceEventsBadExamples = []string{ | ||
` | ||
resource "aws_cloudtrail" "bad_example" { | ||
include_global_service_events = false | ||
s3_bucket_name = "abcdefgh" | ||
} | ||
`, | ||
} | ||
|
||
var terraformIncludeGlobalServiceEventsLinks = []string{ | ||
`https://registry.terraform.io/providers/rgeraskin/aws2/latest/docs/resources/cloudtrail#include_global_service_events`, | ||
} | ||
|
||
var terraformIncludeGlobalServiceEventsRemediationMarkdown = `` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why this has changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should say GoodExample, after updating it on the policy it still needs to be updated on the auto generated docs. Updated from this policy as part of this PR: https://github.com/aquasecurity/defsec/blob/master/rules/cloud/policies/aws/cloudtrail/enable_all_regions.cf.go