Skip to content

tls_inspector: tls client fingerprinting - #16628

Closed
rdegnan wants to merge 2 commits into
envoyproxy:mainfrom
rdegnan:tls-client-fingerprinting
Closed

rdegnan wants to merge 2 commits into
envoyproxy:mainfrom
rdegnan:tls-client-fingerprinting

Conversation

@rdegnan

@rdegnan rdegnan commented May 22, 2021

Copy link
Copy Markdown
Contributor

Commit Message: Implement TLS client fingerprinting
Additional Description: See #16622
Risk Level: low
Testing: unit tests
Docs Changes: Documented in proto
Release Notes:
Platform Specific Features:
Fixes #16622

@rdegnan
rdegnan requested review from asraa and ggreenway as code owners May 22, 2021 14:49
@repokitteh-read-only

Copy link
Copy Markdown

Hi @rdegnan, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #16628 was opened by rdegnan.

see: more, trace.

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
envoyproxy/api-shepherds assignee is @htuch
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #16628 was opened by rdegnan.

see: more, trace.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this PR would benefit from an explanation of what TLS client fingerprinting is. Presumably it's just a hash of some subset of fields in the TLS client hello. Which makes sense, I'm aware of some applications of this. I'd like to understand here the rationale behind choice of fields and what purpose this is intended to serve. This should be done in both the API and also more comments added across the code here.
/wait

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

e.g. what is grease?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I wasn't sure how much context this needed -- your description is accurate, as for the the rationale behind choice of fields and the choice of md5 as a hashing algorithm, this is specified by the JA3 standard, which allows the fingerprints to be shared/recorded in threat databases, etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

GREASE (Generate Random Extensions And Sustain Extensibility) is a mechanism Google uses to prevent extensibility failures in the TLS ecosystem. JA3 ignores these values completely to ensure that programs utilizing GREASE can still be identified with a single JA3 hash.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need to state a default for scalar types in proto3.

Is the reason to add an API field due to the CPU overhead of computing this if not needed?

@ggreenway ggreenway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will need a lot more testing around all the length checks when you're parsing out fields of the client hello (CBS_*).

ENVOY_LOG(trace, "tls:connectionFingerprint(), fingerprint: {}", fingerprint);

uint8_t buf[MD5_DIGEST_LENGTH];
MD5(reinterpret_cast<const uint8_t*>(fingerprint.data()), fingerprint.size(), buf);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why md5? As a cryptographic hash, it shouldn't really be used anymore; use sha256 instead. For a non-cryptographic hash, use something in source/common/common/hash.h that we already use.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

MD5 is specified by the JA3 standard, it's not cryptographic but the intent is to use a standard hashing algorithm so the fingerprint can be shared.


std::ostringstream md5;
md5 << std::hex << std::uppercase << std::setfill('0');
for (const auto &byte: buf) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Replace with something out of source/common/common/hex.h for this.

std::string upstream_transport_failure_reason_;
absl::optional<Upstream::ClusterInfoConstSharedPtr> upstream_cluster_info_;
absl::optional<uint64_t> connection_id_;
std::string connection_fingerprint_;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this use optional like the connection ID does, rather than returning an empty string if its's not set?

[](const StreamInfo::StreamInfo& stream_info) {
return stream_info.connectionID().value_or(0);
});
} else if (field_name == "CONNECTION_FINGERPRINT") {

@jpeach jpeach May 24, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe the field name should be more specific (e.g. "JA3_TLS_FINGERPRINT") in case there's ever a different kind of fingerprinting added?

@github-actions

github-actions Bot commented Jul 1, 2021

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions Bot added the stale stalebot believes this issue/PR has not been touched recently label Jul 1, 2021
@github-actions

github-actions Bot commented Jul 8, 2021

Copy link
Copy Markdown

This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions Bot closed this Jul 8, 2021
@boringuy

boringuy commented Jul 22, 2021 •

Copy link
Copy Markdown
Contributor

@rdegnan I see this PR was closed due to lack of activity. Would you be able to re-open it and get it going or if you don't mind, in a few weeks, I can probably spend sometime on this to get it going.

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

Labels

api stale stalebot believes this issue/PR has not been touched recently waiting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend TLS inspector to capture JA3 client fingerprint

5 participants