Skip to content
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(iam): add new check iam_policy_cloudshell_admin_not_attached #5437

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

MarioRgzLpz
Copy link
Member

Context

Add a new check to ensure IAM identities (users, roles, or groups) don't have the AWS managed policy AWSCloudShellFullAccess attached. The control fails if this policy is present.

AWSCloudShellFullAccess provides full access to AWS CloudShell, including file upload/download capabilities and sudo permissions, which can pose security risks. Adhere to the principle of least privilege and avoid attaching this broad policy.

Description

Added new check iam_cloudshell_admin_policy_not_attached with respective unit tests. Added new attribute entities_attached_to_cloudshell_policy with method _list_entities_for_policy and a test for the method.

Checklist

License

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

@MarioRgzLpz MarioRgzLpz requested review from a team as code owners October 16, 2024 17:00
@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label Oct 16, 2024
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 89.18919% with 4 lines in your changes missing coverage. Please review.

Project coverage is 89.34%. Comparing base (45c32ab) to head (bbbfe12).
Report is 20 commits behind head on master.

Files with missing lines Patch % Lines
prowler/providers/aws/services/iam/iam_service.py 80.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5437      +/-   ##
==========================================
+ Coverage   89.21%   89.34%   +0.12%     
==========================================
  Files        1044     1054      +10     
  Lines       32225    32686     +461     
==========================================
+ Hits        28750    29203     +453     
- Misses       3475     3483       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sergargar sergargar changed the title feat(iam): add new check iam_cloudshell_admin_policy_not_attached feat(iam): add new check iam_policy_cloudshell_admin_not_attached Oct 17, 2024
"SubServiceName": "",
"ResourceIdTemplate": "arn:aws:iam::{account-id}:{resource-type}/{resource-id}",
"Severity": "medium",
"ResourceType": "AwsIamRole, AwsIamUser, AwsIamGroup",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"ResourceType": "AwsIamRole, AwsIamUser, AwsIamGroup",
"ResourceType": "AwsIamPolicy",

def _list_entities_for_policy(self, policy_arn):
logger.info("IAM - List Entities Role For Policy...")
try:
entities = []
Copy link
Member

Choose a reason for hiding this comment

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

Please, make entities a dictionary with keys as User, Group, Role with a list for each entity.

Copy link
Member

Choose a reason for hiding this comment

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

So we can show in the status extended the type of entities too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider/aws Issues/PRs related with the AWS provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants