mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-02 03:05:02 +03:00
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:
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/xtls/xray-core/transport/internet/hysteria/congestion/bbr"
|
||||
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/logger"
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/xray"
|
||||
)
|
||||
|
||||
// Server is an in-process native Go TUIC v5 server terminating QUIC
|
||||
@@ -1089,6 +1090,12 @@ func loadCertificate(certInput, keyInput string) (tls.Certificate, error) {
|
||||
if strings.Contains(certInput, "-----BEGIN CERTIFICATE-----") {
|
||||
return tls.X509KeyPair([]byte(certInput), []byte(keyInput))
|
||||
}
|
||||
// A pushed inbound names these paths, and both are read whole.
|
||||
for _, path := range []string{certInput, keyInput} {
|
||||
if err := xray.CheckCertFile(path); err != nil {
|
||||
return tls.Certificate{}, err
|
||||
}
|
||||
}
|
||||
return tls.LoadX509KeyPair(certInput, keyInput)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user