Skip to content

XMC finalmask: Yggdrasil third-party login and texture verification - #7416

Merged
RPRX merged 6 commits into
XTLS:mainfrom
yandujun363:feat/xmc-yggdrasil-login
Nov 21, 2026
Merged

RPRX merged 6 commits into
XTLS:mainfrom
yandujun363:feat/xmc-yggdrasil-login

Conversation

@yandujun363

@yandujun363 yandujun363 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Refs #7394 (proposal). Draft for review, not ready to merge.

What this adds

  • Yggdrasil third-party login. The XMC client can authenticate against a third-party Yggdrasil API (Blessing Skin / authlib-injector compatible), join the Minecraft session with the standard vanilla login hash and reuse the API's signed textures. The XMC server verifies players through sessionserver/session/minecraft/hasJoined instead of a hand-copied profile list.
  • Texture verification and key handling. In Yggdrasil mode the RSA key pair is no longer derived from the password: each side generates its own key pair, the client accepts the key sent in Encryption Request and binds it through the session hash, and the server verifies with its own actual public key through /hasJoined. The client verifies the signed textures property with the API's signaturePublickey (SHA1withRSA), refreshing the key once if a rotation is detected.
  • Generated config. config.pb.go is regenerated with infra/vprotogen for the new Yggdrasil message and Config.yggdrasil = 13.

Files: yggdrasil.go (new), client.go, server.go, profile.go, config.go, config.proto (Config.yggdrasil = 13), infra/conf/transport_finalmask.go, plus tests.

Rebased onto #7402

The branch now sits on current main (f781c687, #7402 "Switch to native frame padding" merged). Conflicts resolved as follows:

  • Padding in config.proto/config.pb.go keeps main's length_min/length_max/direction/delay_min/delay_max; config.pb.go regenerated with infra/vprotogen instead of hand-merged.
  • The legacy password checks added by XMC finalmask: Switch to native frame padding (breaking); delay supports range (receiver waits at least minimal ms) #7402 (empty password, MaxLegacyPasswordLength) moved into the legacy branch of XMC.Build, so Yggdrasil mode does not require a password (it is ignored there) while the legacy path keeps both checks.
  • newClientConn/wrapConnServer call sites updated for the new paddings + auth parameters (including config_test.go).

Compatibility

  • No yggdrasil section: the legacy pre-shared password + profiles path is unchanged.
  • With yggdrasil: password is ignored (a console warning is printed) and profiles is not required.
  • Config.yggdrasil = 13 keeps existing configs that already use paddings = 12 working unchanged.

What this waits on

Tests

Locally, on top of f781c687:

go build ./...                                         # pass
go test -count=1 ./transport/internet/finalmask/xmc ./infra/conf   # pass
go run ./infra/vformat/main.go -mode check -pwd ./      # pass
go run ./infra/vprotogen/main.go -mode check -pwd ./    # pass
go test -timeout 1h ./...                              # all packages pass; only TestDomainSniffing fails (network, see below)

testing/scenarios fails only in TestDomainSniffing, which dials https://www.github.com/ over the real internet; that is blocked in this WSL environment and the test fails identically on clean main (dial tcp 20.247.166.64:443: i/o timeout), so it is not caused by this branch.

Commits are AI-generated, as declared in the commit trailers.

Let XMC act as a Yggdrasil login client instead of requiring hand-copied player profiles: the client authenticates against a third-party Yggdrasil API (Blessing Skin and compatible servers), joins the Minecraft session with the standard vanilla login hash, and the server verifies players through hasJoined, reusing the signed textures from the API.

The login hash follows vanilla Minecraft: sha1(serverId + sharedSecret + serverPublicKey) rendered as a signed BigInteger hex string, so the same client flow can later be used against a real Minecraft server. Legacy password + profile list mode is kept when no yggdrasil section is configured.

This commit is AI-generated.
In Yggdrasil mode the transport no longer derives the RSA key pair from the password: each side generates its own key pair, the client accepts the key sent in Encryption Request and binds it through the vanilla session hash, and the server verifies with its own actual public key through /hasJoined. A console warning is emitted because the pre-shared password no longer authenticates the transport.

The client now verifies the textures property signature with the Yggdrasil API signaturePublickey (SHA1withRSA, as used by Minecraft clients and Blessing Skin), requiring signed textures in Login Success and refreshing the API key once if rotation is detected.

This commit is AI-generated.
The server-side Yggdrasil check waited a fixed 200 ms before reading
hasJoined again, and every 200 ms after that. The client sends its join
request right after the encryption response, so the first read almost
always missed and every login paid at least one fixed interval: measured
against a local API the check took about 200-400 ms per connection.

Start the retry interval at 10 ms and double it up to the previous 200 ms,
which keeps the same 10 s deadline and only slows down for clients that
are really absent. Also cache the verifier per API root so its HTTP client
and keep-alive connections are shared instead of being rebuilt for every
login.

This commit was produced with AI assistance (DeepSeek Harness).
@yandujun363
yandujun363 force-pushed the feat/xmc-yggdrasil-login branch from b20a29c to 67f2538 Compare November 18, 2026 02:52
@yandujun363

Copy link
Copy Markdown
Contributor Author

本地 E2E 复测(2026-11-18)

在 current head 67f25383(基于 main 82b5b76b)上复跑。

测试台:Go 标准库写的单文件最小 Yggdrasil API,实现 authenticate / refresh / validate / join / hasJoined / profile;返回官方默认 Steve 皮肤,textures 属性非空,用 API 的 signaturePublickey 做 SHA1withRSA 签名(已用 openssl dgst -sha1 -verify 独立验证)。

1. Xray XMC 客户端 ↔ Xray XMC 服务端(Yggdrasil 模式)

  • authenticate → join → hasJoined 全部命中;客户端拉取 metadata 校验 textures 签名。
  • 1 KiB 与 32 MiB 下载 sha256 均一致;32 MiB 约 28.4 MB/s。
  • go test ./transport/internet/finalmask/xmc ./infra/conf 及 -race 通过。

2. 真实 Minecraft 26.1(775)+ 服务端模组

Fabric 26.1 开发服,online-mode=true,authlib-injector 指向同一 API;服务端模组 xmc-mcserver-core master 695fa38。

以上数据由 AI 编码代理复跑整理。


Local E2E re-run (2026-11-18)

Re-ran on current head 67f25383 (based on main 82b5b76b).

Harness: a single-file minimal Yggdrasil API using only the Go standard library, implementing authenticate / refresh / validate / join / hasJoined / profile; it returns the official default Steve skin with a non-empty signed textures property (SHA1withRSA via the API's signaturePublickey, independently verified with openssl dgst -sha1 -verify).

1. Xray XMC client ↔ Xray XMC server (Yggdrasil mode)

  • authenticate → join → hasJoined all hit; the client fetches metadata and verifies the textures signature.
  • 1 KiB and 32 MiB downloads: sha256 OK; 32 MiB at ~28.4 MB/s.
  • go test ./transport/internet/finalmask/xmc ./infra/conf and -race pass.

2. Real Minecraft 26.1 (775) + server-side mod

Fabric 26.1 dev server, online-mode=true, authlib-injector pointing at the same API; server-side mod xmc-mcserver-core master 695fa38.

Numbers reproduced and summarized with AI assistance.

Resolve conflicts between the Yggdrasil login work and main:
- xmc config: keep yggdrasil (field 13) next to no_padding (field 14) and
  regenerate config.pb.go with protoc-gen-go v1.36.12.
- padding: adopt paddingSchedule() from main while threading the
  yggdrasil auth/verifier through newClientConn/wrapConnServer.
- infra/conf: validate password/profiles per mode (relaxed in yggdrasil
  mode) while keeping the noPadding/exclusive checks from main.
- tests: keep both Yggdrasil tests and main's noPadding tests.

This commit was produced by an AI agent (DeepSeek Harness).
The merge regenerated the protobuf file with the system protoc, so the
generated header recorded 'protoc v7.36.1' while the repository's own
generator (infra/vprotogen, which compiles the .proto in-process and has
no protoc binary) emits '(unknown)'. The CI check-format-and-proto job
compares the checked-in file against vprotogen output and failed.

Regenerate with 'go run ./infra/vprotogen -mode generate -pwd ./' so
'mode check' passes.

This commit was produced by an AI agent (DeepSeek Harness).
@yandujun363

Copy link
Copy Markdown
Contributor Author

本地 E2E 复测(2026-11-18,第三轮)

在 head c20f3111 上复跑。该 head = f5749a23(合并 main b1905088)+ c20f3111(用 infra/vprotogen 重新生成 config.pb.go,修复 check-format-and-proto)。CI 在这个 head 上已全绿(23 项 pass,仅 build-release-only 按规则 skipped)。

测试台:Go 标准库单文件最小 Yggdrasil API,实现 authenticate / refresh / validate / join / hasJoined / profile,返回官方默认 Steve 皮肤、非空签名 textures(openssl dgst -sha1 -verify → Verified OK)。服务端模组 xmc-mcserver-core master 695fa38,Fabric 26.1 / 协议 775。

1. 密码模式 Xray XMC ↔ Xray XMC

  • padding:65536 c2s delay 200 / 32768 s2c / 65536 c2s delay 200。
  • 1 KiB 与 32 MiB 下载、上传 sha256 全部一致。
  • 中间用计数 relay 观察线上字节:c2s=131509、s2c=34917 → 两轮 64 KiB padding 原样上线(131072 + 437 开销)。

2. Yggdrasil 模式 Xray XMC ↔ Xray XMC

  • authenticate → join → hasJoined 全部命中,客户端另拉 metadata 校验 textures 签名。
  • 1 KiB 与 32 MiB 双向 sha256 一致;relay:c1 c2s=131509 s2c=511773、c2 s2c=34008460、c3 c2s=33736692(padding 未压缩)。

3. 带模组:Fabric 26.1(Yggdrasil 登录)← XMC client

链路:XMC client(Yggdrasil 登录 MC 服)→ MC 25565(模组落点)→ 模组隧道 → 普通 VLESS 10086 → HTTP 目标。

  • 模组日志:XMC landing detected for TestUser、XMC tunnel established for TestUser、channels registered: data=xmc:data, padding=xmc:pad;每条连接 API 侧 authenticate/join/hasJoined 齐全,vanilla UUID 正确。
  • 1 KiB 与 32 MiB 双向 sha256 一致(32 MiB 上传用 Expect: 100-continue 等隧道排空)。
  • 压缩修复验证:先在 network-compression-threshold=256 下跑(模组会告警),relay c2s=131519 ≈ 131072 padding + 447 开销,说明 64 KiB padding 帧未被 zlib 压缩——本分支已包含 XMC finalmask: Bound padding schedules; Fix delay placement; Stop compressing frames #7423 的“XMC 写出帧永不压缩”。

4. 原版登录路径

./gradlew probeOnline(完整的 online-mode 原版登录路径):

[probe] authenticated as PlayerTwo (...)
[probe] joined the session (...)
[probe] login success; continuing as an ordinary online client
[probe] online vanilla landing OK (reached the Play stage)

服务端同时打印 PlayerTwo joined the game。注意 probe 不实现 Set Compression,所以最终把 network-compression-threshold 设为 README 允许的 -1;真实原版客户端在 65536 下不受该限制。

说明

  • 测试台已关闭,Xray 工作树没有代码改动。
  • 已知限制(沿用上一轮结论):模组待转发队列上限 256 payload,隧道建立前猛发大包会溢出;用 Expect: 100-continue 规避。

Local E2E re-run (2026-11-18, third round)

Re-ran on head c20f3111 (= merge f5749a23 of main b1905088, plus c20f3111 regenerating config.pb.go with infra/vprotogen, which fixes check-format-and-proto). CI is green on this head (23 pass, only build-release-only skipped as designed).

Harness: a single-file minimal Yggdrasil API in the Go standard library (authenticate/refresh/validate/join/hasJoined/profile) returning the official default Steve skin with a non-empty signed textures property (verified with openssl dgst -sha1 -verify → Verified OK). Server mod xmc-mcserver-core master 695fa38, Fabric 26.1 / protocol 775.

  1. Password mode Xray XMC ↔ Xray XMC — 1 KiB and 32 MiB downloads and uploads sha256 OK; a counting relay on the wire shows c2s=131509, i.e. both 64 KiB padding turns traveled uncompressed (131072 + 437 overhead).
  2. Yggdrasil mode Xray XMC ↔ Xray XMC — authenticate → join → hasJoined hit, client fetched metadata and verified the textures signature; 1 KiB and 32 MiB both directions sha256 OK; relay s2c=34008460 on the large download and c2s=33736692 on the large upload.
  3. Mod: Fabric 26.1 (Yggdrasil login) ← XMC client — the mod logged XMC landing detected / XMC tunnel established, every connection did the API authenticate/join/hasJoined trio, and 1 KiB plus 32 MiB transfers hashed OK. The run started at network-compression-threshold=256: relay c2s=131519 proves the 64 KiB padding frames were not zlib-compressed, so XMC finalmask: Bound padding schedules; Fix delay placement; Stop compressing frames #7423's "never compress the frames XMC writes" is active in this branch.
  4. Vanilla path — ./gradlew probeOnline reached online vanilla landing OK (reached the Play stage) and the server logged PlayerTwo joined the game. The probe does not implement Set Compression, so the final config uses network-compression-threshold=-1 (allowed by the mod README); a real vanilla client is fine at 65536 too.

The bench is shut down again and the worktree has no code changes. Known limitation unchanged: the mod's pending payload queue holds 256 entries, so flooding a large body before the tunnel drains can overflow; Expect: 100-continue avoids it.

@yandujun363
yandujun363 marked this pull request as ready for review November 18, 2026 13:12
同步 upstream main(XTLS/Xray-core)最新 11 个提交,无冲突。

本提交由 AI 生成。
@yandujun363

Copy link
Copy Markdown
Contributor Author

@RPRX 应该没问题了,差点把这个忘记了,审查之后没问题就合并吧。
下一步打算是:

  • 优化配置,实现类似 header-custom 的 clients 和 servers
  • 优化填充,实现伪装为一般同步流量
  • 尝试实现 pjscruggs/raknetify2 这个模组的UDP功能,这样可以光明正大用UDP解决队头阻塞

@RPRX
RPRX merged commit 5225121 into XTLS:main Nov 21, 2026
24 checks passed
@yandujun363
yandujun363 deleted the feat/xmc-yggdrasil-login branch November 22, 2026 03:01
patterniha added a commit to patterniha/Xray-core that referenced this pull request Nov 22, 2026
Brings in XTLS/Xray-core up to 74cbdf4 (4 commits). XTLS's version is
unchanged, so the fork's core/core.go stays 26.11.22. Includes: XMC
finalmask Yggdrasil third-party login and texture verification (XTLS#7416),
outbounds avoiding circular dependencies with the built-in DNS (XTLS#7425),
the HTTPUpgrade client closing the connection when the upgrade fails
(XTLS#7395) and a README update (XTLS#7446).

No conflicts. XTLS#7395 is identical to the fork's early merge of it
(cbf3dac), so transport/internet/httpupgrade/dialer.go is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants