Enhance supported patterns to include ** matching multilevel of subdomains#28690
Enhance supported patterns to include ** matching multilevel of subdomains#28690pjablonski123 wants to merge 1 commit intocilium:mainfrom
Conversation
joestringer
left a comment
There was a problem hiding this comment.
I didn't review the code but I just wanted to reshare the concern from the issue which we need to convince ourselves is OK: #22081 (comment)
|
Thank you @joestringer for matching this PR with a previous considerations which should be included here. Regarding a subdomain hijacking this PR does not make it easier comparing to the *. (asterisk dot) notation. Typically hijacked subdomains are at the first subdomain level of the FQDN: [subdomain]. [domainname]. [tld]. Both following rules:
If it is required to block other-level subdomains then the current notation "*.example.com" can be used. FQDNs can be attacked in any case and a proper protection should be provided by e.g. auth codes. |
|
After security review with @ferozsalam , we concluded that this does slightly increase the risk of user clusters becoming compromised in cases where target domains are managed by a third party and particularly in cases where the third party delegates the responsibility for DNS subdomains across multiple administrators within that organization. It's difficult for someone writing a firewall rule to estimate that risk. That said, we also came to the conclusion that limiting the matching feature to a single level of subdomains is probably not the right way to mitigate the risk. We plan on coming up with some improved guidance for the feature in order to ensure users have the opportunity to be properly educated regarding the security impact of this feature. With that, I think that the next step is review and testing. I don't see any tests being proposed here, can you add some unit tests to validate the new regexes? Some of the corner cases might be things like proving that the |
|
CI also complained about unformatted code: You may consider using |
|
Commit 0aabef5 does not match "(?m)^Signed-off-by:". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
|
Added and run unit tests. |
In my statement, I wasn't referring to any particular revision of the code. I still think this is a change that warrants wider discussion and documentation (e.g. also in terms of security implications) in a structured document.
Isn't this still a breaking change if two or more asterisks were allowed previously and now it is rejected? Even if it was wrong and unsupported it might break users' existing CNPs which IMO warrants further discussion in terms of how this should be communicated to users. |
Documents are always welcome, but this can be delivered in a form of a separate blog or a doc entry. There are quite many features which are more complex and described in a concise form like here.
I did not see any single support ticket with Even the simplest from with |
I see you've added a section to the docs discussing some of the security implications. In addition, I think this PR also needs a dedicated release note entry other than the PR title in the PR description mentioning the user-facing implications of this change. See item 12 here in the contribution guide on how a good release note should look.
Just because there aren't any reported issues with
It's still a breaking change, no matter how "wrong" the users were to already using |
Agree, that's why I mentioned that it is not a definite proof. It is a probability.
OK, so then no matter what we do this enhancement will be a breaking change. To summarize what is required, I will add:
Please let me know if anything else is required. Thank you for a review! |
Sounds good to me. Ideally we'd also cover this feature in a cilium-cli connectivity test as a follow-up. |
@pjablonski123 did you have a chance yet to make these changes? |
This week was heavy with high priority tasks. I hope to finish it early next week. Unless there is a specific deadline over the weekend. |
|
Commit 6ec888c does not match "(?m)^Signed-off-by:". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
|
Commits 6ec888c, 9d3543f do not match "(?m)^Signed-off-by:". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
1 similar comment
|
Commits 6ec888c, 9d3543f do not match "(?m)^Signed-off-by:". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
|
/test |
|
@tklauser Added a release note and a word to the wordlist, extended a doc description + all previous changes. |
|
/test |
|
Removing review requests from non-required codeowners (such as e.g. wireguard) |
gentoo-root
left a comment
There was a problem hiding this comment.
Looks good to me, assuming that folks agreed on the semantics of "**xyz".
@pjablonski123 Thanks. The doc description LGTM but I don't see |
…mains.
pkg/fqdn: Adding ** matchpattern
The ** in matchpattern allows a short notation of multilevel subdomains
Instead of the rules with listed subdomains:
rules:
dns:
- matchPattern: '*.cluster.local'
- matchPattern: '*.*.cluster.local'
- matchPattern: '*.*.*.cluster.local'
- matchPattern: '*.*.*.*.cluster.local'
- matchPattern: '*.*.*.*.*.cluster.local'
- matchPattern: '*.*.*.*.*.*.cluster.local'
- matchPattern: '*.*.*.*.*.*.*.cluster.local'
- matchPattern: '*.*.*.*.*.*.*.*.cluster.local'
egress:
- toFQDNs:
- matchPattern: '*.cilium.io'
- matchPattern: '*.*.cilium.io'
- matchPattern: '*.*.*.cilium.io'
- matchPattern: '*.*.*.*.cilium.io'
- matchPattern: '*.*.*.*.*.cilium.io'
- matchPattern: '*.*.*.*.*.*.cilium.io'
- matchPattern: '*.*.*.*.*.*.*.cilium.io'
- matchPattern: '*.*.*.*.*.*.*.*.cilium.io'
the following policy can be used in a simpler form:
rules:
dns:
- matchPattern: '**.cluster.local'
egress:
- toFQDNs:
- matchPattern: '**.cilium.io'
Changelog:
Modified the code and added tests.
Updated language.rst.
Updated matchpattern.go.
Added and updated doc files.
Updated language.rst with a security note.
Double asterisk is allowed at the beginning of the domain only.
Signed-off-by: Piotr Jablonski <[email protected]>
```release-note
The ** in matchpattern allows a short notation of multilevel subdomains,
eg. **.cilium.io matches a.cilium.io, a.b.cilium.io, a.b.c.cilium.io, etc.
This feature can break current configuration if a double asterisk was used inside of FQDN, eg. cil**.io
Before this enhancement two or more directly adjacent asterisks meant the same - a single asterisk, eg. cil**.io == cil*.io
The correct usage of the asterisk before this enhancement should be a single presence between other characters, eg. c*m.io, *.cil*.io
With this enhancement the correct usage of the single asterisk does not change
A double asterisk must be at the beginning of the FQDN string only, eg. **.cilium.io
The single and double asterisk can be present in the same FQDN if they are separated by a dot directly or indirectly, eg. **.*lium.io, **.cili*.io
```
|
@tklauser an upgrade note added. Pls let me know if anything is missing. Thx! |
Thanks @pjablonski123! The upgrade note looks good to me. There seems to be a merge conflict. Could you please rebase the PR on latest Once the remaining reviewers approved, this should be good to go. |
|
This pull request has been automatically marked as stale because it |
|
This pull request has not seen any activity since it was marked stale. |
|
@tklauser is there a chance this might still land? |
|
Some concerns were voiced on the CFP issue, see #22081 (comment). I think these should be discussed and addressed first. |
|
@pjablonski123 are you still working on this item? If not, we would like to pick this up. cc: @vipul-21 |
Hi @tamilmani1989, I will reopen this and address the security concerns. |
|
@pjablonski123 Any update on this ? I can help if needed. |
|
This is now needed for k8s Cluster Network Policy, who's FQDN semantics require matching on multi-level subdomains. Unfortunately it seems like this PR has been effectively abandoned. Is there still a plan to reopen this PR, or should I clone it and start a new discussion in a new PR? |
Adding ** to match substrings as a prefix including subdomains.
Release note:
Signed-off-by: Piotr Jablonski [email protected]
Fixes: #22081