All notable changes to this project will be documented in this file.
- Add support for python 3.14
- Remove support for python 3.9
- Truncate metric arguments to 4000 characters
- Solve low-severity warnings for better readability
- Add support for repo_name in config
- Add support for python 3.13
- Add RequestCertificate to wildcard whitelist @undergroundwires (#308)
- Remove support for python 3.8
- Added 2 new filter functions:
setandsorted
- Bumped pycfmodel to use pydantic v2
- Add PR template @w0rmr1d3r (#279)
- Fix logo in pypi @ignaciobolonio (#274)
- Update .readthedocs.yaml @jsoucheiron (#275)
- Bump actions/setup-python from 4 to 5 (#270)
- Bump cryptography from 42.0.3 to 42.0.4 (#272)
- Migrate to pyproject.toml @jsoucheiron (#269)
- Add dependabot config @w0rmr1d3r (#257)
- Fix
KMSKeyWildcardPrincipalRuleto work without a KMS policy - Fix release drafter template to show PR titles
- Bumped minimum
pycfmodelversion to0.22.0
- Update invalid_role_inline_policy_fn_if.json
- Improve logging for the exception when applying rule filters
- Add release drafter
- Fixes #260
- Fix docs generation
- New rules:
PublicELBCheckerRule,StackNameMatchesRegexRule, andStorageEncryptedRule - New regex:
REGEX_ALPHANUMERICAL_OR_HYPHENto check if stack name only consists of alphanumerical characters and hyphens. - Config has a few extra methods that should make handling Filters easier
Configincludes a metrics logger, and it is called to register when a filter is used
- Update dependency constraints with
pydash, to be able to support newer versions and fix security issues - Fix typo in base_rule actions #237
- (internal) Updating PyPi release workflow
- Fixes docs formatting with #235
- Fixes
GenericResourcePartialWildcardPrincipalRuleandGenericCrossAccountTrustRulemessage, since sometimes it was bad-formatted in markdown.
- Default logging level from INFO to WARNING #230
GenericResourceWildcardPrincipalRule(thereforeGenericResourcePartialWildcardPrincipalRuleandGenericResourceFullWildcardPrincipalRuleas well) now ignoresAWS::KMS::ReplicaKey. It as the same use case as aAWS::KMS::Key.
- Update
GenericWildcardPrincipalRule,FullWildcardPrincipalRule,GenericResourceWildcardPrincipalRuleandGenericResourceFullWildcardPrincipalRulemessage, since sometimes it was bad-formatted in markdown.
- Refactored the
KMSKeyWildcardPrincipalRulerule
- Update
GenericWildcardPrincipalRule,PartialWildcardPrincipalRuleandGenericResourcePartialWildcardPrincipalRulemessage - Update docs
- Fix
GenericWildcardPrincipalRulethat could add a false-positive - Fix
GenericWildcardPrincipalRulethat wasn't handling canonical IDs - Fix
REGEX_PARTIAL_WILDCARD_PRINCIPALto correctly handle canonical IDs and account IDs - Fix unit tests
- New regex
REGEX_CONTAINS_WILDCARDto check for any wildcard
GenericResourceWildcardPolicyRulenow usesREGEX_CONTAINS_WILDCARDinstead ofREGEX_HAS_STAR_OR_STAR_AFTER_COLON.- Bump dev dependency
mototo==3.1.9.
GenericCrossAccountTrustRulecan now scan IAM Roles correctly asCrossAccountTrustRuledoes
- New rule:
RDSSecurityGroupIngressOpenToWorldRule
- Bumped minimum
pycfmodelversion to0.20.0
- CFRipper is now compatible with Python3.10
- CFRipper is now able to detect new types of wildcard usage.
- Default config will now detect lambda resource wildcards as through IAM overpowered roles.
- Bump dev dependency
mototo allow>=3.0.0.
- Pin
clickto at least version8.0.0. - Update
blackto22.3.0, and runmake formatwith this new version ofblack.
EBSVolumeHasSSERulecan now understandencrypted_statusif modelled as abool.- Add support to
EC2SecurityGroupOpenToWorldRulefor use cases where ports are not defined in the CloudFormation template. By default, this means all ports are included.
- Updated
EBSVolumeHasSSERuleto iterate only overAWS::EC2::Volumeresources. - Update
RuleConfigdocumentation.
- Bump
pycfmodelto0.18.0.
- Added
resource_typesto failures.
- Created
GenericResourceWildcardPrincipalRuleto be an abstract for wildcard principals for Generic resources. - Created
GenericResourcePartialWildcardPrincipalRuleandGenericResourceFullWildcardPrincipalRuleto evaluate Generic resources.
- Rollback
GenericWildcardPrincipalRuleas it was in1.5.2.
- Updates
GenericWildcardPrincipalRuleto understand theGenericResource.
- Stopped using
_statement_as_list()when retrieving statements in favor ofstatement_as_list().
- Updates
WildcardResourceRulefor a better use with theGenericResource.
- Stopped using
_statement_as_list()when retrieving statements in several rules in favor ofstatement_as_list().
- Created
GenericResourceWildcardPolicyRulein order to check for WildcardPolicy issues in generic resources. - Added documentation regarding the deprecation of
S3BucketPolicyWildcardActionRule,SNSTopicPolicyWildcardActionRuleandSQSQueuePolicyWildcardActionRule. - Covering cases for already mapped models in rules inherited from
GenericWildcardPolicyRulewith the newGenericResourceWildcardPolicyRule.
- Created
GenericCrossAccountTrustRulein order to check for CrossAccount issues for generic resources. - Added documentation regarding the deprecation of
S3CrossAccountTrustRule,KMSKeyCrossAccountTrustRule,ElasticsearchDomainCrossAccountTrustRuleandOpenSearchDomainCrossAccountTrustRule. - Covering cases for already mapped models in rules inherited from
CrossAccountCheckingRulewith the newGenericCrossAccountTrustRule.
- Bump
pycfmodelto0.17.0
- Stopped using
_statement_as_list()when retrieving statements inCrossAccountCheckingRulein favor ofstatement_as_list().
- Fix how
make install-devworks, it will install dependencies frommake installfirst.
- Bump dev dependency
motofrom1.3.13to1.3.14.
- Bump
pycfmodelto0.16.3
- Fix CI, updated tests to work with
pycfmodellatest version which includes the use of theGeneric.
- Bump and fixed required dependency
pycfmodelto be at least0.16.2. - Bump several dependencies:
boto3to1.21.2botocoreto1.24.2cfn-flipto1.3.0pydanticto1.9.0python-dateutilto2.8.2pyyamlto6.0s3transferto0.5.1typing-extensionsto4.1.1urllib3to1.26.8
- Fix CI, force
pycfmodelto use version0.13.0.
- Stop logging when conditions are ignored in
CrossAccountCheckingRule,KMSKeyWildcardPrincipalRule,S3BucketPolicyPrincipalRule,SQSQueuePolicyPublicRuleandGenericWildcardPrincipalRule.
- Fixes
CrossAccountCheckingRulewhen checking resources withoutPROPERTY_WITH_POLICYDOCUMENT.
- Add
ElasticsearchDomainCrossAccountTrustRuleandOpenSearchDomainCrossAccountTrustRule - Bump
pycfmodelto0.13.0
- Bump
pycfmodelto0.11.1
- The
WildcardResourceRulewould fail if it received a policy document that was a string. It was expecting all policy documents to be a dictionary. Some AWS services allow for string policies though (e.g.AWS::Logs::ResourcePolicy). The rule has been updated to handle string policies by attempting to convert it to a dictionary.
- The rules
EC2SecurityGroupOpenToWorldRuleandEC2SecurityGroupIngressOpenToWorldRulewere by default allowing ports 80 and 443. This has now been migrated to use a filter object, that can be optionally applied. See the README for further details. This means if the filter is not applied, Security Groups open to the world on ports 80 and 443 will start failing in CFRipper.
- Add a fix to the
KMSKeyEnabledKeyRotationrule to be able to detect theEnableKeyRotationproperty properly.
- Add a fix to the
PartialWildcardPrincipalrule to be able to detect policies where whole account access is specified via just the account ID. - For example, if the Principal was defined as
Principal: AWS: 123456789012as opposed toPrincipal: AWS: arn:aws:iam::123456789012:root.
- Add
S3ObjectVersioningrule - Update
pycfmodelto0.11.0- This includes model support for S3 Buckets. Rules against these resources have been updated (alongside tests).
- Update valid AWS Account IDs that might be included as principals on policies.
- This list now covers ELB Logs, CloudTrail Logs, Redshift Audit, and ElastiCache backups.
WildCardResourceRuleis now triggered by resources that only limit by service (ex:arn:aws:s3:::*)
- Add
S3LifecycleConfiguratonrule
- Add
KMSKeyEnabledKeyRotationrule - Bump
pycfmodelto0.10.4
- Add
S3BucketPublicReadAclRulerule
- Add EKS permissions that accept wildcard resource only
- Add
stack_idto log output when failing to convert a YML template to JSON. - Various minor test improvements
- Added CLI args for aws account id and aws principals
- Fix an issue in
S3BucketPublicReadAclAndListStatementRulewhere it could crash if the model was unresolved - Center logo (thanks @lpmi-13)
- Run tests in python 3.9
- Downgrade logging severity from exception to warning when there is no stack in AWS
- Handle AWS throttling errors when listing exports for a given account and region
- If we get a throttling error, we actually sleep for some time before retrying (before we were sleeping for 0 seconds)
- Decrease logging level when loading external filters
- Decrease logging level on known AWS errors such as AccessDenied when listing exports and throttling errors on getting a template from AWS CloudFormation.
Filterinclude the set of rules in which it is applied.RuleConfigonly containsrule_modeandrisk_valuenow.- Removes old whitelisting methods in favour of Filters
- Rename
RuleMode.WHITELISTEDtoRuleMode.ALLOWED, and allwhitelistword in strings. - Add debug flag to
Filterclass.
- Implements
pluggyhttps://github.com/pytest-dev/pluggy to enable dynamic rule loading. - Add support to load filters from external files
- All rules now support filter contexts!
- Update
WildcardResourceRuleto allow for certain resources to be excluded.
GenericWildcardPrincipalRuleto ignore account IDs where full or partial wildcard is required in the Principal. These accounts should be AWS Service Accounts defined in the config.- Fix CLI flag
--rules-config-file
- Update
ResourceSpecificRuleto allow for certain resources to be excluded. In particular, thePrivilegeEscalationRulewill now no longer be invoked forS3BucketPolicyresources. - Add rules config for Kinesis Data Firehose IPs that can be applied
- Add more X-Ray permissions that accept wildcard resource only
- CLI handles case of empty template by returning appropriate exception message
- CLI now returns exit code 2 for scenarios where CFRipper finds a template violating any of the rules
- Rule config files using filters must now use
ingress_objand notingress.
- Rules using IP Address Ranges now export both
ingress_objandingress_ipfilter fields. - Add support to load an external rules configuration file
- Classes inheriting from
ResourceSpecificRulenow must allow anextrafield in theresource_invokefunction
- Improved context data for
BaseDangerousPolicyActionsand classes inheriting from it
CrossAccountCheckingRuledid not check properly for calculated mock fields.
- Add SNS actions that only allow wildcards
- Upgraded to pycfmodel 0.8.1 (this will improve policy action detection)
- Refactored a few classes to use improvements from new base classes and pycfmodel
PrivilegeEscalationRulenow detects issues in all policies
- New Rules:
SNSTopicDangerousPolicyActionsRuleandSQSDangerousPolicyActionsRule - New abstract base rule: BaseDangerousPolicyActions
- Various typo fixes
- Added more actions that only allow wildcard as resource
- Require pycfmodel 0.7.2
- Bump pip-tools dev requirement to 5.3.1
- Add
WildcardResourceRulerule
- Add
regex:ignorecasefilter function
- Add support for this new S3 url format:
https://bucket.s3.aws-region.amazonaws.com/path1/path2
rule_modeis nowBLOCKINGfor all Rules.
CrossAccountCheckingRulecallingadd_failure_to_resultonUNDEFINED_was missing context variable.
EC2SecurityGroupIngressOpenToWorldRule,EC2SecurityGroupMissingEgressRuleandEC2SecurityGroupOpenToWorldRuleinclude support for filters.EC2SecurityGroupIngressOpenToWorldRuleandEC2SecurityGroupOpenToWorldRulesupport adding errors for port ranges.
Config.DEFAULT_ALLOWED_WORLD_OPEN_PORTStype changes toList[int]- Rename
SecurityGroupIngressOpenToWorldRuletoEC2SecurityGroupIngressOpenToWorldRule - Rename
SecurityGroupMissingEgressRuletoEC2SecurityGroupMissingEgressRule - Rename
SecurityGroupOpenToWorldRuletoEC2SecurityGroupOpenToWorldRule - Improved message for users when failing the
SecurityGroupOpenToWorldRuleandSecurityGroupIngressOpenToWorldRulerules. - Improved documentation for the above rules, including styling fixes which have now been tested.
- Improved message for users when failing the
SecurityGroupOpenToWorldRuleandSecurityGroupIngressOpenToWorldRulerules. - Improved documentation for the above rules, including styling fixes which have now been tested.
- Add
existsandemptyfunctions to filters - Add
param_resolverto filters to evaluate just necessary params
- Add protection when a filter is evaluated to catch the exception and continue
CrossAccountCheckingRule,CrossAccountTrustRule,S3CrossAccountTrustRuleandKMSKeyCrossAccountTrustRuleinclude support for filters.
CrossAccountCheckingRulenow includes the invoke method. Statements of PolicyDocument are now analysed usingRESOURCE_TYPEandPROPERTY_WITH_POLICYDOCUMENTclass variables.
- Add new
RuleConfig, allows to overwrite the default behaviour of the rule changing rule mode and risk value. - Add new
Filter, allows setting custom rule configuration to matching coincidences. - New RuleModes supported:
RuleMode.DISABLEDandRuleMode.WHITELISTED.
- Class variables
Rule.RULE_MODEandRule.RISK_VALUEshould be changed to use propertiesrule_modeandrisk_value. These properties take in consideration the custom config that might be applied. - If rule mode is
DISABLEDorWHITELISTED; methodsadd_failure_to_resultandadd_warning_to_resultwill have no effect. add_failure_to_resultandadd_warning_to_resultaccepts a new optional parameter namedcontext. This variable is going to be evaluated by filters defined in the custom config.
SecurityGroupOpenToWorldRuleandSecurityGroupIngressOpenToWorldRuleare now more accurately scoped to block potentially public CIDR ranges. It it utilising the latestpycfmodelrelease (0.7.0).
- Generate DEFAULT_RULES and BASE_CLASSES using code instead of hardcoding
- Whitelist did not work if it didn't have the
Ruleprefix
- Sufix
KMSKeyWildcardPrincipalandSecurityGroupIngressOpenToWorldwithRule - Sufix whitelist constant
FullWildcardPrincipalandPartialWildcardPrincipalwithRule
- Update dependencies
- Rule processor now accepts an extras parameter that will be forwarded to the rules
- Main gets extra information from the event and forwards it to the rule formatter
- Completely changed base
Ruleabstract class signature and adapted rule classes to match it:- Init now only takes a
Config invokemethod now accepts an optional extra Dictinvokemethod returns aResultinstead ofNoneadd_failurehas been renamed toadd_failure_to_result. It now takes a result instead of a reason (that now it's inferred)add_warninghas been renamed toadd_warning_to_result. It now has the same signature thanadd_failure_to_result
- Init now only takes a
- Rule Invoke extras parameter has been added to allow changing the rule behaviour depending on state besides the cfmodel itself:
- Stack naming rules
- Stack tags
- User restrictions
- ...
- Regular expressions had an unescaped '.' before 'amazonaws.com', so it might match more hosts than expected.
CloudFormationAuthenticationRulenow inMONITORmode and new test addedIAMRoleWildcardActionOnPolicyRulecombines three previous unused rules inIAMManagedPolicyWildcardActionRule,IAMRoleWildcardActionOnPermissionsPolicyRule, andIAMRoleWildcardActionOnTrustPolicyRuleIAMRoleWildcardActionOnPolicyRulenow inDEBUGmodeS3BucketPolicyWildcardActionRulehas now been changed to be an instantiation of the new generic ruleGenericWildcardPolicyRule. It is set inDEBUGmodeS3BucketPolicyWildcardActionRulehas had updated regex filter to make it more aligned with both further rules to do with wildcards in actions, and the existingSQSQueuePolicyWildcardActionRuleSQSQueuePolicyWildcardActionRulehas now been changed to be an instantiation of the new generic ruleGenericWildcardPolicyRule. It is set inDEBUGmodeSecurityGroupMissingEgressRulenow inDEBUGmode and a new test addedSNSTopicPolicyWildcardActionRulehas beed added. It is an instantiation of the new generic ruleGenericWildcardPolicyRule. It is set inDEBUGmode
- The following rules are no longer available:
IAMRoleWildcardActionOnPermissionsPolicyRuleIAMRoleWildcardActionOnTrustPolicyRuleIAMManagedPolicyWildcardActionRule
- The following rules have been moved:
S3BucketPolicyWildcardActionRuleSQSQueuePolicyWildcardActionRule
- Documentation updated to show the risk of rules and possible fixes where available, as well as a large set of updates to the content. The macros for parsing the documentation have also been updated.
- Fix for
CrossAccountCheckingRulewas adding errors when the principal was sts when it shouldn't.
get_account_id_from_sts_arnandget_aws_service_from_arnin utils.
- Adds CLI to package
KMSKeyCrossAccountTrustRule
GenericWildcardPrincipalRule,PartialWildcardPrincipalRule,FullWildcardPrincipalRuleno longer check for wildcards in KMSKey principals.- Improved granularity of most rules
S3CrossAccountTrustRulenow accepts resource level exceptions- New documentation!
cfripper.rules.s3_bucked_policyrenamed tocfripper.rules.s3_bucket_policy(typo)
- Fix
get_templatewhen AWS doesn't return a dict.
HardcodedRDSPasswordRulenow reports two different messages when there is a missing echo or a readable password.
HardcodedRDSPasswordRulewas wrongly adding an error when a value is provided.
- Moved some files from model to rules, renamed rules to match pythonic style. Moved tons of classes around
- Fix a regression that caused
S3CrossAccountTrustRuleandCrossAccountTrustRulenot to alert whenever cross-account permissions are found within the allowed list of aws accounts. CrossAccountTrustRulewrongly say that AWS canonical ids and services were a cross-account relationship.
- Added
PrincipalCheckingRule, it has a property calledvalid_principals. It's a list with all allowed principals. This list can be customized using_get_whitelist_from_config(). - Added
AWS_ELASTICACHE_BACKUP_CANONICAL_IDSwhich contains the aws canonical ids used for backups.
CrossAccountTrustRuleoutputs warning log message if the AWS Account ID is not present in the config.HardcodedRDSPasswordRuleupdated to check for both RDS Clusters and RDS Instances, and reduce false positives on valid instances.CrossAccountTrustRule,GenericWildcardPrincipalRule,S3BucketPolicyPrincipalRule,S3BucketPolicyPrincipalRuleandS3CrossAccountTrustRulenow check the account against a list. The list is composed of AWS service accounts, configured AWS principals and the account id where the event came from.- Rename
AWS_ELB_ACCOUNT_IDStoAWS_ELB_LOGS_ACCOUNT_IDS
- New regexes and utility methods to get parts of arns
S3CrossAccountTrustRuleandS3BucketPolicyPrincipalRulewon't trigger if the principal comes from one of the AWS ELB service account ids
- New regex
REGEX_IS_STAR, matches only a*character.
GenericWildcardPrincipalRule,S3BucketPolicyPrincipalRule,S3CrossAccountTrustRule,SQSQueuePolicyPublicRuleandKMSKeyWildcardPrincipalnow trust the condition to reduce false positives.- Rules check the resource type using
isinstanceinstead of comparing type to a string if pycfmodel implements the resource. - Instance method
add_failurenow acceptsrisk_valueandrisk_modeas optional parameters. CrossAccountTrustRuleonly runs if config has definedself._config.aws_account_id.IAMRoleWildcardActionOnPermissionsPolicyRulenow usesREGEX_WILDCARD_POLICY_ACTION.
IAMRolesOverprivilegedRulenow usesREGEX_IS_STARfor finding statements instead ofREGEX_CONTAINS_STAR.