Skip to content

api: add tcpAuthorization and udpAuthorization to SecurityPolicy - #10664

Open
zhaohuabing wants to merge 7 commits into
envoyproxy:mainfrom
zhaohuabing:api/tcp-udp-authorization
Open

zhaohuabing wants to merge 7 commits into
envoyproxy:mainfrom
zhaohuabing:api/tcp-udp-authorization

Conversation

@zhaohuabing

@zhaohuabing zhaohuabing commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Adds tcpAuthorization and udpAuthorization to SecurityPolicy, so TCP and UDP traffic each get their own authorization rules instead of sharing the HTTP authorization field. This is the API only; the implementation follows in a separate PR.

Today one authorization field covers HTTP, TCP and UDP. On a Gateway-level policy the same rules land on every listener, so there's no way to give TCP or UDP listeners rules that differ from the HTTP ones, and the field exposes JWT, headers, methods and CEL, none of which mean anything for a TCP connection or a UDP datagram. Splitting it per protocol makes the intent of each policy clear and limits each field to what its protocol can actually match on.

TCP and UDP get separate types even though both only take clientCIDRs today. Envoy can match a lot more on TCP connections (SNI, client certs, CEL), and keeping the types apart lets TCP grow without those fields leaking into UDP.

Using authorization for TCP and UDP is deprecated but keeps working until the matching new field is set. Dropping it right away would quietly remove existing Gateway-level CIDR rules from TCP and UDP listeners on upgrade.

This also gives #7825 a place to land later. A Gateway-level tcpAuthorization could apply to HTTP listeners as a connection-level check on the peer IP, for example only accepting connections from Cloudflare's ranges. Route-level authorization would keep checking the real client IP from XFF or proxy protocol. Keeping that check on Gateway targets avoids the per-route problem that got sourceCIDRs reverted in #8471.

Part of #10359

@netlify

netlify Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cerulean-figolla-1f9435 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 338c80b
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6b1268db4c2ce5678d59fec8
😎 Deploy Preview https://deploy-preview-10664--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the area/api API-related issues label Nov 19, 2026
@zhaohuabing
zhaohuabing marked this pull request as ready for review November 19, 2026 07:43
@zhaohuabing
zhaohuabing requested a review from a team as a code owner November 19, 2026 07:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-12-04T07:17:03.126044Z
We couldn’t complete this review. Comment @codex review to try again.
338c80b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c73bda7907

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/v1alpha1/securitypolicy_types.go Resolved
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.87%. Comparing base (0b677fb) to head (338c80b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10664      +/-   ##
==========================================
+ Coverage   82.85%   82.87%   +0.02%     
==========================================
  Files         278      278              
  Lines       44695    44695              
==========================================
+ Hits        37032    37041       +9     
+ Misses       7662     7653       -9     
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zhaohuabing
zhaohuabing requested a review from arkodg November 19, 2026 07:53

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e2affbcd6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/v1alpha1/securitypolicy_types.go Outdated
Comment on lines +55 to +56
// +kubebuilder:validation:XValidation:rule="!has(self.tcpAuthorization) || ((!has(self.targetRef) || !(self.targetRef.kind in ['HTTPRoute', 'GRPCRoute'])) && (!has(self.targetRefs) || !self.targetRefs.exists(ref, ref.kind in ['HTTPRoute', 'GRPCRoute'])) && (!has(self.targetSelectors) || !self.targetSelectors.exists(sel, sel.kind in ['HTTPRoute', 'GRPCRoute'])))", message="tcpAuthorization cannot be used with HTTPRoute or GRPCRoute targets"
// +kubebuilder:validation:XValidation:rule="!has(self.udpAuthorization) || ((!has(self.targetRef) || !(self.targetRef.kind in ['HTTPRoute', 'GRPCRoute'])) && (!has(self.targetRefs) || !self.targetRefs.exists(ref, ref.kind in ['HTTPRoute', 'GRPCRoute'])) && (!has(self.targetSelectors) || !self.targetSelectors.exists(sel, sel.kind in ['HTTPRoute', 'GRPCRoute'])))", message="udpAuthorization cannot be used with HTTPRoute or GRPCRoute targets"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject unsupported route kinds in L4 authorization selectors

When targetSelectors is used, these rules only reject HTTPRoute and GRPCRoute. Unlike targetRef and targetRefs, selectors have no general kind allowlist, and the translator includes TLSRoute in the route candidates resolved by ProcessSecurityPolicies. A TLSRoute selector with either new L4 authorization field therefore passes admission and reaches policy processing even though TLSRoute is not a supported SecurityPolicy target; apply the supported-kind allowlist to selectors too.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ignored for incompatible routes instead of rejecting them.

We could add warning status in the implementation PR.

@zhaohuabing zhaohuabing added this to the v1.11.0-rc.1 Release milestone Nov 20, 2026
@zhaohuabing
zhaohuabing force-pushed the api/tcp-udp-authorization branch from 0efcab1 to aae963b Compare November 20, 2026 05:00
@zhaohuabing
zhaohuabing requested a review from guydc November 21, 2026 04:39
@zhaohuabing
zhaohuabing force-pushed the api/tcp-udp-authorization branch from aae963b to 21034a3 Compare November 21, 2026 04:43
@zhaohuabing

Copy link
Copy Markdown
Member Author

/retest

@zhaohuabing
zhaohuabing force-pushed the api/tcp-udp-authorization branch 8 times, most recently from 9470336 to d5c472a Compare November 30, 2026 04:50
@zhaohuabing
zhaohuabing force-pushed the api/tcp-udp-authorization branch from d5c472a to 0aa8e4c Compare December 1, 2026 04:59
@zhaohuabing
zhaohuabing force-pushed the api/tcp-udp-authorization branch 3 times, most recently from a482aca to 834d65a Compare December 4, 2026 05:12
Adds separate authorization fields for TCP and UDP traffic so each listener
type has its own rules instead of sharing the HTTP authorization field. TCP
and UDP get their own types because Envoy can match on more for TCP (SNI,
client certs, CEL), and the two will diverge.

Using authorization for TCP and UDP is now deprecated but keeps working until
the new fields are set. The implementation follows in a separate PR.

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
Spells out in the SecurityPolicy docs that using authorization for TCPRoute
and UDPRoute targets is deprecated and will be removed in a future release,
and that it keeps applying until the new fields are set.

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
Marks the new fields as not implemented so they stay out of the API docs
until the translator supports them.

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
A policy that targets both TCPRoutes and UDPRoutes can now set both fields;
each one is ignored for the other route kind, the same way Gateway targets
work. Only HTTPRoute and GRPCRoute targets are still rejected.

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
Drops the target-kind CEL rules so tcpAuthorization and udpAuthorization can
sit on any SecurityPolicy target. Each one only applies to its own listeners
and routes and is ignored elsewhere, the same way Gateway targets work.

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
The l4 name was left over from an earlier design. One file per protocol
matches how the rest of the API is laid out and lets the two types grow apart.

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
The split into separate files left the UDP types behind in the TCP file,
so the package failed to build. Remove the leftover copies.

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
@zhaohuabing
zhaohuabing force-pushed the api/tcp-udp-authorization branch from 834d65a to 338c80b Compare December 4, 2026 07:16

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API-related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant