-
Notifications
You must be signed in to change notification settings - Fork 53
NETOBSERV-2471: TLS usage tracking #815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Skipping CI for Draft Pull Request. |
|
@jotak: This pull request references NETOBSERV-2471 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the spike to target the "4.21.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
9797fe9 to
abc2fd7
Compare
|
@jotak: This pull request references NETOBSERV-2471 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the spike to target the "4.21.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@jotak: This pull request references NETOBSERV-2471 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the spike to target the "4.21.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@jotak: This pull request references NETOBSERV-2471 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the spike to target the "4.21.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@jotak: This pull request references NETOBSERV-2471 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the spike to target the "4.21.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
bpf/flows.c
Outdated
| if (enable_dns_tracking) { | ||
| dns_errno = track_dns_packet(skb, &pkt); | ||
| } | ||
| track_tls_version(skb, &pkt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think its better if we have feature config for tracker like we do with all other features ? instead of enabling it by default ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I'll do that (although I would like to have it enabled by default if it doesn't show visible impact on perfs)
bpf/flows.c
Outdated
| if (pkt->ssl_version < aggregate_flow->ssl_version) { | ||
| aggregate_flow->ssl_version = pkt->ssl_version; | ||
| } | ||
| aggregate_flow->misc_flags |= MISC_FLAGS_SSL_MISMATCH; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it better to have mismatch counter instead of flag ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the flag allows us to correlate precisely with a particular flow, and report that up to the UI
bpf/tls_tracker.h
Outdated
|
|
||
| // Extract TLS info | ||
| static inline void track_tls_version(struct __sk_buff *skb, pkt_info *pkt) { | ||
| if (pkt->id->transport_protocol == IPPROTO_TCP) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do u think this work for STCP protocol too ?, not sure what is the story for DTLS ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't digged into other protocols.. might be something to do if someone asks for it, but I believe TCP covers most of the expectations
bpf/tls_tracker.h
Outdated
| struct tcphdr *tcp = (struct tcphdr *)pkt->l4_hdr; | ||
| if (!tcp || ((void *)tcp + sizeof(*tcp) > data_end)) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the verifier needs the above check given how late we call this tracker all headers should have been sane already ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I had a verifier error without those checks
bpf/tls_tracker.h
Outdated
| }; | ||
|
|
||
| // Extract TLS info | ||
| static inline void track_tls_version(struct __sk_buff *skb, pkt_info *pkt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be good idea to add return code and track failure at the caller since there many conditions check in this function and if things doesn't work it will be hard to debug.
might be good adding BPF_PRINTK() on failing checks ?
bpf/tls_tracker.h
Outdated
|
|
||
| switch (rec.content_type) { | ||
| case CONTENT_TYPE_HANDSHAKE: { | ||
| pkt->ssl_version = ((u16)rec.major) << 8 | rec.minor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why setting it here if u really want handshake ssl version ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a fallback for the case where handshake header couldn't be read ... But I'm going to change that, actually perhaps we don't want the client-hello version at all, it doesn't tell what's actually going to be used
bpf/tls_tracker.h
Outdated
| case CONTENT_TYPE_ALERT: | ||
| case CONTENT_TYPE_APP_DATA: | ||
| pkt->ssl_version = ((u16)rec.major) << 8 | rec.minor; | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do u think adding SSL record type to the follow will be adding value to end user ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean adding it to the flow, like, as a bitfield? hmm why not ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!!, I left some comments/suggestions, nothing major small enhancements . Also pls share some screenshots for this new feature
bpf/tls_tracker.h
Outdated
| return; | ||
| } | ||
|
|
||
| switch (rec.content_type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic assume there is always tls record after tcp header this is not safe assumption we could have dns header here or any other header ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, I should harden that a bit more; I've found unexpected TLSVersion during my tests probably because of that.
|
New images: These will expire after two weeks. To deploy this build, run from the operator repo, assuming the operator is running: USER=netobserv VERSION=16db482 make set-agent-image |
- Start implementing TLS, by reading the TLS header when present - Extract SSL version (not done yet for the handshake message) - Report the TLS version in output records
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@jotak: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
| tls->version = bpf_ntohs(version); | ||
| // Stop reading here | ||
| return TLSTRACKER_MATCHED; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something else that would be nice to pull out of the extensions is the key share. This would tell users if the server is using classical or hybrid key exchange algorithms, which is useful for finding out which applications are PQC-ready (e.g., looking for X25519 + Kyber768).
We might need to do something like:
if (ext_hdr.type == 0x002b) {
// Supported Versions: single version expected
u16 version;
if (bpf_skb_load_bytes(skb, offset + ext_offset, &version, sizeof(version)) < 0) {
return TLSTRACKER_UNKNOWN;
}
tls->version = bpf_ntohs(version);
}
else if (ext_hdr.type == 0x0033) {
// Key Share Extension (TLS 1.3)
// The Server Hello Key Share contains:
// Group (2 bytes) + Key Exchange Length (2 bytes) + Key Exchange Data
u16 selected_group;
if (bpf_skb_load_bytes(skb, offset + ext_offset, &selected_group, sizeof(selected_group)) < 0) {
// not sure what would be best to return here?
return KEYSHARE_UNKNOWN;
}
tls->key_share_group = bpf_ntohs(selected_group);
}The tls_info would need to be updated to relay that information though.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, definitely, if that's useful to figure out PQC-readiness, it's something that we want here
I'll add it, thanks for the hint!
Dependencies