Browse Source

fix #1428

Tor listeners should never see an STS cap.

Add an undocumented 'hide-sts' key for listeners that hides the STS cap.
This can be used if the listener is secured at layer 3 or 4 (VPNs,
E2E mixnets). It will be necessary to add the relevant IPs to `secure-nets`.
tags/v2.5.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
7bdbb01238
4 changed files with 13 additions and 0 deletions
  1. 2
    0
      irc/client.go
  2. 8
    0
      irc/config.go
  3. 2
    0
      irc/handlers.go
  4. 1
    0
      irc/utils/proxy.go

+ 2
- 0
irc/client.go View File

159
 	proxiedIP   net.IP
159
 	proxiedIP   net.IP
160
 	rawHostname string
160
 	rawHostname string
161
 	isTor       bool
161
 	isTor       bool
162
+	hideSTS     bool
162
 
163
 
163
 	fakelag              Fakelag
164
 	fakelag              Fakelag
164
 	deferredFakelagCount int
165
 	deferredFakelagCount int
376
 		realIP:     realIP,
377
 		realIP:     realIP,
377
 		proxiedIP:  proxiedIP,
378
 		proxiedIP:  proxiedIP,
378
 		isTor:      wConn.Config.Tor,
379
 		isTor:      wConn.Config.Tor,
380
+		hideSTS:    wConn.Config.Tor || wConn.Config.HideSTS,
379
 	}
381
 	}
380
 	client.sessions = []*Session{session}
382
 	client.sessions = []*Session{session}
381
 
383
 

+ 8
- 0
irc/config.go View File

59
 	Tor       bool
59
 	Tor       bool
60
 	STSOnly   bool `yaml:"sts-only"`
60
 	STSOnly   bool `yaml:"sts-only"`
61
 	WebSocket bool
61
 	WebSocket bool
62
+	HideSTS   bool `yaml:"hide-sts"`
62
 }
63
 }
63
 
64
 
64
 type PersistentStatus uint
65
 type PersistentStatus uint
532
 		SecureNetDefs            []string                        `yaml:"secure-nets"`
533
 		SecureNetDefs            []string                        `yaml:"secure-nets"`
533
 		secureNets               []net.IPNet
534
 		secureNets               []net.IPNet
534
 		supportedCaps            *caps.Set
535
 		supportedCaps            *caps.Set
536
+		supportedCapsWithoutSTS  *caps.Set
535
 		capValues                caps.Values
537
 		capValues                caps.Values
536
 		Casemapping              Casemapping
538
 		Casemapping              Casemapping
537
 		EnforceUtf8              bool         `yaml:"enforce-utf8"`
539
 		EnforceUtf8              bool         `yaml:"enforce-utf8"`
834
 		}
836
 		}
835
 		lconf.RequireProxy = block.TLS.Proxy || block.Proxy
837
 		lconf.RequireProxy = block.TLS.Proxy || block.Proxy
836
 		lconf.WebSocket = block.WebSocket
838
 		lconf.WebSocket = block.WebSocket
839
+		lconf.HideSTS = block.HideSTS
837
 		conf.Server.trueListeners[addr] = lconf
840
 		conf.Server.trueListeners[addr] = lconf
838
 	}
841
 	}
839
 	return nil
842
 	return nil
1371
 		return nil, fmt.Errorf("failed to prepare listeners: %v", err)
1374
 		return nil, fmt.Errorf("failed to prepare listeners: %v", err)
1372
 	}
1375
 	}
1373
 
1376
 
1377
+	// #1428: Tor listeners should never see STS
1378
+	config.Server.supportedCapsWithoutSTS = caps.NewSet()
1379
+	config.Server.supportedCapsWithoutSTS.Union(config.Server.supportedCaps)
1380
+	config.Server.supportedCapsWithoutSTS.Disable(caps.STS)
1381
+
1374
 	return config, nil
1382
 	return config, nil
1375
 }
1383
 }
1376
 
1384
 

+ 2
- 0
irc/handlers.go View File

442
 	supportedCaps := config.Server.supportedCaps
442
 	supportedCaps := config.Server.supportedCaps
443
 	if client.isSTSOnly {
443
 	if client.isSTSOnly {
444
 		supportedCaps = stsOnlyCaps
444
 		supportedCaps = stsOnlyCaps
445
+	} else if rb.session.hideSTS {
446
+		supportedCaps = config.Server.supportedCapsWithoutSTS
445
 	}
447
 	}
446
 
448
 
447
 	badCaps := false
449
 	badCaps := false

+ 1
- 0
irc/utils/proxy.go View File

54
 	Tor       bool
54
 	Tor       bool
55
 	STSOnly   bool
55
 	STSOnly   bool
56
 	WebSocket bool
56
 	WebSocket bool
57
+	HideSTS   bool
57
 }
58
 }
58
 
59
 
59
 // read a PROXY header (either v1 or v2), ensuring we don't read anything beyond
60
 // read a PROXY header (either v1 or v2), ensuring we don't read anything beyond

Loading…
Cancel
Save