VLESS Vision: user `testseed` with zero entries panics in crypto/rand.Int at the first write; `-test` passes

Open
#7,560 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
networking

Research direction

Start with proxy/proxy.go:508-514, where testseed values are passed to crypto/rand.Int, and trace how the config builder validates those values. Check the existing tests for Vision padding and configuration validation. Done means invalid non-positive values produce a config error instead of a panic, with tests covering the reported case.

Written by the indexing model from the issue text.

Description

Integrity requirements

  • I read the issue template.
  • I confirm I read the documentation and did not pile up options.
  • Complete configs and logs are provided below.
  • I searched issues and found no similar ones.
  • Reproduced on the latest release.

Description

Version: Xray 26.11.9 (Xray, Penetrates Everything.) 676eaf6 (go1.27.3 linux/amd64), the v26.11.9 release Xray-linux-64.zip (sha256 b651f7e1d9966ee2c1b1ee1bf8b52c72771824d3065dce96bbc8bcc19ed95f82). The panic site is also unchanged on main at 919d0ae (2026-11-30).

proxy/proxy.go:508-514 passes testseed[1] and testseed[3] to rand.Int(rand.Reader, big.NewInt(...)), which panics for a value <= 0 (crypto/rand: argument to Int is <= 0). The conf builder accepts any four numbers, so "testseed": [0,0,0,0] passes -test and kills the process at the first Vision write. The argument is also used for int32(testseed[3]) conversions and the padding length, so huge values are unchecked as well (not tested here).

Reproduction Method

Save the client config below as cfg.json and the server config as server.json (both on 127.0.0.1).

# server: xray run -c server.json ; client: xray run -c client.json, then
curl -x socks5h://127.0.0.1:10808 http://127.0.0.1:20002/

Expected result: a config error for non-positive testseed entries; no panic.

(xray run -test on the client config prints Configuration OK, exit 0. The server uses a throwaway self-signed certificate; the client pins its leaf hash.)

Client config


{
  "log": {
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 10808,
      "protocol": "socks"
    }
  ],
  "outbounds": [
    {
      "protocol": "vless",
      "settings": {
        "vnext": [
          {
            "address": "127.0.0.1",
            "port": 20002,
            "users": [
              {
                "id": "c20965b7-c354-405b-a3ef-f886415c9181",
                "encryption": "none",
                "flow": "xtls-rprx-vision",
                "testseed": [
                  0,
                  0,
                  0,
                  0
                ]
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "raw",
        "security": "tls",
        "tlsSettings": {
          "serverName": "localhost",
          "alpn": [
            "http/1.1"
          ],
          "pinnedPeerCertSha256": "208773ca012415a909c508eeaab62107341e8dcb096c649bb3bb50540d1baf62"
        }
      }
    }
  ]
}

Server config


{
  "log": {
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 20002,
      "protocol": "vless",
      "settings": {
        "clients": [
          {
            "id": "c20965b7-c354-405b-a3ef-f886415c9181",
            "flow": "xtls-rprx-vision"
          }
        ],
        "decryption": "none"
      },
      "streamSettings": {
        "network": "raw",
        "security": "tls",
        "tlsSettings": {
          "certificates": [
            {
              "certificateFile": "/tmp/repro/lab/srv.crt",
              "keyFile": "/tmp/repro/lab/srv.key"
            }
          ]
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom"
    }
  ]
}

Client log

Full output of the panicking process (ends with the exit code):


Xray 26.11.9 (Xray, Penetrates Everything.) 676eaf6 (go1.27.3 linux/amd64)
A unified platform for anti-censorship.
[Info] infra/conf/serial: Reading config: &{Name:/tmp/repro/cfg/testseed-run.json Format:json}
[Warning] core: Xray 26.11.9 started
from tcp:127.0.0.1:57894 accepted tcp:127.0.0.1:20002
panic: crypto/rand: argument to Int is <= 0

goroutine 26 [running]:
crypto/rand.Int({0x24bff20?, 0x25f5aa0?}, 0x77361baa11f0?)
crypto/rand/util.go:73 +0x55e
github.com/xtls/xray-core/proxy.XtlsPadding(0x1401fc78a390, 0x0, 0x1401fc649b48, 0x60?, {0x24c9120, 0x1401fc6afc20}, {0x1401fc2bb4d0?, 0x49f380?, 0x1401fc78e0a8?})
github.com/xtls/xray-core/proxy/proxy.go:514 +0x255
github.com/xtls/xray-core/proxy.(*VisionWriter).WriteMultiBuffer(0x1401fc649b00, {0x1401fc382028, 0x1, 0x1})
github.com/xtls/xray-core/proxy/proxy.go:396 +0x6b9
github.com/xtls/xray-core/proxy/vless/outbound.(*Handler).Process.func4()
github.com/xtls/xray-core/proxy/vless/outbound/outbound.go:326 +0x662
github.com/xtls/xray-core/common/task.Run.func1(0x1401fc40c090?)
github.com/xtls/xray-core/common/task/task.go:28 +0x28
created by github.com/xtls/xray-core/common/task.Run in goroutine 24
github.com/xtls/xray-core/common/task/task.go:27 +0xe5
exit=2

Server log

Server started normally, no warnings (loglevel: warning).

Dominant language
Go
Stars
43.3k
Forks
6.2k
Avg merge
2d 11h
Merged PRs (30d)
55

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from XTLS/Xray-core

All issues in XTLS/Xray-core

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.