VLESS outbound: malformed `encryption` (mlkem768x25519plus.… with no key segment) panics with slice bounds out of range at config load

Open Beginner friendly
#7,554 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, security

Research direction

Read infra/conf/vless.go around the reported checks and slice operation in VLessOutboundConfig.Build; the issue provides two malformed encryption values that reproduce the panic. Start by running xray run -test -c cfg.json with the supplied config, then check existing VLESS outbound tests for a place to cover both cases. Done means both inputs return a config 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).

A VLESS outbound whose encryption starts with mlkem768x25519plus.<mode>.<0rtt|1rtt>. but has no 32/1184-byte key segment is accepted by the parser's first checks and then sliced past the end of the string (infra/conf/vless.go:342-352: segments shorter than 20 characters are counted as padding, and account.Encryption[padding:] is taken without checking that a key segment remains). The process panics while loading the config instead of reporting unsupported "encryption". Both mlkem768x25519plus.native.0rtt. (slice bounds out of range [1:0]) and mlkem768x25519plus.native.0rtt.abc ([4:3]) reproduce.

Reproduction Method

Save the client config below as cfg.json.

xray run -test -c cfg.json

Expected result: a config error (for example VLESS users: unsupported "encryption": ...), no panic. Same for xray run.

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": "mlkem768x25519plus.native.0rtt."
              }
            ]
          }
        ]
      }
    }
  ]
}

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/enc.json Format:json}
panic: runtime error: slice bounds out of range [1:0]

goroutine 1 [running]:
github.com/xtls/xray-core/infra/conf.(*VLessOutboundConfig).Build.func1(...)
github.com/xtls/xray-core/infra/conf/vless.go:370
github.com/xtls/xray-core/infra/conf.(*VLessOutboundConfig).Build(0x3a21a9a39860)
github.com/xtls/xray-core/infra/conf/vless.go:373 +0x11c5
github.com/xtls/xray-core/infra/conf.(*OutboundDetourConfig).Build(0x3a21a986f860)
github.com/xtls/xray-core/infra/conf/xray.go:395 +0xd48
github.com/xtls/xray-core/infra/conf.(*Config).Build(0x3a21a9a46580)
github.com/xtls/xray-core/infra/conf/xray.go:749 +0x1f25
github.com/xtls/xray-core/infra/conf/serial.BuildConfig({0x3a21a9b10200?, 0x23b9e38?, 0x3a21a986fb50?})
github.com/xtls/xray-core/infra/conf/serial/builder.go:66 +0x2a
github.com/xtls/xray-core/core.LoadConfig({0x1417b55, 0x4}, {0x23372e8?, 0x3a21a98cf008?})
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?, {0x3a21a98d2020?, 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.