All notable changes to this project will be documented in this file.
- Add support for python 3.13
- Remove support for python 3.8
- Added 2 new filter functions:
set
andsorted
- 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
KMSKeyWildcardPrincipalRule
to work without a KMS policy - Fix release drafter template to show PR titles
- Bumped minimum
pycfmodel
version 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_HYPHEN
to check if stack name only consists of alphanumerical characters and hyphens. - Config has a few extra methods that should make handling Filters easier
Config
includes 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
GenericResourcePartialWildcardPrincipalRule
andGenericCrossAccountTrustRule
message, since sometimes it was bad-formatted in markdown.
- Default logging level from INFO to WARNING #230
GenericResourceWildcardPrincipalRule
(thereforeGenericResourcePartialWildcardPrincipalRule
andGenericResourceFullWildcardPrincipalRule
as well) now ignoresAWS::KMS::ReplicaKey
. It as the same use case as aAWS::KMS::Key
.
- Update
GenericWildcardPrincipalRule
,FullWildcardPrincipalRule
,GenericResourceWildcardPrincipalRule
andGenericResourceFullWildcardPrincipalRule
message, since sometimes it was bad-formatted in markdown.
- Refactored the
KMSKeyWildcardPrincipalRule
rule
- Update
GenericWildcardPrincipalRule
,PartialWildcardPrincipalRule
andGenericResourcePartialWildcardPrincipalRule
message - Update docs
- Fix
GenericWildcardPrincipalRule
that could add a false-positive - Fix
GenericWildcardPrincipalRule
that wasn't handling canonical IDs - Fix
REGEX_PARTIAL_WILDCARD_PRINCIPAL
to correctly handle canonical IDs and account IDs - Fix unit tests
- New regex
REGEX_CONTAINS_WILDCARD
to check for any wildcard
GenericResourceWildcardPolicyRule
now usesREGEX_CONTAINS_WILDCARD
instead ofREGEX_HAS_STAR_OR_STAR_AFTER_COLON
.- Bump dev dependency
moto
to==3.1.9
.
GenericCrossAccountTrustRule
can now scan IAM Roles correctly asCrossAccountTrustRule
does
- New rule:
RDSSecurityGroupIngressOpenToWorldRule
- Bumped minimum
pycfmodel
version 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
moto
to allow>=3.0.0
.
- Pin
click
to at least version8.0.0
. - Update
black
to22.3.0
, and runmake format
with this new version ofblack
.
EBSVolumeHasSSERule
can now understandencrypted_status
if modelled as abool
.- Add support to
EC2SecurityGroupOpenToWorldRule
for use cases where ports are not defined in the CloudFormation template. By default, this means all ports are included.
- Updated
EBSVolumeHasSSERule
to iterate only overAWS::EC2::Volume
resources. - Update
RuleConfig
documentation.
- Bump
pycfmodel
to0.18.0
.
- Added
resource_types
to failures.
- Created
GenericResourceWildcardPrincipalRule
to be an abstract for wildcard principals for Generic resources. - Created
GenericResourcePartialWildcardPrincipalRule
andGenericResourceFullWildcardPrincipalRule
to evaluate Generic resources.
- Rollback
GenericWildcardPrincipalRule
as it was in1.5.2
.
- Updates
GenericWildcardPrincipalRule
to understand theGenericResource
.
- Stopped using
_statement_as_list()
when retrieving statements in favor ofstatement_as_list()
.
- Updates
WildcardResourceRule
for a better use with theGenericResource
.
- Stopped using
_statement_as_list()
when retrieving statements in several rules in favor ofstatement_as_list()
.
- Created
GenericResourceWildcardPolicyRule
in order to check for WildcardPolicy issues in generic resources. - Added documentation regarding the deprecation of
S3BucketPolicyWildcardActionRule
,SNSTopicPolicyWildcardActionRule
andSQSQueuePolicyWildcardActionRule
. - Covering cases for already mapped models in rules inherited from
GenericWildcardPolicyRule
with the newGenericResourceWildcardPolicyRule
.
- Created
GenericCrossAccountTrustRule
in order to check for CrossAccount issues for generic resources. - Added documentation regarding the deprecation of
S3CrossAccountTrustRule
,KMSKeyCrossAccountTrustRule
,ElasticsearchDomainCrossAccountTrustRule
andOpenSearchDomainCrossAccountTrustRule
. - Covering cases for already mapped models in rules inherited from
CrossAccountCheckingRule
with the newGenericCrossAccountTrustRule
.
- Bump
pycfmodel
to0.17.0
- Stopped using
_statement_as_list()
when retrieving statements inCrossAccountCheckingRule
in favor ofstatement_as_list()
.
- Fix how
make install-dev
works, it will install dependencies frommake install
first.
- Bump dev dependency
moto
from1.3.13
to1.3.14
.
- Bump
pycfmodel
to0.16.3
- Fix CI, updated tests to work with
pycfmodel
latest version which includes the use of theGeneric
.
- Bump and fixed required dependency
pycfmodel
to be at least0.16.2
. - Bump several dependencies:
boto3
to1.21.2
botocore
to1.24.2
cfn-flip
to1.3.0
pydantic
to1.9.0
python-dateutil
to2.8.2
pyyaml
to6.0
s3transfer
to0.5.1
typing-extensions
to4.1.1
urllib3
to1.26.8
- Fix CI, force
pycfmodel
to use version0.13.0
.
- Stop logging when conditions are ignored in
CrossAccountCheckingRule
,KMSKeyWildcardPrincipalRule
,S3BucketPolicyPrincipalRule
,SQSQueuePolicyPublicRule
andGenericWildcardPrincipalRule
.
- Fixes
CrossAccountCheckingRule
when checking resources withoutPROPERTY_WITH_POLICYDOCUMENT
.
- Add
ElasticsearchDomainCrossAccountTrustRule
andOpenSearchDomainCrossAccountTrustRule
- Bump
pycfmodel
to0.13.0
- Bump
pycfmodel
to0.11.1
- The
WildcardResourceRule
would 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
EC2SecurityGroupOpenToWorldRule
andEC2SecurityGroupIngressOpenToWorldRule
were 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
KMSKeyEnabledKeyRotation
rule to be able to detect theEnableKeyRotation
property properly.
- Add a fix to the
PartialWildcardPrincipal
rule 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: 123456789012
as opposed toPrincipal: AWS: arn:aws:iam::123456789012:root
.
- Add
S3ObjectVersioning
rule - Update
pycfmodel
to0.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.
WildCardResourceRule
is now triggered by resources that only limit by service (ex:arn:aws:s3:::*
)
- Add
S3LifecycleConfiguraton
rule
- Add
KMSKeyEnabledKeyRotation
rule - Bump
pycfmodel
to0.10.4
- Add
S3BucketPublicReadAclRule
rule
- Add EKS permissions that accept wildcard resource only
- Add
stack_id
to 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
S3BucketPublicReadAclAndListStatementRule
where 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.
Filter
include the set of rules in which it is applied.RuleConfig
only containsrule_mode
andrisk_value
now.- Removes old whitelisting methods in favour of Filters
- Rename
RuleMode.WHITELISTED
toRuleMode.ALLOWED
, and allwhitelist
word in strings. - Add debug flag to
Filter
class.
- Implements
pluggy
https://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
WildcardResourceRule
to allow for certain resources to be excluded.
GenericWildcardPrincipalRule
to 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
ResourceSpecificRule
to allow for certain resources to be excluded. In particular, thePrivilegeEscalationRule
will now no longer be invoked forS3BucketPolicy
resources. - 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_obj
and notingress
.
- Rules using IP Address Ranges now export both
ingress_obj
andingress_ip
filter fields. - Add support to load an external rules configuration file
- Classes inheriting from
ResourceSpecificRule
now must allow anextra
field in theresource_invoke
function
- Improved context data for
BaseDangerousPolicyActions
and classes inheriting from it
CrossAccountCheckingRule
did 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
PrivilegeEscalationRule
now detects issues in all policies
- New Rules:
SNSTopicDangerousPolicyActionsRule
andSQSDangerousPolicyActionsRule
- 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
WildcardResourceRule
rule
- Add
regex:ignorecase
filter function
- Add support for this new S3 url format:
https://bucket.s3.aws-region.amazonaws.com/path1/path2
rule_mode
is nowBLOCKING
for all Rules.
CrossAccountCheckingRule
callingadd_failure_to_result
onUNDEFINED_
was missing context variable.
EC2SecurityGroupIngressOpenToWorldRule
,EC2SecurityGroupMissingEgressRule
andEC2SecurityGroupOpenToWorldRule
include support for filters.EC2SecurityGroupIngressOpenToWorldRule
andEC2SecurityGroupOpenToWorldRule
support adding errors for port ranges.
Config.DEFAULT_ALLOWED_WORLD_OPEN_PORTS
type changes toList[int]
- Rename
SecurityGroupIngressOpenToWorldRule
toEC2SecurityGroupIngressOpenToWorldRule
- Rename
SecurityGroupMissingEgressRule
toEC2SecurityGroupMissingEgressRule
- Rename
SecurityGroupOpenToWorldRule
toEC2SecurityGroupOpenToWorldRule
- Improved message for users when failing the
SecurityGroupOpenToWorldRule
andSecurityGroupIngressOpenToWorldRule
rules. - Improved documentation for the above rules, including styling fixes which have now been tested.
- Improved message for users when failing the
SecurityGroupOpenToWorldRule
andSecurityGroupIngressOpenToWorldRule
rules. - Improved documentation for the above rules, including styling fixes which have now been tested.
- Add
exists
andempty
functions to filters - Add
param_resolver
to filters to evaluate just necessary params
- Add protection when a filter is evaluated to catch the exception and continue
CrossAccountCheckingRule
,CrossAccountTrustRule
,S3CrossAccountTrustRule
andKMSKeyCrossAccountTrustRule
include support for filters.
CrossAccountCheckingRule
now includes the invoke method. Statements of PolicyDocument are now analysed usingRESOURCE_TYPE
andPROPERTY_WITH_POLICYDOCUMENT
class 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.DISABLED
andRuleMode.WHITELISTED
.
- Class variables
Rule.RULE_MODE
andRule.RISK_VALUE
should be changed to use propertiesrule_mode
andrisk_value
. These properties take in consideration the custom config that might be applied. - If rule mode is
DISABLED
orWHITELISTED
; methodsadd_failure_to_result
andadd_warning_to_result
will have no effect. add_failure_to_result
andadd_warning_to_result
accepts a new optional parameter namedcontext
. This variable is going to be evaluated by filters defined in the custom config.
SecurityGroupOpenToWorldRule
andSecurityGroupIngressOpenToWorldRule
are now more accurately scoped to block potentially public CIDR ranges. It it utilising the latestpycfmodel
release (0.7.0).
- Generate DEFAULT_RULES and BASE_CLASSES using code instead of hardcoding
- Whitelist did not work if it didn't have the
Rule
prefix
- Sufix
KMSKeyWildcardPrincipal
andSecurityGroupIngressOpenToWorld
withRule
- Sufix whitelist constant
FullWildcardPrincipal
andPartialWildcardPrincipal
withRule
- 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
Rule
abstract class signature and adapted rule classes to match it:- Init now only takes a
Config
invoke
method now accepts an optional extra Dictinvoke
method returns aResult
instead ofNone
add_failure
has been renamed toadd_failure_to_result
. It now takes a result instead of a reason (that now it's inferred)add_warning
has 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.
CloudFormationAuthenticationRule
now inMONITOR
mode and new test addedIAMRoleWildcardActionOnPolicyRule
combines three previous unused rules inIAMManagedPolicyWildcardActionRule
,IAMRoleWildcardActionOnPermissionsPolicyRule
, andIAMRoleWildcardActionOnTrustPolicyRule
IAMRoleWildcardActionOnPolicyRule
now inDEBUG
modeS3BucketPolicyWildcardActionRule
has now been changed to be an instantiation of the new generic ruleGenericWildcardPolicyRule
. It is set inDEBUG
modeS3BucketPolicyWildcardActionRule
has had updated regex filter to make it more aligned with both further rules to do with wildcards in actions, and the existingSQSQueuePolicyWildcardActionRule
SQSQueuePolicyWildcardActionRule
has now been changed to be an instantiation of the new generic ruleGenericWildcardPolicyRule
. It is set inDEBUG
modeSecurityGroupMissingEgressRule
now inDEBUG
mode and a new test addedSNSTopicPolicyWildcardActionRule
has beed added. It is an instantiation of the new generic ruleGenericWildcardPolicyRule
. It is set inDEBUG
mode
- The following rules are no longer available:
IAMRoleWildcardActionOnPermissionsPolicyRule
IAMRoleWildcardActionOnTrustPolicyRule
IAMManagedPolicyWildcardActionRule
- The following rules have been moved:
S3BucketPolicyWildcardActionRule
SQSQueuePolicyWildcardActionRule
- 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
CrossAccountCheckingRule
was adding errors when the principal was sts when it shouldn't.
get_account_id_from_sts_arn
andget_aws_service_from_arn
in utils.
- Adds CLI to package
KMSKeyCrossAccountTrustRule
GenericWildcardPrincipalRule
,PartialWildcardPrincipalRule
,FullWildcardPrincipalRule
no longer check for wildcards in KMSKey principals.- Improved granularity of most rules
S3CrossAccountTrustRule
now accepts resource level exceptions- New documentation!
cfripper.rules.s3_bucked_policy
renamed tocfripper.rules.s3_bucket_policy
(typo)
- Fix
get_template
when AWS doesn't return a dict.
HardcodedRDSPasswordRule
now reports two different messages when there is a missing echo or a readable password.
HardcodedRDSPasswordRule
was 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
S3CrossAccountTrustRule
andCrossAccountTrustRule
not to alert whenever cross-account permissions are found within the allowed list of aws accounts. CrossAccountTrustRule
wrongly 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_IDS
which contains the aws canonical ids used for backups.
CrossAccountTrustRule
outputs warning log message if the AWS Account ID is not present in the config.HardcodedRDSPasswordRule
updated to check for both RDS Clusters and RDS Instances, and reduce false positives on valid instances.CrossAccountTrustRule
,GenericWildcardPrincipalRule
,S3BucketPolicyPrincipalRule
,S3BucketPolicyPrincipalRule
andS3CrossAccountTrustRule
now 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_IDS
toAWS_ELB_LOGS_ACCOUNT_IDS
- New regexes and utility methods to get parts of arns
S3CrossAccountTrustRule
andS3BucketPolicyPrincipalRule
won'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
,SQSQueuePolicyPublicRule
andKMSKeyWildcardPrincipal
now trust the condition to reduce false positives.- Rules check the resource type using
isinstance
instead of comparing type to a string if pycfmodel implements the resource. - Instance method
add_failure
now acceptsrisk_value
andrisk_mode
as optional parameters. CrossAccountTrustRule
only runs if config has definedself._config.aws_account_id
.IAMRoleWildcardActionOnPermissionsPolicyRule
now usesREGEX_WILDCARD_POLICY_ACTION
.
IAMRolesOverprivilegedRule
now usesREGEX_IS_STAR
for finding statements instead ofREGEX_CONTAINS_STAR
.