-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add check for all vpcs need flow logs (#885)
* feat: add check for all vpcs need flow logs Resolves #886 Signed-off-by: Owen Rumney <[email protected]> * docs: add the remediation documentation Signed-off-by: Owen Rumney <[email protected]> * remove missing property ref * fix conflict issues * fix schema Signed-off-by: Owen Rumney <[email protected]> Co-authored-by: Liam Galvin <[email protected]>
- Loading branch information
Showing
14 changed files
with
293 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
1. Sign into the management console | ||
2. Select Services then VPC | ||
3. In the left navigation pane, select Your VPCs | ||
4. Select a VPC | ||
5. In the right pane, select the Flow Logs tab. | ||
6. If no Flow Log exists, click Create Flow Log | ||
7. For Filter, select Reject | ||
8. Enter in a Role and Destination Log Group | ||
9. Click Create Log Flow | ||
10. Click on CloudWatch Logs Group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
Enable flow logs for VPC | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
Enable flow logs for VPC | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
VPC Flow Logs provide visibility into network traffic that traverses the VPC and can be used to detect anomalous traffic or insight during security workflows. | ||
|
||
### Impact | ||
Without VPC flow logs, you risk not having enough information about network traffic flow to investigate incidents or identify security issues. | ||
|
||
<!-- DO NOT CHANGE --> | ||
{{ remediationActions }} | ||
|
||
### Links | ||
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/RootDeviceStorage.html | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
internal/rules/aws/ec2/require_vpc_flow_logs_for_all_vpcs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package ec2 | ||
|
||
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 CheckRequireVPCFlowLogs = rules.Register( | ||
scan.Rule{ | ||
AVDID: "AVD-AWS-0178", | ||
Aliases: []string{"aws-autoscaling-enable-at-rest-encryption"}, | ||
Provider: providers.AWSProvider, | ||
Service: "ec2", | ||
ShortCode: "require-vpc-flow-logs-for-all-vpcs", | ||
Summary: `VPC Flow Logs is a feature that enables you to capture information about the IP traffic going to and from network interfaces in your VPC. After you've created a flow log, you can view and retrieve its data in Amazon CloudWatch Logs. It is recommended that VPC Flow Logs be enabled for packet "Rejects" for VPCs.`, | ||
Impact: "Without VPC flow logs, you risk not having enough information about network traffic flow to investigate incidents or identify security issues.", | ||
Resolution: "Enable flow logs for VPC", | ||
Explanation: `VPC Flow Logs provide visibility into network traffic that traverses the VPC and can be used to detect anomalous traffic or insight during security workflows.`, | ||
Links: []string{ | ||
"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/RootDeviceStorage.html", | ||
}, | ||
Terraform: &scan.EngineMetadata{}, | ||
CloudFormation: &scan.EngineMetadata{}, | ||
Severity: severity.Medium, | ||
}, | ||
func(s *state.State) (results scan.Results) { | ||
for _, vpc := range s.AWS.EC2.VPCs { | ||
if vpc.FlowLogsEnabled.IsFalse() { | ||
results.Add("VPC Flow Logs is not enabled for VPC "+vpc.ID.Value(), vpc) | ||
} else { | ||
results.AddPassed(vpc) | ||
} | ||
} | ||
return | ||
}, | ||
) |
Oops, something went wrong.