REALITY client: `spiderX` that net/url cannot parse panics with nil pointer dereference at config load

Open Beginner friendly
#7,555 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
backend, testing

Research direction

Read infra/conf/transport_security.go around lines 221–222, where REALITYConfig.Build parses spiderX and calls Query, and inspect nearby config validation and tests. Reproduce with the supplied client config using xray run -test -c cfg.json; add coverage for malformed URL values such as /%zz. Done means config loading reports an invalid spiderX error without panicking.

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).

infra/conf/transport_security.go:221-222 runs u, _ := url.Parse(c.SpiderX) and then u.Query(). When url.Parse fails, u is nil and u.Query() dereferences it. A value that starts with / (so it passes the c.SpiderX[0] != '/' check) but holds a bad percent escape, such as /%zz, is enough. Other values that fail the same way: //[::1, /#%zz.

Reproduction Method

Save the client config below as cfg.json.

xray run -test -c cfg.json

Expected result: a config error (for example invalid "spiderX": /%zz), no panic. Same for xray run. Note that the value usually comes from a panel that copies it into client configs, so a single bad value in a panel takes down every client that loads it.

Client config


{
  "log": {
    "loglevel": "warning"
  },
  "outbounds": [
    {
      "protocol": "vless",
      "settings": {
        "vnext": [
          {
            "address": "192.0.2.1",
            "port": 443,
            "users": [
              {
                "id": "00000000-0000-4000-8000-000000000000",
                "encryption": "none"
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "raw",
        "security": "reality",
        "realitySettings": {
          "serverName": "example.com",
          "fingerprint": "chrome",
          "publicKey": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
          "shortId": "",
          "spiderX": "/%zz"
        }
      }
    }
  ]
}

Server config

Not needed: the client config panics on its own.

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:../cfg/spider.json Format:json}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x1312181]

goroutine 1 [running]:
net/url.(*URL).Query(...)
net/url/url.go:1165
github.com/xtls/xray-core/infra/conf.(*REALITYConfig).Build(0x304b2b8ddb00)
github.com/xtls/xray-core/infra/conf/transport_security.go:222 +0x10c1
github.com/xtls/xray-core/infra/conf.(*StreamConfig).Build(0x304b2b9226e0)
github.com/xtls/xray-core/infra/conf/transport_internet.go:124 +0x785
github.com/xtls/xray-core/infra/conf.(*OutboundDetourConfig).Build(0x304b2b8ff860)
github.com/xtls/xray-core/infra/conf/xray.go:372 +0x7b0
github.com/xtls/xray-core/infra/conf.(*Config).Build(0x304b2b922580)
github.com/xtls/xray-core/infra/conf/xray.go:749 +0x1f25
github.com/xtls/xray-core/infra/conf/serial.BuildConfig({0x304b2ba02210?, 0x23b9e38?, 0x304b2b8ffb50?})
github.com/xtls/xray-core/infra/conf/serial/builder.go:66 +0x2a
github.com/xtls/xray-core/core.LoadConfig({0x1417b55, 0x4}, {0x23372e8?, 0x304b2b67f020?})
github.com/xtls/xray-core/core/config.go:150 +0x573
main.startXray()
github.com/xtls/xray-core/main/run.go:225 +0x15c
main.executeRun(0x25b6c50?, {0x304b2b6ac070?, 0x25b6c88?, 0x80000025b6c88?})
github.com/xtls/xray-core/main/run.go:83 +0x130
github.com/xtls/xray-core/main/commands/base.Execute()
github.com/xtls/xray-core/main/commands/base/execute.go:65 +0x708
main.main()
github.com/xtls/xray-core/main/main.go:22 +0x1b2
exit=2

Server log

Not applicable.

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.