[GH-ISSUE #5435] [Bug]: Possible issues with VLESS outbound structure and XHTTP parsing #3799

Closed
opened 2026-10-31 20:35:03 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @MohsenBg on GitHub (Jun 19, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5435

Describe the bug

Hi,

While implementing a compatible VLESS/XHTTP parser for another project, I was comparing my output with the parser in internal/util/link/outbound.go and noticed two things that I wasn't sure were intentional.

1. VLESS outbound structure

Current code:

"settings": map[string]any{
    "address": host,
    "port": port,
    "id": id,
    "flow": params.Get("flow"),
    "encryption": firstNonEmpty(params.Get("encryption"), "none"),
},

Source:

github.com/MHSanaei/3x-ui@4915d6b18d/internal/util/link/outbound.go (L273-L284)

The structure above appears different from the VLESS outbound schema commonly used by Xray, which is usually:

{
  "protocol": "vless",
  "settings": {
    "vnext": [
      {
        "address": "...",
        "port": 443,
        "users": [
          {
            "id": "...",
            "flow": "...",
            "encryption": "none"
          }
        ]
      }
    ]
  }
}
ob := Outbound{
    "protocol": "vless",
    "tag":      decodeHash(u.Fragment),
    "settings": map[string]any{
        "vnext": []any{
            map[string]any{
                "address": host,
                "port":    port,
                "users": []any{
                    map[string]any{
                        "id":         id,
                        "encryption": firstNonEmpty(params.Get("encryption"), "none"),
                        "flow":       params.Get("flow"),
                    },
                },
            },
        },
    },
    "streamSettings": stream,
}

Is there another conversion step later that transforms the flat structure into a standard Xray outbound, or is this intentional?

2. XHTTP advanced fields

Current implementation:

github.com/MHSanaei/3x-ui@4915d6b18d/internal/util/link/outbound.go (L598-L610)

places advanced fields directly under xhttpSettings:

xh[k] = v

However, according to the Xray XHTTP examples, fields such as:

  • xPaddingBytes
  • scMaxEachPostBytes
  • scMinPostsIntervalMs
  • xmux
  • downloadSettings

appear to belong under:

"xhttpSettings": {
    "host": "...",
    "path": "...",
    "mode": "auto",
    "extra": {
        ...
    }
}

Reference:

https://github.com/XTLS/Xray-core/discussions/4113

While implementing my own parser I ended up handling it roughly like this:

xh := stream["xhttpSettings"].(map[string]any)

if host := p.Get("host"); host != "" {
    xh["host"] = host
}

if path := p.Get("path"); path != "" {
    xh["path"] = path
}

if mode := p.Get("mode"); mode != "" {
    xh["mode"] = mode
}

extra := map[string]any{}

if raw := p.Get("extra"); raw != "" {
    var obj map[string]any
    if err := json.Unmarshal([]byte(raw), &obj); err == nil {
        extra = obj
    }
}

if len(extra) > 0 {
    xh["extra"] = extra
}

I am not sure whether the current behavior is intentional, based on an older XHTTP schema, or whether this may be a bug/incompatibility.

Could someone clarify the intended behavior?

How to reproduce the problem

How to reproduce the problem

  1. Start from a clean environment with a working Go project.

  2. Clone the repository and checkout the referenced commit:

    git clone https://github.com/MHSanaei/3x-ui.git
    cd 3x-ui
    git checkout 4915d6b18dabaace15a7557682f93bf7607a2ecf
    
  3. Locate the outbound parser implementation:

    internal/util/link/outbound.go
    
  4. Parse a sample VLESS link using the parser (call the parsing function used in the project).

    Example link:

vless://<uuid>@example.com:443?encryption=none&security=tls&sni=example.com&fp=chrome&alpn=h2%2Chttp%2F1.1&insecure=0&allowInsecure=0&type=xhttp&host=example.com&path=%2FexamplePath123&mode=auto&extra=%7B%22xPaddingBytes%22%3A%22100-1000%22%2C%22xPaddingHeader%22%3A%22X-Cache%22%2C%22xPaddingKey%22%3A%22x_location%22%2C%22xPaddingMethod%22%3A%22tokenish%22%2C%22xPaddingObfsMode%22%3Atrue%2C%22xPaddingPlacement%22%3A%22queryInHeader%22%7D#example-tag
  1. Observe the generated outbound structure for VLESS:

    • Check the settings field in the output
    • Notice it is a flat structure (no vnext / users nesting)
  2. Compare the output with a standard Xray VLESS outbound configuration schema.

  3. Repeat the same process for XHTTP links:

    • Provide a link with XHTTP parameters (host, path, mode, xPaddingBytes, etc.)
    • Observe that advanced fields are placed directly under xhttpSettings
  4. Compare with Xray XHTTP specification:
    https://github.com/XTLS/Xray-core/discussions/4113

  5. Notice that several fields expected under xhttpSettings.extra appear at the top level instead.

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.3.1

Xray-core version

26.6.1

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu24.0.4

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

None

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @MohsenBg on GitHub (Jun 19, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5435 ### Describe the bug Hi, While implementing a compatible VLESS/XHTTP parser for another project, I was comparing my output with the parser in `internal/util/link/outbound.go` and noticed two things that I wasn't sure were intentional. ### 1. VLESS outbound structure Current code: ```go "settings": map[string]any{ "address": host, "port": port, "id": id, "flow": params.Get("flow"), "encryption": firstNonEmpty(params.Get("encryption"), "none"), }, ``` Source: https://github.com/MHSanaei/3x-ui/blob/4915d6b18dabaace15a7557682f93bf7607a2ecf/internal/util/link/outbound.go#L273-L284 The structure above appears different from the VLESS outbound schema commonly used by Xray, which is usually: ```json { "protocol": "vless", "settings": { "vnext": [ { "address": "...", "port": 443, "users": [ { "id": "...", "flow": "...", "encryption": "none" } ] } ] } } ``` ```go ob := Outbound{ "protocol": "vless", "tag": decodeHash(u.Fragment), "settings": map[string]any{ "vnext": []any{ map[string]any{ "address": host, "port": port, "users": []any{ map[string]any{ "id": id, "encryption": firstNonEmpty(params.Get("encryption"), "none"), "flow": params.Get("flow"), }, }, }, }, }, "streamSettings": stream, } ``` Is there another conversion step later that transforms the flat structure into a standard Xray outbound, or is this intentional? ### 2. XHTTP advanced fields Current implementation: https://github.com/MHSanaei/3x-ui/blob/4915d6b18dabaace15a7557682f93bf7607a2ecf/internal/util/link/outbound.go#L598-L610 places advanced fields directly under `xhttpSettings`: ```go xh[k] = v ``` However, according to the Xray XHTTP examples, fields such as: * xPaddingBytes * scMaxEachPostBytes * scMinPostsIntervalMs * xmux * downloadSettings appear to belong under: ```json "xhttpSettings": { "host": "...", "path": "...", "mode": "auto", "extra": { ... } } ``` Reference: https://github.com/XTLS/Xray-core/discussions/4113 While implementing my own parser I ended up handling it roughly like this: ```go xh := stream["xhttpSettings"].(map[string]any) if host := p.Get("host"); host != "" { xh["host"] = host } if path := p.Get("path"); path != "" { xh["path"] = path } if mode := p.Get("mode"); mode != "" { xh["mode"] = mode } extra := map[string]any{} if raw := p.Get("extra"); raw != "" { var obj map[string]any if err := json.Unmarshal([]byte(raw), &obj); err == nil { extra = obj } } if len(extra) > 0 { xh["extra"] = extra } ``` I am not sure whether the current behavior is intentional, based on an older XHTTP schema, or whether this may be a bug/incompatibility. Could someone clarify the intended behavior? ### How to reproduce the problem ## How to reproduce the problem 1. Start from a clean environment with a working Go project. 2. Clone the repository and checkout the referenced commit: ```bash git clone https://github.com/MHSanaei/3x-ui.git cd 3x-ui git checkout 4915d6b18dabaace15a7557682f93bf7607a2ecf ``` 3. Locate the outbound parser implementation: ``` internal/util/link/outbound.go ``` 4. Parse a sample VLESS link using the parser (call the parsing function used in the project). Example link: ```url vless://<uuid>@example.com:443?encryption=none&security=tls&sni=example.com&fp=chrome&alpn=h2%2Chttp%2F1.1&insecure=0&allowInsecure=0&type=xhttp&host=example.com&path=%2FexamplePath123&mode=auto&extra=%7B%22xPaddingBytes%22%3A%22100-1000%22%2C%22xPaddingHeader%22%3A%22X-Cache%22%2C%22xPaddingKey%22%3A%22x_location%22%2C%22xPaddingMethod%22%3A%22tokenish%22%2C%22xPaddingObfsMode%22%3Atrue%2C%22xPaddingPlacement%22%3A%22queryInHeader%22%7D#example-tag ``` 5. Observe the generated outbound structure for VLESS: * Check the `settings` field in the output * Notice it is a flat structure (no `vnext` / `users` nesting) 6. Compare the output with a standard Xray VLESS outbound configuration schema. 7. Repeat the same process for XHTTP links: * Provide a link with XHTTP parameters (host, path, mode, xPaddingBytes, etc.) * Observe that advanced fields are placed directly under `xhttpSettings` 8. Compare with Xray XHTTP specification: [https://github.com/XTLS/Xray-core/discussions/4113](https://github.com/XTLS/Xray-core/discussions/4113) 9. Notice that several fields expected under `xhttpSettings.extra` appear at the top level instead. ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.3.1 ### Xray-core version 26.6.1 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu24.0.4 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:35:03 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jun 19, 2026):

Both observations are confirmed against the current source at v3.3.1.

1. VLESS outbound structure — confirmed bug

parseVless in internal/util/link/outbound.go (lines 273–285) emits a flat settings map without the vnext/users nesting that the Xray VLESS outbound schema requires. By contrast, parseVmess in the same file (lines 212–226) correctly nests vnext/users, and parseTrojan (lines 319–325) correctly nests servers. No downstream transformation corrects the VLESS output: parsed outbounds are merged directly into the Xray runtime config by mergeSubscriptionOutbounds (internal/web/service/xray.go:567) and serialised as-is by parsedExternalOutbound (internal/sub/external_config.go:139–149). A VLESS entry pulled from an outbound subscription therefore injects invalid JSON into the Xray config.

One additional touch-point that would need updating alongside any fix: extractOutboundEndpoints in internal/web/service/outbound/outbound.go (lines 251–252) also reads settings["address"] and settings["port"] from the flat map and would need to traverse vnext[0] instead, matching the VMess path already there on lines 244–250.

2. XHTTP extra nesting — partially confirmed

applyTransport (outbound.go, lines 598–610) reads individual query parameters (xPaddingBytes, scMaxEachPostBytes, scMinPostsIntervalMs, uplinkChunkSize) and sets them as direct keys of xhttpSettings. buildStream (lines 547–553) also seeds xPaddingBytes at the top level of xhttpSettings, with a comment referencing #5141 on fingerprinting concerns.

Two distinct gaps are present:

  • The extra query parameter (a JSON blob, as in the sample link you supplied) is not read at all by the current parser. Fields carried inside that blob — such as xPaddingHeader, xPaddingKey, xPaddingMethod, xPaddingObfsMode, xPaddingPlacement — are silently dropped.
  • Whether the individually-named fields (xPaddingBytes, etc.) should be placed directly under xhttpSettings or nested under xhttpSettings.extra depends on which XHTTP config schema the running Xray-core version expects. The repo imports github.com/xtls/xray-core v1.260327.1-0.20260601021109-94ffd50060f1 (go.mod:24); that library is not vendored in-repo, so verifying against its XHTTPConfig struct directly would confirm the correct placement.

Related closed issues for context: #4406 (UI "Convert" path for XHTTP outbounds), #4107 (feature request for xhttp extra field support in outbound), #5141 (fingerprinting via scMinPostsIntervalMs seed value).

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4750811009 --> @github-actions[bot] commented on GitHub (Jun 19, 2026): Both observations are confirmed against the current source at v3.3.1. **1. VLESS outbound structure — confirmed bug** `parseVless` in `internal/util/link/outbound.go` (lines 273–285) emits a flat `settings` map without the `vnext`/`users` nesting that the Xray VLESS outbound schema requires. By contrast, `parseVmess` in the same file (lines 212–226) correctly nests `vnext`/`users`, and `parseTrojan` (lines 319–325) correctly nests `servers`. No downstream transformation corrects the VLESS output: parsed outbounds are merged directly into the Xray runtime config by `mergeSubscriptionOutbounds` (`internal/web/service/xray.go:567`) and serialised as-is by `parsedExternalOutbound` (`internal/sub/external_config.go:139–149`). A VLESS entry pulled from an outbound subscription therefore injects invalid JSON into the Xray config. One additional touch-point that would need updating alongside any fix: `extractOutboundEndpoints` in `internal/web/service/outbound/outbound.go` (lines 251–252) also reads `settings["address"]` and `settings["port"]` from the flat map and would need to traverse `vnext[0]` instead, matching the VMess path already there on lines 244–250. **2. XHTTP `extra` nesting — partially confirmed** `applyTransport` (outbound.go, lines 598–610) reads individual query parameters (`xPaddingBytes`, `scMaxEachPostBytes`, `scMinPostsIntervalMs`, `uplinkChunkSize`) and sets them as direct keys of `xhttpSettings`. `buildStream` (lines 547–553) also seeds `xPaddingBytes` at the top level of `xhttpSettings`, with a comment referencing #5141 on fingerprinting concerns. Two distinct gaps are present: - The `extra` query parameter (a JSON blob, as in the sample link you supplied) is not read at all by the current parser. Fields carried inside that blob — such as `xPaddingHeader`, `xPaddingKey`, `xPaddingMethod`, `xPaddingObfsMode`, `xPaddingPlacement` — are silently dropped. - Whether the individually-named fields (`xPaddingBytes`, etc.) should be placed directly under `xhttpSettings` or nested under `xhttpSettings.extra` depends on which XHTTP config schema the running Xray-core version expects. The repo imports `github.com/xtls/xray-core v1.260327.1-0.20260601021109-94ffd50060f1` (go.mod:24); that library is not vendored in-repo, so verifying against its `XHTTPConfig` struct directly would confirm the correct placement. Related closed issues for context: #4406 (UI "Convert" path for XHTTP outbounds), #4107 (feature request for xhttp extra field support in outbound), #5141 (fingerprinting via `scMinPostsIntervalMs` seed value). *This reply was generated automatically; a maintainer may follow up.*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3799
No description provided.