You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/proposals/nap-waf.md
+85-17Lines changed: 85 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,15 @@
5
5
6
6
## Summary
7
7
8
-
This proposal describes the integration of NGINX App Protect (NAP) WAF v5 into NGINX Gateway Fabric (NGF) to provide comprehensive WAF protection at Gateway and Route levels while working within NAP v5's architectural constraints of multi-container deployment and pre-compiled policy requirements. The design uses Gateway API inherited policy attachment to provide flexible, hierarchical WAF protection.
8
+
This proposal describes the integration of NGINX App Protect (NAP) WAF v5 into NGINX Gateway Fabric (NGF) to provide comprehensive WAF protection at Gateway and Route levels while working within NAP v5's architectural constraints of multi-container deployment and pre-compiled policy requirements. The design uses Gateway API inherited policy attachment to provide flexible, hierarchical WAF protection with GitOps-friendly static policy references through automatic polling and change detection.
9
9
10
10
## Goals
11
11
12
12
- Extend NginxProxy resource to enable NAP WAF for GatewayClass/Gateway with multi-container orchestration
13
13
- Design WafPolicy custom resource using inherited policy attachment for hierarchical WAF configuration
14
14
- Define deployment workflows that accommodate NAP v5's external policy compilation requirements
15
15
- Provide secure and automated policy distribution mechanisms from external sources
16
+
- Support GitOps workflows with static policy file references and automatic change detection
16
17
- Deliver enterprise-grade WAF capabilities through Kubernetes-native APIs with intuitive policy inheritance
17
18
- Maintain alignment with NGF's existing security and operational patterns
18
19
- Support configurable security logging for WAF events and policy violations
@@ -41,6 +42,14 @@ NGINX App Protect WAF v5 imposes specific architectural requirements that fundam
41
42
42
43
This proposal provides the best possible Kubernetes-native experience while respecting NAP v5 constraints, abstracting complexity from end users where possible while maintaining operational flexibility for enterprise environments. The design uses Gateway API's inherited policy attachment pattern to provide intuitive hierarchical security with the ability to override policies at more specific levels.
43
44
45
+
### GitOps Integration
46
+
47
+
A key design principle is seamless GitOps workflow support through automatic change detection:
48
+
49
+
-**Automatic Polling**: When polling is enabled, NGF periodically checks for policy changes using checksum validation
50
+
-**Efficient Updates**: Only downloads policy bundles when content actually changes
51
+
-**CI/CD Friendly**: Teams can update policies without modifying Kubernetes resources
52
+
44
53
### Policy Attachment Strategy
45
54
46
55
The design uses **inherited policy attachment** following Gateway API best practices:
@@ -132,6 +141,7 @@ graph TB
132
141
NGFPod -->|Watches Resources| NginxProxy
133
142
NGFPod -->|Watches Resources| GatewayWafPolicy
134
143
NGFPod -->|Watches Resources| RouteWafPolicy
144
+
NGFPod -->|Periodic Polling<br/>Checksum Validation| Store
135
145
NGFPod -->|Fetches Policy<br/>Native Cloud Auth| Store
136
146
NGFServiceAccount -.->|Cloud Provider<br/>Authentication| Store
Note1[📝 Note: Gateway-level WafPolicy provides inherited protection<br/>Route-level WafPolicy can override for specific routes]
183
-
Note2[📝 Note: Secret only required for fallback authentication<br/>Native cloud auth uses NGF Service Account annotations]
184
-
class Note1,Note2 note
185
190
```
186
191
187
192
This architecture demonstrates the hierarchical policy attachment system where Gateway-level WafPolicies provide default protection that can be overridden by Route-level policies for granular control:
188
193
189
-
**External Policy Management (Blue):** Security teams develop WAF policies using NAP v5 JSON schema, compile them using NAP v5 compiler tools, and publish the compiled policy bundles to accessible storage locations (S3, HTTP servers, or MinIO).
194
+
**External Policy Management (Blue):** Security teams develop WAF policies using NAP v5 JSON schema, compile them using NAP v5 compiler tools, and publish the compiled policy bundles to accessible storage locations (S3, HTTP servers, MinIO etc).
190
195
191
196
**Control Plane (Purple):** The NGF Pod in the `nginx-gateway` namespace acts as the centralized control plane, watching for NginxProxy and WafPolicy resources across application namespaces, fetching compiled policies from external storage using appropriate authentication, and distributing policy configurations to NGINX Pods via secure gRPC connections.
192
197
@@ -200,6 +205,8 @@ This architecture demonstrates the hierarchical policy attachment system where G
200
205
201
206
**Policy Inheritance:** Gateway-level WafPolicies automatically protect all routes attached to the Gateway. Route-level WafPolicies can override Gateway policies with more specific protection. This design supports both broad default protection and granular security controls while maintaining operational simplicity.
The architecture demonstrates separation of concerns: external policy compilation and storage, centralized policy distribution with inheritance hierarchy, and distributed policy enforcement, while maintaining security through ephemeral storage and immutable infrastructure principles.
204
211
205
212
### Network Access Requirements
@@ -232,6 +239,9 @@ Example air-gapped configuration:
@@ -243,7 +253,7 @@ Given NAP v5 constraints, users must follow this workflow:
243
253
3. **Compilation**: Use NAP v5 compiler tools to create policy and logging profile bundles
244
254
4. **Distribution**: Publish compiled policies and log profiles to accessible storage (S3, HTTP)
245
255
5. **Configuration**: Create WafPolicy CR with targetRefs referencing Gateway or Routes and configuring security logging
246
-
6. **Automatic Application**: NGF fetches and applies policies when WafPolicy is created or updated, with automatic inheritance
256
+
6. **Automatic Application**: NGF fetches and applies policies when WafPolicy is created or updated, with automatic inheritance. Policies can also be updated by publishing new content to the same configured file path; when polling is enabled, NGF automatically detects and applies changes.
247
257
248
258
**Note**: Policy enforcement mode and behavior are defined within the compiled NAP policy itself. Security logging profiles can be either built-in names or custom compiled bundles.
- Only downloads policy bundles when content changes
287
+
- New policies applied immediately upon detection
288
+
269
289
### Security Logging Configuration
270
290
271
291
The securityLogs section supports multiple logging configurations, each generating an `app_protect_security_log` directive:
@@ -284,6 +304,7 @@ The securityLogs section supports multiple logging configurations, each generati
284
304
- Reference compiled logging profile bundles from remote sources
285
305
- Same fetch and validation mechanisms as policy bundles
286
306
- Support for checksums and retry policies
307
+
- Automatic polling for log profile updates
287
308
288
309
**Destination Types:**
289
310
@@ -347,10 +368,11 @@ The design supports hierarchical policy application with clear precedence rules:
347
368
348
369
The integration leverages NGF's existing architecture:
349
370
350
-
-**Single NGF Pod**: Centralized control plane in `nginx-gateway` namespace manages all WAF operations
371
+
-**Single NGF Deployment**: Centralized control plane in `nginx-gateway` namespace manages all WAF operations and policy polling
351
372
-**Per-Gateway Deployment**: Each Gateway with WAF enabled gets a dedicated multi-container NGINX Pod
352
373
-**Selective WAF Enablement**: Only Gateways configured with WAF-enabled NginxProxy resources deploy NAP v5 containers
353
374
-**Centralized Policy Management**: NGF controllers fetch policies and distribute them to appropriate NGINX Pods via the existing Agent gRPC connection
375
+
-**Automatic Change Detection**: NGF polling engine can detect policy changes and trigger updates across affected Gateways
354
376
355
377
## API, Customer Driven Interfaces, and User Experience
356
378
@@ -414,6 +436,14 @@ spec:
414
436
# Note: Policy content validation handled by NAP v5 components
415
437
# We will support signature verification in the future
416
438
439
+
# Polling configuration for automatic change detection
440
+
polling:
441
+
enabled: true
442
+
interval: "5m"# Check every 5 minutes
443
+
# Optional: explicit checksum location
444
+
# If not specified, defaults to <fileLocation>.sha256
**Approach**: Have NGINX containers fetch policies directly using njs
827
869
**Rejected Reason**: Creates distributed system complexity, inconsistent state issues, and violates NGF's centralized control plane pattern
828
870
871
+
### Alternative 7: Manual Policy Updates Only
872
+
873
+
**Approach**: Require users to manually update WafPolicy resources for each policy change
874
+
**Rejected Reason**: Breaks GitOps workflows and creates operational overhead; teams want to update policies without modifying Kubernetes resources
875
+
876
+
### Alternative 8: Webhook-Only Updates
877
+
878
+
**Approach**: Use only webhook notifications for policy updates, no polling
879
+
**Rejected Reason**: Creates dependency on reliable webhook delivery; polling provides fallback mechanism and works in environments where webhooks are not feasible
880
+
829
881
## Future Enhancements
830
882
831
883
- **Policy signature verification**: Cryptographic validation of policy bundle authenticity using public key infrastructure
0 commit comments