Skip to content

MASQUE client: Support WARP - #6878

Merged
RPRX merged 3 commits into
XTLS:mainfrom
CluvexStudio:masque-warp
Oct 8, 2026
Merged

RPRX merged 3 commits into
XTLS:mainfrom
CluvexStudio:masque-warp

Conversation

@CluvexStudio

Copy link
Copy Markdown
Contributor

#6844 (comment)
#6862 (comment)

masque can now connect to cloudflare warp. masqueSettings gets a warp object, filled from the warp registration of the device, like the keys of wireguard

"streamSettings": {
  "method": "masque",
  "masqueSettings": {
    "warp": {
      "privateKey": "MHcCAQEE...",
      "publicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEIaU7MToJm9NKp8YfGxR6r+/h4mcG7SxI8tsW8OR1A5tv/zCzVbCRRh2t87/kxnP6lAy0lkr7qYwu+ox+k3dr6w==",
      "address": ["172.16.0.2/32", "2606:4700:110:8a36::2/128"]
    }
  },
  "security": "tls",
  "tlsSettings": {
    "serverName": "consumer-masque.cloudflareclient.com"
  }
}

-- privateKey the p-256 key of the device, pem or base64, a client cert is made from it
-- publicKey the endpoint key from the registration, the server cert is checked against it so the sni can be anything
-- address the addresses of the device, warp doesnt assign them inside the tunnel
-- http/3 uses cf-connect-ip and the older datagram setting, http/2 a plain connect with bare ip packets, like the warp client. "alpn": ["h2"] picks http/2
-- the device needs warp_enabled on, otherwise the endpoint answers with access denied
-- nothing is requested from cloudflare, the keys come from the registration like with wireguard
-- utls fingerprints send the client cert now too, http/2 needs it

tested in iran on the real network with finalmask noise and fragment: http/3 and http/2 both connect and hold up (warp on, ipv6, udp, parallel downloads, idle). plus tests against a local server that acts like the warp endpoint

@RPRX

RPRX commented Oct 1, 2026

Copy link
Copy Markdown
Member

话说直接写 WARP 字样是没事的吗

另外这个是需要客户端发送证书吗

@CluvexStudio

Copy link
Copy Markdown
Contributor Author

话说直接写 WARP 字样是没事的吗

i don't think the warp name will be a problem. if you want i can change it, or we can merge it as is for now and change it later, it's up to you

另外这个是需要客户端发送证书吗

yes, it needs one. the endpoint authenticates the device by mtls: the client cert is self-signed and made on the fly from privateKey, cloudflare only checks that its key is the one enrolled for that device. no token or password goes over the wire. mihomo does it the same way, and it's why the first commit is in here, utls fingerprints were dropping the client cert

@RPRX

RPRX commented Oct 5, 2026

Copy link
Copy Markdown
Member

认证信息填传输层,好吧看了下 Hy2 客户端实现也是这样,而入站的认证填在代理层方便 API,然而支持 WARP 显然仅客户端

不清楚 Cloudflare 现在的政策,不过确实其它仓库明确写 WARP 字样都没事,且有没有这个字样都改变不了 WARP 专用的事实

关于客户端发送证书,感觉 WARP 这特征有点扎眼了,而且你这代码咋像是 uTLS 会有独特的逻辑?另外想到了 #6354

特地看了下验证服务端证书的代码,你这 pin 完公钥不验证 signature 什么的吗?自定义的 VerifyPeerCertificate 又不是一定有

况且这个相当于强制 pin 公钥了,已证实服务端身份,似乎没必要再去叠上 pcs/vcn 了吧,也不清楚 CF 发来的证书是什么样的

@CluvexStudio

Copy link
Copy Markdown
Contributor Author

yeah with publicKey it's a pure spki pin — matches the leaf's RawSubjectPublicKeyInfo to the enrolled key, nothing else, on purpose. the pin is the trust anchor so there's no chain to check, and the handshake still proves the server holds that key (1.3 CertificateVerify / the ecdhe signature, which go does even under InsecureSkipVerify — that flag only skips chain building, not the signature). so right-key-in-the-cert + proof-of-possession is enough; checking a signature on the cert would just say some CA signed it, which is moot once you pin the exact key. and the custom VerifyPeerCertificate runs on the utls path too — copyConfig carries it and InsecureSkipVerify into the utls config. TestDialWarpVerification covers it: matching key connects, a different key is rejected.

it's not really stacked on pcs/vcn — it only chains to an existing verify if the user set one, so warp itself adds nothing on top. can make the pin the sole server check if you'd rather.

the client cert is just how warp authenticates (self-signed from privateKey, CF only checks the key is the enrolled one), so it's unavoidable and yeah, a recognizable shape. the utls logic is only there because utls has its own CertificateRequestInfo — GetClientCertificate needs the little bridge in the first commit, otherwise the fingerprint drops the client cert.

keeping the WARP name :))

@therealtunge

Copy link
Copy Markdown

you sound like you prompted an ai to act like a gen z person

@CluvexStudio

Copy link
Copy Markdown
Contributor Author

@therealtunge if you genuinely think an ai wrote this then my suggestion is to try it yourself. ask claude for a masque warp transport and see if anthropic's safeguards even let you finish. i went that route first to save the work and it didn't happen. my goal here was only to help and contribute to xray-core. i had already implemented it earlier in my own core aether. so go ahead and try it yourself first then come back and tell me it was ai :))

@RPRX

RPRX commented Oct 8, 2026

Copy link
Copy Markdown
Member

@CluvexStudio 确实我想多了不过最近已经 PTSD 到很难不多想了,至于 pcs/vcn 叠就叠吧,你贴出服务端两次发的证书看看

“客户端发送证书”使 WARP 即使是换成了 CF 通用 IP、隐藏了 SNI 后仍有独特特征,话说这个能不能 ECH / domain fronting?

这个 PR 即将合并,请发出 ETH 地址以便转你一个 Project X NFT,另外希望你能写一篇 MASQUE、WG 结合 Finalmask 的教程

@RPRX RPRX changed the title MASQUE: Support WARP MASQUE client: Support WARP Oct 8, 2026
@RPRX
RPRX merged commit 9e55a6e into XTLS:main Oct 8, 2026
40 checks passed
@Fangliding

Copy link
Copy Markdown
Member

“客户端发送证书”使 WARP 即使是换成了 CF 通用 IP、隐藏了 SNI 后仍有独特特征,话说这个能不能 ECH / domain fronting?

warp wg/masque 是划分出来的专用IP段 跑CDN前端不同的stack 黑洞掉一了百了 不然我之前为什么我之前一直反对加这个 还能用只是监管钝性罢了

@RPRX

RPRX commented Oct 8, 2026

Copy link
Copy Markdown
Member

warp wg/masque 是划分出来的专用IP段 跑CDN前端不同的stack 黑洞掉一了百了 不然我之前为什么我之前一直反对加这个 还能用只是监管钝性罢了

这个我知道,然而现在在某些地区这些 IP 就是能连,另外如果以后 WARP 不支持 WG 了那么就只能 MASQUE 了,早晚得支持

@RememberOurPromise

Copy link
Copy Markdown

@CluvexStudio 有兴趣的话可以补上h3l4模式,这个模式出口IP是另一个IP池

@CluvexStudio

CluvexStudio commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

the two certs for consumer-masque.cloudflareclient.com, both from 162.159.198.0/24, same sni:

198.1 is a normal Let's Encrypt cert, CN=cloudflareclient.com, full chain to isrg.
198.2 is self-signed, CN=masque.cloudflareclient.com, issuer "Cloudflare 2024-02-27 Self-Signed Root", just the leaf.

both P-256, i hit each 3 times and the key never moved. the self-signed leaf's spki is exactly the publicKey from the example:

MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEIaU7MToJm9NKp8YfGxR6r+/h4mcG7SxI8tsW8OR1A5tv/zCzVbCRRh2t87/kxnP6lAy0lkr7qYwu+ox+k3dr6w==

-----BEGIN CERTIFICATE-----
MIICPzCCAcWgAwIBAgIUc2dOs+UVA8fE6UO4F/QWdHT8JoEwCgYIKoZIzj0EAwMw
TjELMAkGA1UEBhMCVVMxGTAXBgNVBAoMEENsb3VkZmxhcmUsIEluYy4xJDAiBgNV
BAMMGzIwMjQtMDItMjcgU2VsZi1TaWduZWQgUm9vdDAeFw0yNjAxMjYxMDQ1MDZa
Fw0yNzAyMjYxMDQ1MDZaMCYxJDAiBgNVBAMMG21hc3F1ZS5jbG91ZGZsYXJlY2xp
ZW50LmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCGlOzE6CZvTSqfGHxsU
eq/v4eJnBu0sSPLbFvDkdQObb/8ws1WwkUYdrfO/5MZz+pQMtJZK+6mMLvqMfpN3
a+ujgagwgaUwHQYDVR0OBBYEFMv1d+q9sqfM3gXICqoYHSa7GKJMMB8GA1UdIwQY
MBaAFFDWHnoISkfPE/lnoezNAkLPEhxwMA4GA1UdDwEB/wQEAwIHgDAdBgNVHSUE
FjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDAYDVR0TAQH/BAIwADAmBgNVHREEHzAd
ghttYXNxdWUuY2xvdWRmbGFyZWNsaWVudC5jb20wCgYIKoZIzj0EAwMDaAAwZQIw
LS/QI/GHtOvBaf5jYJJtCUrDOITNY0hl7RZMcye4txaJaC2xEs9Nbo673Mku5QLU
AjEAlzppJWKclkTTZLoIBRdbyIZnf0nKnGKEoA0kRh6eChPf2n6csMhL1VOVAz1E
MgOu
-----END CERTIFICATE-----

so same sni, one edge gives a ca chain and the other a self-signed leaf with no chain to check, which is why the server side is just a key pin and the 1.3 CertificateVerify is what proves possession.

on ech i tested it on both carriers. it works for the warp api fine (the general edge publishes cloudflare-ech.com and the api enable goes over ech), but the masque edge itself rejects it: h2 comes back ECH_REJECTED and then the cert check fails, h3 the quic conn closes with crypto_error 0x179 (ech_required). so the masque stack just doesn't do ech for cloudflare-ech.com. the sni doesn't need hiding that way though, the edge picks the backend by ip not by sni, 162.159.198.2 gives the same pinned cert for any sni. so there are two ways to set serverName: keep consumer-masque.cloudflareclient.com like the warp client sends and put finalmask fragment/noise on it, or use any other name like www.cloudflare.com and the masque name never shows up. either way the real tell is the dedicated ip range like Fangliding said.

eth for the nft: 0x20c980AEF36Aa71D0A0e7bE382AeD20b73bC6D27

tutorial i'll put up as a docs pr on Xray-docs-next, masque and wg both with finalmask.

@CluvexStudio

Copy link
Copy Markdown
Contributor Author

@RPRX here's the docs pr :)) XTLS/Xray-docs-next#908

@RPRX

RPRX commented Oct 8, 2026

Copy link
Copy Markdown
Member

eth for the nft: 0x20c980AEF36Aa71D0A0e7bE382AeD20b73bC6D27

0x48d8660fa3eaddc53343624162b3ed8dbdc8081f70e61db6fb2f1a4331874ab3

tutorial i'll put up as a docs pr on Xray-docs-next, masque and wg both with finalmask.

因为总是有人要求 Xray 支持 AWG 然而却不知道 Finalmask 有类似甚至可能更强的能力,之前想让 @Meo597 写,但他没兴趣

@RPRX

RPRX commented Oct 8, 2026

Copy link
Copy Markdown
Member

#6710 这个说的是不是需要改 WG 代码本身?

@CluvexStudio

Copy link
Copy Markdown
Contributor Author

thank you, really appreciate the nft. got the tx hash, it'll show up in the wallet

and yeah that's exactly what i want the tutorial to get across. a lot of people asking for awg don't realize finalmask already does the same kind of obfuscation with fragment and noise and can go further than that. so rather than a separate awg i'll show how finalmask covers it for masque and wg both. glad to be the one writing it <:

@Meo597

Meo597 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

因为总是有人要求 Xray 支持 AWG 然而却不知道 Finalmask 有类似甚至可能更强的能力,之前想让 @Meo597 写,但他没兴趣

作为 end-user pro 我基本只碰自用的地方,否则高低得补一下 xhttp 文档


and yeah that's exactly what i want the tutorial to get across.

RPRX wants a complete FinalMask example under /level-2/, just like /level-2/vless_reverse.md.

@CluvexStudio

Copy link
Copy Markdown
Contributor Author

#6710 这个说的是不是需要改 WG 代码本身?

yeah it needs the wg outbound itself, not finalmask. finalmask only sends separate junk packets and never touches the handshake packet. i tested it against warp, appending random bytes to the init still completes the handshake and data-plane fine, so warp ignores the trailer and the one-way trick does work. it just has to sit in the outbound, gated to the handshake packets so data isn't corrupted, the same bind.Send spot that already writes the reserved bytes. following awg 3.1 there makes sense.

@RPRX

RPRX commented Oct 10, 2026

Copy link
Copy Markdown
Member

@CluvexStudio 还需要把 XMUX 移植进 MASQUE client、禁掉 mux.cool,另外默认 TLS 指纹、HTTP UA 等也需要 reconsider

@CluvexStudio

Copy link
Copy Markdown
Contributor Author

@RPRX done in #7121

@alirezaporamin07-oss

Copy link
Copy Markdown

#6844 (comment)
#6862 (comment)

masque can now connect to cloudflare warp. masqueSettings gets a warp object, filled from the warp registration of the device, like the keys of wireguard

"streamSettings": {
  "method": "masque",
  "masqueSettings": {
    "warp": {
      "privateKey": "MHcCAQEE...",
      "publicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEIaU7MToJm9NKp8YfGxR6r+/h4mcG7SxI8tsW8OR1A5tv/zCzVbCRRh2t87/kxnP6lAy0lkr7qYwu+ox+k3dr6w==",
      "address": ["172.16.0.2/32", "2606:4700:110:8a36::2/128"]
    }
  },
  "security": "tls",
  "tlsSettings": {
    "serverName": "consumer-masque.cloudflareclient.com"
  }
}

-- privateKey the p-256 key of the device, pem or base64, a client cert is made from it
-- publicKey the endpoint key from the registration, the server cert is checked against it so the sni can be anything
-- address the addresses of the device, warp doesnt assign them inside the tunnel
-- http/3 uses cf-connect-ip and the older datagram setting, http/2 a plain connect with bare ip packets, like the warp client. "alpn": ["h2"] picks http/2
-- the device needs warp_enabled on, otherwise the endpoint answers with access denied
-- nothing is requested from cloudflare, the keys come from the registration like with wireguard
-- utls fingerprints send the client cert now too, http/2 needs it

tested in iran on the real network with finalmask noise and fragment: http/3 and http/2 both connect and hold up (warp on, ipv6, udp, parallel downloads, idle). plus tests against a local server that acts like the warp endpoint

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.

7 participants