fix(xray): bound what the in-process config loader is asked to expand

The panel runs xray-core's conf.Build() in its own process on inbounds
and on outbounds that come from pushes and subscriptions. Some values
make it allocate or loop without bound (an XHTTP sessionIDLength, udphop
port lists, any number of finalmask entries, each xmc one costing an RSA
key), and certificate paths are read whole whatever they name.

Refuse those before any build: sessionIDLength above 1024, more than one
port range's worth of udphop ports per stream, more than 16 masks per
stream, more than 64 xmc masks per outbound subscription, and certificate
or key files that are not regular files of at most 1 MiB. Inbound saves,
the TUIC readers and the certificate-pin helper apply the file rule too;
the pin helper also stops looking at paths that name files on a node.
This commit is contained in:
MHSanaei
2026-10-31 08:43:30 +00:00
parent db20e491e6
commit 61ee202750
12 changed files with 390 additions and 2 deletions
+7
View File
@@ -2687,6 +2687,9 @@ func (s *ServerService) GetCertHash(certFile string, certContent string) ([]stri
if !ok {
return nil, common.NewError("certificate file is not referenced by any inbound or panel setting")
}
if err := xray.CheckCertFile(known); err != nil {
return nil, err
}
b, err := os.ReadFile(known)
if err != nil {
return nil, err
@@ -2760,6 +2763,10 @@ func (s *ServerService) knownCertFiles() []string {
}
if inbounds, err := s.inboundService.GetAllInbounds(); err == nil {
for _, inbound := range inbounds {
// A node row's path names a file on the node's host, not on this one.
if inbound.NodeID != nil {
continue
}
files = collectCertFiles(inbound.StreamSettings, files)
}
}