Skip to content

Minecraft 26.4 - #1913

Draft
WouterGritter wants to merge 18 commits into
dev/4.0.0from
minecraft-26.4
Draft

WouterGritter wants to merge 18 commits into
dev/4.0.0from
minecraft-26.4

Conversation

@WouterGritter

@WouterGritter WouterGritter commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Adds support for 26.4 (-pre-1 as of 25-11-2026).

Protocol changes

  • Compression: SetCompression now only announces the threshold. LoginSuccess carries a new options byte, and compression is switched on around LoginAcknowledged (the last uncompressed packet in both directions).
  • Encryption:
    • Enabled only after hasJoined: proxy sends new ApplyOptions, waits for OptionsApplied, then encrypts. Auth-failure disconnects go out in plaintext.
    • Key exchange is now X25519 + HKDF-SHA256 instead of RSA (new SessionKeyExchange, key pair per login unlike vanilla which reuses one and rotates it every 60 s by default (key-rotation-period-seconds)).
    • EncryptionRequest: salt + X25519 key, no verify token (server id "server" like vanilla)
    • EncryptionResponse: client key + 32-byte HMAC
    • Separate AES key and IV per direction (was shared secret as both, which had issues)
    • hasJoined server id is now a base32hex HMAC digest.
  • JoinGame/Respawn: partialHashedSeed and isDebug were removed.
  • Transfer: gained a Map<String, String> properties field. Backend-initiated transfers now pass it through to the client.
  • Handshake: the host limit was raised to 1024 for 26.4 clients, which can append query properties (host?_o=original:port&_id=...). These are stripped from the virtual host before the forced-host lookup.
  • minecraft:mod_list: 26.4 clients send this right after the brand, once per session. Forwarding it immediately hits ensureConnected() while the initial backend connection was still in flight, which kicked the player. It is now stored on the player, like the brand, and sent to every backend during configuration.
  • Play packets: a new add_entity_motion clientbound packet
  • Commands:
    • Argument-type ids: renumbered alphabetically. brigadier:* became minecraft:*. resource_key and resource_or_tag_key were removed, and pattern was added. string was split into greedy_string, quoted_string and word without properties.
    • Properties:
      • time sends optional min/max bounds instead of only a min.
      • vec2/vec3 gained a bool.
      • loot_table, loot_predicate, loot_modifier, context_float_provider, context_int_provider and slot_source gained a context key set id.
    • Suggestion providers: sent as a varint registry id instead of a string. New minecraft:literal provider carries its own list of suggestions. They now pass through from backend to client, and proxy commands send ask_server.

TODOs / needs deciding

Check all before merging!

  • ProtocolVersion.MINECRAFT_26_4(-1, ..., "26.4") // TODO
  • ClientConfigSessionHandler: any other client plugin message that arrives before the backend connection exists is now dropped with a warning (// TODO: Do we queue this instead?). Previously this threw and disconnected the player. Queueing and flushing once the backend is connected would be friendlier to mods. Related: Route plugin messages to the in-flight connection while no server is connected #1907 does something similar for the play state.
  • Clients now also accept the commands packet during configuration. Velocity doesn't register it there, so a backend sending it in configuration would reach the client without the proxy's commands merged in. Vanilla only sends it in play, where it is still merged. Could cause problems later.
  • With a 26.4 backend and an older client, the debug-world flag is now always false. I think this is fine, but worth noting.
  • Properly test this with older clients/backends
  • Encryption
    • NATIVE ENCRYPTION! (JavaVelocityCipher#withIv -> VelocityCipherFactory + native implementations + rebuild natives)
    • Rebuild MacOS natives
    • Especially scrutinize 2e71237 and 9bd706c, which refactors the encryption flow
    • Encryption tests
    • serverIdHash (LoginEvent/GameProfileRequestEvent) is now the base32hex digest for 26.4 clients, not SHA-1 hex (document this?)
    • (from above) new SessionKeyExchange, key pair per login unlike vanilla which reuses one and rotates it every 60 s by default (key-rotation-period-seconds): do we mirror vanilla's behavior instead?
    • Possibly deprecate the insecure and old VelocityCipherFactory#for[Encryption|Decryption] that do not consume byte[] iv. They would be forever deprecated and in use though, as they are needed for pre-26.4 clients, and any other projects that make use of the velocity-natives module (e.g. @astei's krypton) would have to deal with that too.

Not included

API surface, may be done in later PRs, maybe open issues after PR gets merged (checkboxes)

  • Mod list API: the mod list is stored but not exposed to plugins. Related to Implementing support for minecraft:mod_list #1893.
  • Transfer properties API: plugins can't set or read them yet. Paper has no API for this yet either.
  • Handshake query properties: currently only stripped. Exposing them to plugins and/or forwarding them to backends would be nice.
  • contact field: the server list ping JSON gained an optional contact string, which ServerPing doesn't have yet.
  • pattern argument: passed through as-is, but not exposed as a real argument type for plugins.

@WouterGritter WouterGritter changed the title Minecraft 26.4-snapshot-5 Minecraft 26.4 Oct 23, 2026
@WouterGritter
WouterGritter force-pushed the minecraft-26.4 branch 2 times, most recently from bd2151c to f343a42 Compare October 28, 2026 09:44
@WouterGritter
WouterGritter force-pushed the minecraft-26.4 branch 2 times, most recently from 07df1d7 to 342bb57 Compare November 25, 2026 12:39
@WouterGritter

Copy link
Copy Markdown
Member Author

I had claude rewrite the commit history, splitting each snapshot commit into multiple commits, split by feature/refactor/action. Each batch of snapshot commits results in the same code as before the commit history rewrite of course, but hopefully this will make it easier to review!

@electronicboy electronicboy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of the C changes in 9bd706c (source read only, not compiled or run).

The source looks correct in both backends: EVP_CipherInit and CCCryptorCreateWithMode get the key and IV in the right slots (CommonCrypto takes the IV first), ivLen is checked before the copy into the 16-byte buffer, and moving EVP_CIPHER_CTX_new() after the array copies fixes an existing leak of ctx when the key copy threw. Passing the key as the IV from NativeVelocityCipher keeps the pre-26.4 behaviour.

Before merge:

  • Linux binaries: the six velocity-cipher-*.so files in this commit will need to be rebuilt by a maintainer from the reviewed source rather than merged as-is. These handle every session key, so we can't take contributor-built blobs.
  • macOS dylib: removing it was the right call, since the JNI symbol name is unchanged while the argument list isn't, and a stale binary would treat the jboolean as an array reference and crash the JVM. macOS falls back to the Java cipher until it is rebuilt.

Minor, non-blocking, and predating this commit: jni_cipher_macos.c still reports "openssl initialize cipher" on the CommonCrypto path, and "cipher not 16 bytes" should say "key".

EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
if (ctx == NULL) {
throwException(env, "java/lang/OutOfMemoryError", "allocate cipher");
jsize ivLen = (*env)->GetArrayLength(env, iv);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: GetArrayLength on a null reference crashes the JVM instead of throwing. The only caller never passes null today, but a short null check that throws NullPointerException would be cheap insurance (same in jni_cipher_macos.c, and the same hazard already exists for key).

// If you are using Minecraft in a security-sensitive application, *I don't know what to say.*
int result = EVP_CipherInit(ctx, EVP_aes_128_cfb8(), (byte*) keyBytes, (byte*) keyBytes,
jbyte ivBytes[16];
(*env)->GetByteArrayRegion(env, iv, 0, ivLen, (jbyte*) ivBytes);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: keyBytes and now ivBytes are left on the stack after return. With 26.4 the IV is HKDF-derived, so it may be worth an OPENSSL_cleanse on both before returning (memset_s on the macOS side). Also, the (jbyte*) cast is redundant here since the buffer is already jbyte[].

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