Skip to content

Add support for wildcard specifiers anywhere in SNI pattern#1698

Merged
jrajahalme merged 2 commits intomainfrom
pr/fristonio/add-server-name-proto-validation
Feb 11, 2026
Merged

Add support for wildcard specifiers anywhere in SNI pattern#1698
jrajahalme merged 2 commits intomainfrom
pr/fristonio/add-server-name-proto-validation

Conversation

@fristonio
Copy link
Member

See commit message for more details.

Extends: #1242
Fixes: cilium/cilium#43597

@squeed
Copy link

squeed commented Jan 13, 2026

So, @fristonio and I were chatting about this, and I wondered if we should convert to regex in the agent and send that to the proxy.

Pros:

  • No risk of divergent implementations
  • Easier changes in the future

Cons:

  • requires a new protobuf field for upgrade compat

I'm not sure what the general practice is for c/proxy here.

@squeed
Copy link

squeed commented Jan 13, 2026

Conclusion: because spinning a new proto type is annoying, we'll implement it as-is.

Copy link

@squeed squeed left a comment

Choose a reason for hiding this comment

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

great tests!

@fristonio fristonio force-pushed the pr/fristonio/add-server-name-proto-validation branch from d9c7a5e to 5620d48 Compare January 15, 2026 17:52
@fristonio fristonio force-pushed the pr/fristonio/add-server-name-proto-validation branch from 5620d48 to f80c75a Compare February 5, 2026 07:53
@fristonio fristonio requested a review from jrajahalme February 5, 2026 07:54
@fristonio fristonio force-pushed the pr/fristonio/add-server-name-proto-validation branch 2 times, most recently from 778dcb9 to 1f0b2ad Compare February 6, 2026 02:09
@fristonio fristonio requested a review from nezdolik February 6, 2026 02:12
@fristonio fristonio force-pushed the pr/fristonio/add-server-name-proto-validation branch 2 times, most recently from 8d4fb6d to c3ebac2 Compare February 10, 2026 21:25
@fristonio
Copy link
Member Author

PR updated with changes as discussed during today's sig-policy meeting.

A valid match pattern should:

  • Contain only valid DNS characters(-a-zA-Z0-9_) and the wildcard specifier(*)
  • Not have a trailing .
  • Not have an empty subdomain (multiple consecutive . are not allowed)
  • Not contain more than 2 consecutive wildcard specifiers(*)

Wildcard specifier behavior:

  • * matches any number of valid DNS characters within a subdomain boundary.
  • ** matches any non empty DNS pattern (across subdomain boundary).

With this change cilium-agent needs to normalize the SNI patterns to be conformant with the above match pattern syntax and aligned with DNS match pattern. This will include the below operations:

  • Drop trailing .
  • Reduce ^[*]{2,}[.] to **.
  • Reduce [*]{1,} to *

This commit adds support for specifying wildcard('*') anywhere in the
server names match pattern. This allow users to write more compressed
network policies.

With this change users can now write allowed server names as:

- `*.cilium.io` matching all first-level subdomains of `cilium.io`:
  - Matches: `www.cilium.io`, `blog.cilium.io`
  - Does NOT match: `cilium.io`, `foo.bar.cilium.io`, `kubernetes.io`

- `*cilium.io` matching `cilium.io` and any domain ending with the `cilium.io` suffix:
  - Matches: `cilium.io`, `sub-cilium.io`, `subcilium.io`
  - Does NOT match: `www.cilium.io`, `blog.cilium.io`

- `sub*.cilium.io` matching subdomains of `cilium.io` that start with the "sub" prefix:
  - Matches: `sub.cilium.io`, `subdomain.cilium.io`
  - Does NOT match: `www.cilium.io`, `blog-sub.cilium.io`, `blog.sub.cilium.io`, `cilium.io`

- `**.cilium.io` matching all subdomains of `cilium.io` at any depth:
  - Matches: `www.cilium.io`, `test.app.cilium.io`
  - Does NOT match: `cilium.io`

SNI match patterns are now implemented using regular expressions. The
required regex is derived and compiled once during xDS configuration
update.
If the match pattern doesn't contain any wildcard specifier the
implementation relies on explicit full string match as before.

Signed-off-by: Deepesh Pathak <deepesh.pathak@isovalent.com>
This commit adds regex pattern validation to the `server_names` field of
PortNetworkPolicyRule type. The validation pattern
(`^([-a-zA-Z0-9_*]+[.]?)+"$`) is in alignment with the supported match
pattern as defined for the corresponding k8s type in cilium/cilium.

Signed-off-by: Deepesh Pathak <deepesh.pathak@isovalent.com>
@fristonio fristonio force-pushed the pr/fristonio/add-server-name-proto-validation branch from c3ebac2 to 0e7e83f Compare February 10, 2026 22:53
@jrajahalme jrajahalme merged commit 38f2469 into main Feb 11, 2026
10 of 13 checks passed
@jrajahalme jrajahalme deleted the pr/fristonio/add-server-name-proto-validation branch February 11, 2026 17: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.

SNI ServerName wildcard doesn't match toFQDNs MatchPattern

4 participants