api: add CSRF origin validation to SecurityPolicy#8836
Open
albsga4 wants to merge 1 commit intoenvoyproxy:mainfrom
Open
api: add CSRF origin validation to SecurityPolicy#8836albsga4 wants to merge 1 commit intoenvoyproxy:mainfrom
albsga4 wants to merge 1 commit intoenvoyproxy:mainfrom
Conversation
✅ Deploy Preview for cerulean-figolla-1f9435 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8836 +/- ##
==========================================
+ Coverage 74.36% 74.40% +0.03%
==========================================
Files 246 247 +1
Lines 39292 39382 +90
==========================================
+ Hits 29221 29301 +80
- Misses 8041 8042 +1
- Partials 2030 2039 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f6609d8 to
eb1feaf
Compare
Add native CSRF protection to SecurityPolicy following the CORS pattern. The CSRF filter validates the Origin header on mutating requests (POST, PUT, DELETE, PATCH) against the destination and additional allowed origins. API: SecurityPolicy.csrf with additionalOrigins []StringMatch IR: CSRF struct in SecurityFeatures xDS: csrf.go implementing httpFilter interface (disabled at HCM 0%, enabled per-route 100%) Fixes envoyproxy#8835 Signed-off-by: asalvador <asalvador@newrelic.com>
eb1feaf to
d7ee907
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
api: addcsrffield toSecurityPolicyWhat this PR does / why we need it:
Envoy has a built-in
envoy.filters.http.csrffilter that validates theOriginheader against allowed origins on mutating requests (POST, PUT, DELETE, PATCH). Currently there's no way to configure this through Envoy Gateway withoutEnvoyPatchPolicy.This PR adds native CSRF support following the exact same pattern as CORS:
Implementation:
Follows the CORS pattern exactly:
SecurityPolicy.csrfwithadditionalOrigins []StringMatch(reuses existingStringMatchtype)CSRFstruct inSecurityFeatureswithAdditionalOrigins []*StringMatchbuildCSRF()usingirStringMatch()helper (same as CORS)csrf.goimplementinghttpFilterinterface:patchHCM: adds CSRF filter to listener disabled by default (0%)patchRoute: enables CSRF per-route viatyped_per_filter_config(100%)patchResources: no-opBehavior:
additionalOriginsOriginheader on mutating requests → 403Origin→ 403Changes:
api/v1alpha1/csrf_types.go(new) — CSRF API typeapi/v1alpha1/securitypolicy_types.go— addCSRF *CSRFfieldinternal/ir/xds.go— CSRF IR struct in SecurityFeaturesinternal/gatewayapi/securitypolicy.go—buildCSRF(), translation for route and gateway targets, TCP validationinternal/xds/translator/csrf.go(new) — httpFilter implementationsecuritypolicy-with-csrfsite/content/en/latest/tasks/security/csrf.mdWhich issue(s) this PR fixes:
Fixes #8835
Release Notes: Yes
/cc @arkodg