[GH-ISSUE #5432] [Bug]: Shadowsocks2022 link: userinfo must not be base64 encoded #3797

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

Originally created by @taxi-c on GitHub (Jun 18, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5432

Describe the bug

When i get the link in the user panel just for the SS2022 inbound (2022-blake3-aes-128-gcm or 2022-blake3-aes-256-gcm), the userinfo is base64 encoded: userinfo = method+server password:client password.
for example Hiddify cleint could not read it without error. the method is none!

https://shadowsocks.org/doc/sip002.html
Note that encoding userinfo with Base64URL is recommended but optional for Stream and AEAD (SIP004). But for AEAD-2022 (SIP022), userinfo MUST NOT be encoded with Base64URL. When userinfo is not encoded, method and password MUST be percent encoded.

How to reproduce the problem

1.Create an inbound shaadowsocks : (2022-blake3-aes-128-gcm or 2022-blake3-aes-256-gcm)
2.Create a client which will use it.
3.Get the link, not the suscription link, but the link just for the inbound
4. You will have something like ss:// MjAyMi.......
5.

Expected behavior

cc2022-blake3-aes-256-gcm:YctPZ6U7xPPcU%2Bgp3u%2B0tx%2FtRizJN9K8y%2BuKlW2qjlI%3D@192.168.100.1:8888#Example3)

Actual behavior

Get a link like ss://MjAyMi.......

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

Ubuntu 24.04

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 @taxi-c on GitHub (Jun 18, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5432 ### Describe the bug When i get the link in the user panel just for the SS2022 inbound (2022-blake3-aes-128-gcm or 2022-blake3-aes-256-gcm), the userinfo is base64 encoded: userinfo = method+server password:client password. for example Hiddify cleint could not read it without error. the method is none! https://shadowsocks.org/doc/sip002.html Note that encoding userinfo with Base64URL is recommended but optional for Stream and AEAD ([SIP004](https://github.com/shadowsocks/shadowsocks-org/issues/30)). But for AEAD-2022 ([SIP022](https://github.com/shadowsocks/shadowsocks-org/issues/196)), userinfo MUST NOT be encoded with Base64URL. When userinfo is not encoded, method and password MUST be percent encoded. ### How to reproduce the problem 1.Create an inbound shaadowsocks : (2022-blake3-aes-128-gcm or 2022-blake3-aes-256-gcm) 2.Create a client which will use it. 3.Get the link, not the suscription link, but the link just for the inbound 4. You will have something like ss:// MjAyMi....... 5. ### Expected behavior cc2022-blake3-aes-256-gcm:YctPZ6U7xPPcU%2Bgp3u%2B0tx%2FtRizJN9K8y%2BuKlW2qjlI%3D@192.168.100.1:8888#Example3) ### Actual behavior Get a link like ss://MjAyMi....... ### 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 Ubuntu 24.04 ### 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:02 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

The report is confirmed. genShadowsocksLink in internal/sub/service.go (lines 719–742) applies base64.RawURLEncoding.EncodeToString to the entire userinfo string for all Shadowsocks ciphers, including 2022-blake3-aes-128-gcm and 2022-blake3-aes-256-gcm:

encPart := fmt.Sprintf("%s:%s", method, clients[clientIndex].Password)
if method[0] == '2' {
    encPart = fmt.Sprintf("%s:%s:%s", method, inboundPassword, clients[clientIndex].Password)
}
// ...
link := fmt.Sprintf("ss://%s@%s", base64.RawURLEncoding.EncodeToString([]byte(encPart)), joinHostPort(address, inbound.Port))

SIP002 (AEAD ciphers) permits optional Base64URL encoding of userinfo. SIP022 (AEAD-2022 ciphers) explicitly forbids it: userinfo MUST NOT be Base64URL-encoded; instead each component (method and password) MUST be percent-encoded individually. The correct link shape for an SS2022 inbound is:

ss://2022-blake3-aes-256-gcm:serverpass:clientpass@host:port

where each segment is percent-encoded (e.g. = → %3D, / → %2F).

The encodeUserinfo helper already present in the same file (line 667) does exactly that encoding and is used for Trojan and Hysteria2 links; it is simply not applied to the SS2022 path.

The fix requires the method[0] == '2' branch to build the userinfo as percent-encoded individual components instead of a single base64 blob — both for the direct link (line 742) and for the externalProxy path (line 734). The characterization test TestChar_C3_ShadowsocksExternalProxy in internal/sub/characterization_test.go (line 171) locks in the current (incorrect) base64 output and will need to be updated alongside the fix.

For context: issue #123 (closed, 2023) introduced base64 encoding for SS links to satisfy clients that expected the legacy format. That change covered all ciphers uniformly but predates the SIP022 constraint being enforced by newer clients such as Hiddify.


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

<!-- gh-comment-id:4743142202 --> @github-actions[bot] commented on GitHub (Jun 18, 2026): The report is confirmed. `genShadowsocksLink` in `internal/sub/service.go` (lines 719–742) applies `base64.RawURLEncoding.EncodeToString` to the entire userinfo string for **all** Shadowsocks ciphers, including `2022-blake3-aes-128-gcm` and `2022-blake3-aes-256-gcm`: ```go encPart := fmt.Sprintf("%s:%s", method, clients[clientIndex].Password) if method[0] == '2' { encPart = fmt.Sprintf("%s:%s:%s", method, inboundPassword, clients[clientIndex].Password) } // ... link := fmt.Sprintf("ss://%s@%s", base64.RawURLEncoding.EncodeToString([]byte(encPart)), joinHostPort(address, inbound.Port)) ``` SIP002 (AEAD ciphers) permits optional Base64URL encoding of userinfo. [SIP022](https://github.com/shadowsocks/shadowsocks-org/issues/196) (AEAD-2022 ciphers) explicitly forbids it: userinfo MUST NOT be Base64URL-encoded; instead each component (method and password) MUST be percent-encoded individually. The correct link shape for an SS2022 inbound is: ``` ss://2022-blake3-aes-256-gcm:serverpass:clientpass@host:port ``` where each segment is percent-encoded (e.g. `=` → `%3D`, `/` → `%2F`). The `encodeUserinfo` helper already present in the same file (line 667) does exactly that encoding and is used for Trojan and Hysteria2 links; it is simply not applied to the SS2022 path. The fix requires the `method[0] == '2'` branch to build the userinfo as percent-encoded individual components instead of a single base64 blob — both for the direct link (line 742) and for the `externalProxy` path (line 734). The characterization test `TestChar_C3_ShadowsocksExternalProxy` in `internal/sub/characterization_test.go` (line 171) locks in the current (incorrect) base64 output and will need to be updated alongside the fix. For context: issue #123 (closed, 2023) introduced base64 encoding for SS links to satisfy clients that expected the legacy format. That change covered all ciphers uniformly but predates the SIP022 constraint being enforced by newer clients such as Hiddify. --- _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#3797
No description provided.