Skip to content
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

Support randomized with non-nil seed in UTLSIdToSpec #157

Merged
merged 1 commit into from
Feb 4, 2023

Conversation

RPRX
Copy link
Contributor

@RPRX RPRX commented Feb 4, 2023

@RPRX
Copy link
Contributor Author

RPRX commented Feb 4, 2023

In one of Xray-core's use cases, I want to generate a randomized Client Hello that supports TLSv1.3 and continually reuse it until the program exits. It's convenient to generate a randomized ClientHelloSpec and then check the TLSVersMax field, but using that ClientHelloSpec directly in many concurrent conns is not safe enough. Unfortunately, the actual Seed is unacquirable.

So with this change, I'm able to set the Seed field in advance and store it once a Client Hello that supports TLSv1.3 is generated:

func init() {
	randomized := utls.HelloRandomized
	for {
		randomized.Seed, _ = utls.NewPRNGSeed()
		clientHelloSpec, _ := utls.UTLSIdToSpec(randomized)
		if clientHelloSpec.TLSVersMax == utls.VersionTLS13 {
			PresetFingerprints["randomized"] = &randomized
			break
		}
	}
}

@gaukas
Copy link
Contributor

gaukas commented Feb 4, 2023

Looks interesting (and legit). We should merge this to provide maximized flexibility. Thanks!

Would you like to elaborate how does this change benefit circumvention tools like Xray? IMO it kinda defeats the purpose of mimicking, and makes it a fingerprint-able behavior. Unless there are some well-known popular tools with the same or similar behavior?

@gaukas gaukas merged commit a3b55c9 into refraction-networking:master Feb 4, 2023
@RPRX
Copy link
Contributor Author

RPRX commented Feb 5, 2023

Would you like to elaborate how does this change benefit circumvention tools like Xray? IMO it kinda defeats the purpose of mimicking, and makes it a fingerprint-able behavior. Unless there are some well-known popular tools with the same or similar behavior?

Actually, randomized itself is fingerprint-able already, and we should avoid using it unless we have to (e.g. in some cities in Iran).

  1. Sending different unusual Client Hellos is a very strange behavior, as normal applications will not behave like that.
  2. There are many preset weights in generateRandomizedSpec(), but most of them stopped changing since fd72b83, 2019.

if r.FlipWeightedCoin(0.7) {
if r.FlipWeightedCoin(0.4) {
p.CipherSuites = removeRandomCiphers(r, shuffledSuites, 0.4)
if r.FlipWeightedCoin(0.63) {
if r.FlipWeightedCoin(0.59) {
if r.FlipWeightedCoin(0.51) || p.TLSVersMax == VersionTLS13 {
if r.FlipWeightedCoin(0.9) {
if r.FlipWeightedCoin(0.71) || p.TLSVersMax == VersionTLS13 {
if r.FlipWeightedCoin(0.46) {
if r.FlipWeightedCoin(0.62) || p.TLSVersMax == VersionTLS13 {
if r.FlipWeightedCoin(0.74) {
if r.FlipWeightedCoin(0.46) {
if r.FlipWeightedCoin(0.75) {
if r.FlipWeightedCoin(0.77) {
if r.FlipWeightedCoin(0.25) {
if r.FlipWeightedCoin(0.33) {

After collecting enough amount of unusual Client Hellos, certainly the censors will find out that they are randomized in uTLS.
Especially, the preset weight 0.4 for p.TLSVersMax = VersionTLS13 is obviously unreasonable nowadays in 2023.

In my opinion, changing that weight to 1.0 is helpful for us to expose less preset weights, and certainly we will have a more secure connection and less RTT, and actually it's getting more and more reasonable, because it's very normal to support TLSv1.3 nowadays. Besides, both XTLS Vision and REALITY (a real-time Server Hello stealer + MitM, coming soon) require TLSv1.3.

By the way, these two problems will all be gone if we reuse the same Seed all the time. It's the most appropriate usage, probably.

@gaukas
Copy link
Contributor

gaukas commented Feb 5, 2023

Thanks for the detailed analysis and suggestions.

I agree that some designs included in uTLS have been outdated and needs a lot of rework. Since it is open-sourced, you are always welcome to submit PR if you'd like to!

RPRX added a commit to XTLS/Xray-core that referenced this pull request Feb 6, 2023
But we should aviod using it unless we have to, see
refraction-networking/utls#157 (comment)
RPRX added a commit to XTLS/Xray-core that referenced this pull request Feb 8, 2023
But we should avoid using it unless we have to, see
refraction-networking/utls#157 (comment)
mwhorse46 added a commit to mwhorse46/Xray-core that referenced this pull request Feb 19, 2023
But we should avoid using it unless we have to, see
refraction-networking/utls#157 (comment)
rampagekiller0725 added a commit to rampagekiller0725/wox that referenced this pull request Jun 29, 2023
But we should avoid using it unless we have to, see
refraction-networking/utls#157 (comment)
Autumn216 added a commit to Autumn216/wox that referenced this pull request Oct 31, 2023
But we should avoid using it unless we have to, see
refraction-networking/utls#157 (comment)
adotkhan pushed a commit to Psiphon-Labs/utls that referenced this pull request Dec 10, 2024
adotkhan pushed a commit to Psiphon-Labs/utls that referenced this pull request Dec 10, 2024
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.

2 participants