Skip to content

feat: allow acl to be delegated#99

Open
paibok wants to merge 8 commits intocrowdsecurity:mainfrom
paibok:dev/argar/v2
Open

feat: allow acl to be delegated#99
paibok wants to merge 8 commits intocrowdsecurity:mainfrom
paibok:dev/argar/v2

Conversation

@paibok
Copy link
Copy Markdown

@paibok paibok commented Mar 31, 2026

Summary

  • Adds support for delegated ACL management: Allows the bouncer to update RuleGroup without requiring full IAM wafv2:UpdateWebACL permissions on the global WebACL managing CloudFront distributions.
  • Decouples Security Operations: Enables a clear separation between infrastructure management (WebACL structure) and security automation (IP blocking).
  • Reduces IAM Blast Radius: The bouncer now only requires permissions to update specific RuleGroup resources, adhering to the principle of least privilege.
  • Backward Compatible: This is an opt-in feature; the bouncer maintains its default behavior of direct WebACL management if not configured otherwise.
  • Related to Crowdsec AWS WAF bouncer to manage an existing RuleGroup

Changes

  • Updated: pkg/cfg/config.go
    • Added delegate_acl_management (boolean) to the configuration structure.
  • New: pkg/waf/waf.go
    • Implements the conditional logic to sync decisions to a RuleGroup.
    • Bypasses the requirement to create, modify and delete the WebACL object itself.
    • Bypasses the requirement to create/delete the RuleGroup.
    • Implemented a function to unassign Rules from the RuleGroup, ensuring that associated IPSets can be cleaned up.

Note: Users must manually create the "RuleGroup" object itself and assign it in their WebACL before enabling this mode, as the bouncer will no longer have permissions to alter the WebACL structure.

Copy link
Copy Markdown
Member

@blotus blotus left a comment

Choose a reason for hiding this comment

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

Thanks for the PR !

It looks good overall, I just have a few comments/requests.

Comment thread pkg/waf/waf.go Outdated
LockToken: aws.String(token),
Id: aws.String(id),
Rules: []wafv2types.Rule{},
VisibilityConfig: &wafv2types.VisibilityConfig{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This overwrites whatever the visibility config was for the rule group. You should use the values that were already set in the RG instead (you can get the values from the object returned by w.GetRuleGroup that is called just before this function.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Comment thread pkg/waf/waf.go Outdated
}

err = w.CreateRuleGroup(ctx, w.config.RuleGroupName)
if !w.config.DelegateAclManagement {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should probably check the if the rule group specified in the config exists when in delegated mode, so that a clean error can be returned immediately in case of misconfiguration

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Comment thread pkg/waf/waf.go
return fmt.Errorf("failed to cleanup: %w", err)
}

w.aclsInfo, w.setsInfos, w.ruleGroupsInfos, err = w.ListResources(ctx)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the goal is to limit the IAM permissions required, I think we could go a step further and also remove the read calls for the webacl when in delegated mode ? This would also make web_acl_name optional in this mode.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Comment thread pkg/waf/waf.go Outdated
@@ -429,9 +448,16 @@

w.Logger.Debugf("Deleting RuleGroup %s", w.config.RuleGroupName)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: the debug log should be different when delegate is true

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Comment thread pkg/cfg/config.go Outdated
CloudWatchMetricName string `yaml:"cloudwatch_metric_name"`
SampleRequests bool `yaml:"sample_requests"`
CleanOnStart bool `yaml:"remove_sets_on_start"`
DelegateAclManagement bool `yaml:"delegate_acl_management"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure about delegate_acl_management: we don't really delegate anything ? Maybe use_existing_rule_group or something a bit more descriptive ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

@paibok paibok force-pushed the dev/argar/v2 branch 5 times, most recently from 282ce24 to 4d5818c Compare April 7, 2026 12:08
@paibok
Copy link
Copy Markdown
Author

paibok commented Apr 7, 2026

Hi @blotus, thanks for reviewing my PR and for the feedback. I've integrated most of your suggestions and just pushed the fixes. Let me know what you think! :)

@paibok paibok requested a review from blotus April 14, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants