Skip to content

feat: add sudoku protocol - #3658

Closed
saba-futai wants to merge 91 commits into
SagerNet:dev-nextfrom
SUDOKU-ASCII:feat/sudoku
Closed

saba-futai wants to merge 91 commits into
SagerNet:dev-nextfrom
SUDOKU-ASCII:feat/sudoku

Conversation

@saba-futai

Copy link
Copy Markdown

A basic description of Sudoku has already been provided in the README and documentation of the sudoku repository.
Its primary feature is the ability to customize various low-entropy byte formats, with the option to map them to printable ASCII characters (both uppercase and lowercase). It allows for the insertion of arbitrary redundant bytes at random positions. Specifically, these are "spam" bytes regarding Sudoku (meaning they do not constitute a valid Sudoku grid or compromise the uniqueness of the solution), but they serve to alter the packet length distribution.
Since the GFW tends to be lenient towards plaintext information, these low-entropy, printable bytes are typically allowed to pass. Furthermore, for enhanced camouflage, Sudoku introduces httpmask to incorporate various HTTP characteristics. As a result, Wireshark identifies the packets directly as HTTP traffic, which further facilitates passage through the GFW.

Zephyruso and others added 30 commits December 25, 2025 14:48
We mistakenly believed that `libresolv`'s `search` function worked correctly in NetworkExtension, but it seems only `getaddrinfo` does.

This commit changes the behavior of the `local` DNS server in NetworkExtension to prefer DHCP, falling back to `getaddrinfo` if DHCP servers are unavailable.

It's worth noting that `prefer_go` does not disable DHCP since it respects Dial Fields, but `getaddrinfo` does the opposite. The new behavior only applies to NetworkExtension, not to all scenarios (primarily command-line binaries) as it did previously.

In addition, this commit also improves the DHCP DNS server to use the same robust query logic as `local`.
We do not have the `com.apple.developer.networking.multicast` entitlement and are unable to obtain it for non-technical reasons.
@nekohasekai

Copy link
Copy Markdown
Member

Similar to mieru's question: What are its real-world applications?

If anti-censorship is its only feature, you need to prove it's truly effective.

@saba-futai

Copy link
Copy Markdown
Author

@nekohasekai Thanks for the follow-up (and +1 to the “what’s the real-world value” question).

Real‑world application (concrete, not theoretical):
Sudoku is specifically a censorship/DPI-oriented transport/obfuscation layer for situations where “random‑looking encrypted proxy traffic” (i.e. high-entropy payloads) is treated as suspicious and is throttled/blocked, while “plaintext‑looking” flows are more tolerated.

This isn’t a “general purpose faster/better TLS replacement”; it targets a different threat model:

  • Make the first payload(s) look like plaintext / low‑entropy, so the flow is more likely to be classified as “not fully encrypted traffic”.
  • Add active‑probing resistance via defensive fallback instead of hard-failing on malformed probes.
  • Allow per-user/per-connection diversity (custom layouts / rotation) to avoid a single global fingerprint.

You can see this is used as an actual end‑user proxy stack (not just a paper protocol):

“If anti‑censorship is the only feature, prove it’s truly effective.”
You can’t mathematically prove long-term effectiveness against an adaptive censor, but you can demonstrate that Sudoku directly targets the currently documented/measured GFW-style heuristics rather than hand-wavy “it’s obfuscated so it must work”.

The design rationale is explicitly grounded in the published GFW measurements from the GFW Report / USENIX Security paper:

The inferred exemption rules in that paper include (paraphrased):

  • Ex1: average popcount/byte <= 3.4 OR >= 4.6 → exempt
  • Ex2/Ex3/Ex4: printable ASCII in the first packet (first 6 bytes printable OR >50% printable OR >20 contiguous printable) → exempt
  • Ex5: matches HTTP/TLS fingerprint → exempt

Now map that 1:1 to Sudoku’s documented behavior in its README:

  • Sudoku can emit printable ASCII (ASCII‑preferred mode) and/or low‑entropy bytes (ENTROPY‑preferred mode), instead of “random noise”:
    https://github.com/SUDOKU-ASCII/sudoku
    • It documents 65%–100% ASCII ratio depending on mode, and Hamming weight ~3.0 in low‑entropy mode (i.e. intentionally outside the [3.4, 4.6] “censorship band” described in the GFW paper).
  • Sudoku also adds dynamic padding where padding bytes are chosen to match the plaintext distribution (so padding itself doesn’t trivially stick out), and inserted at arbitrary times/positions.
  • For “look like real web traffic”, Sudoku provides httpmask (including CDN/HTTPS-oriented modes like auto/stream/poll), so the flow can present HTTP characteristics (aligning with the GFW paper’s Ex5 “HTTP/TLS fingerprint” exemption). See README section on http_mask_mode / http_mask_tls.

Active probing resistance (not just passive “looks like plaintext”):
Sudoku also implements a defensive fallback: on illegal handshake / malformed packets it can forward to a decoy web server instead of immediately dropping, so naive probes just see a normal HTTP service:

Why this PR is meaningful in sing-box specifically:
Mihomo already has Sudoku support; adding it to sing-box gives users a second core implementation and improves ecosystem diversity. That matters for censorship resistance (single-implementation monoculture is easier to fingerprint and target), and it’s the same logic behind supporting multiple transports in sing-box.

@nekohasekai

Copy link
Copy Markdown
Member

This is the effect you're claiming (and it looks like it's AI-generated), you need to prove it.

@nekohasekai

Copy link
Copy Markdown
Member

As far as I know, those so-called exemption rules expired a few months after the paper was published.

@saba-futai

saba-futai commented Jan 1, 2026 •

Copy link
Copy Markdown
Author

Yes, I wrote the comment in Chinese and had AI translate them into English and polish them to sound polite. My protocol considers that most existing protocols are TLS-oriented, so I want to create a secure, non-random, non-TLS protocol. If you insist that I prove this will not be blocked by the GFW, I honestly can't do that. However, under the current GFW rules (which still operate as a black box),for sudoku, there have been no reported cases of blocking after long-term use by multiple people. Perhaps my greatest confidence lies in the obfuscation demonstrated in the mathematical aspects of the core code. Therefore, I will not give up on promoting this protocol


Or are you saying that you need me to write a paper that thoroughly explains the underlying mathematical principles of this protocol? (Although anyone can analyze the principles and see that its feasibility is valid, there just aren't that many people willing to review the code to understand the underlying operational logic.)

@nekohasekai

Copy link
Copy Markdown
Member

Anyone can use AI to generate protocols that theoretically disrupt some kind of analysis. Perhaps you could try sending a PR to Xray; they also like creating protocols without evidence of their validity.

@saba-futai

saba-futai commented Jan 1, 2026 •

Copy link
Copy Markdown
Author

You misunderstood my meaning. I only said that the comment was polished by AI; the agreement is a product created entirely from scratch by my own human brain.


some prove
Entropy bound (payload‑independent)
Let Σ be the set of byte values that appear in those tokens (plus the padding pool). Regardless of what you tunnel (even AEAD ciphertext), on‑wire bytes live in Σ, so per‑byte Shannon entropy is upper‑bounded by log2|Σ|. That’s the point: AEAD provides confidentiality/integrity, while the obfs layer forces the wire representation away from “random‑looking ciphertext”.
Tunable byte‑level stats aimed at cheap classifiers
The upstream table generation supports prefer_ascii (printable‑ASCII heavy) and prefer_entropy (lower Hamming weight). Baseline numbers for uniform random bytes: printable ASCII ratio is ~95/256 ≈ 37%, and expected popcount is 4. The upstream docs quote that Sudoku can push printable ratio to ~65–100% and average Hamming weight down to ~3.0 (and they cite ~3.4–4.6 as a typical trigger band used by entropy‑based filtering). That’s a measurable shift in exactly the metrics those heuristics use.
Network‑wise it’s also not “only sudoku bytes”: the handshake is layered (HTTP mask → Sudoku obfs → AEAD → protocol fields), and HTTP mask has legacy/stream/poll/auto modes plus optional TLS so it can traverse strict HTTP(S) environments / CDN forwarding. PaddingMin/Max (0–100%) lets you perturb packet sizes without breaking decode.
So yes: the real‑world application is censorship / constrained networks. What I can’t honestly claim is “it beats every censor forever”. What I can claim (and you can verify with a pcap) is: the transform guarantees bounded/tunable on‑wire entropy/printability/popcount by construction, plus padding to avoid fixed length fingerprints, and an HTTP front layer for restrictive environments.


some related math calc:
SUDOKU-ASCII/sudoku#5 (comment)

@nekohasekai

nekohasekai commented Jan 1, 2026 •

Copy link
Copy Markdown
Member

To the best of my knowledge, the low-entropy censorship mitigation methods described in the paper have failed. In other words, there is currently no evidence that any low-entropy protocol can function effectively in a censorship environment. This is even worse than unproven TLS-in-TLS mitigation schemes, because while TLS-in-TLS might work, your protocol may be useless anywhere else.

@saba-futai

saba-futai commented Jan 1, 2026 •

Copy link
Copy Markdown
Author

Perhaps I can predict: the Sudoku protocol may not be a good protocol, nor has it been tested by history. However, some of its ideas, such as byte appearance restructuring and non-random number mapping, may be seen reflected in subsequent 'good protocols'

@saba-futai saba-futai closed this Jan 1, 2026
@RememberOurPromise

Copy link
Copy Markdown

your protocol may be useless anywhere else.

GFW的供应商积至公司的TSG天狗安全网关中采用了Qosmos ixEngine作为第三方插件。
Enea Qosmos ixEngine 是全球网络安全和电信行业中最顶尖的深度数据包检测(DPI)引擎。

"description": "High Entropy is a virtual protocol used to detect potentially encrypted payloads. Important note: the classification of this layer is effective since the 4.18.0 version of the ixEngine framework. The classification is based on two methods: entropy value computation, and printable strings detection. This concerns only unknown sessions over TCP and UDP."

可见并非"useless anywhere else",如此评价过于武断。

@saba-futai

Copy link
Copy Markdown
Author

Thank you for helping me speak. I was just about to ask 世界 how he can prove that the protocols already in the sing-box are proven.

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.

6 participants