Repository navigation
Minecraft 26.4 - #1913
Minecraft 26.4#1913WouterGritter wants to merge 24 commits into
Conversation
bd2151c to
f343a42
Compare
f343a42 to
ba8e876
Compare
342bb57 to
685e3ec
Compare
|
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
left a comment
There was a problem hiding this comment.
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-*.sofiles 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
jbooleanas 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".
| * | ||
| * @return the payload, or {@code null} if the client didn't send one | ||
| */ | ||
| byte @Nullable [] getClientModList() { |
There was a problem hiding this comment.
Name could clash with a future API PR that exposes this in a more useful format to plugins. But this method is internal so meh, we can always rename this then.
Addresses review feedback from #1913: - Throw NullPointerException for a null key or IV instead of crashing the JVM in GetArrayLength. - Wipe the key and IV stack buffers before returning on every path (OPENSSL_cleanse on OpenSSL, memset_s on CommonCrypto). - Drop redundant (jbyte*) casts. - Fix error messages: "cipher not 16 bytes" -> "key not 16 bytes", and the CommonCrypto path no longer claims to be OpenSSL. - Test the native argument checks directly. TODO: Rebuild macOS natives.
* Native encryption support for 26.4+ with tests Partial cherry-pick of the native/ changes from the minecraft-26.4 branch (PR #1913), without the proxy-side 26.4 protocol changes: - 2e71237 26.4-snapshot-9..10: Replace RSA login encryption with X25519 key exchange (JavaVelocityCipher only) - 9bd706c Native encryption support for 26.4+ with tests (TODO: rebuild macos natives) - 38b0266 Build natives for macOS - 5b59096 Remove .gitkeep after macos natives have been rebuilt * Harden native cipher init and rebuild Linux natives Addresses review feedback from #1913: - Throw NullPointerException for a null key or IV instead of crashing the JVM in GetArrayLength. - Wipe the key and IV stack buffers before returning on every path (OPENSSL_cleanse on OpenSSL, memset_s on CommonCrypto). - Drop redundant (jbyte*) casts. - Fix error messages: "cipher not 16 bytes" -> "key not 16 bytes", and the CommonCrypto path no longer claims to be OpenSSL. - Test the native argument checks directly. TODO: Rebuild macOS natives. * Rebuild macOS cipher native from hardened source Rebuilds velocity-cipher.dylib for macOS arm64 from the hardened jni_cipher_macos.c (deployment target 27.0, matching the previous dylib) and removes the placeholder .gitkeep. * Rename IV-less cipher factory methods to *Insecure Deprecate forEncryption(key) and forDecryption(key) in favor of forEncryptionInsecure(key) and forDecryptionInsecure(key), which behave identically but make the insecure key-as-IV mode explicit at every call site. The two-argument methods no longer accept a null IV. Velocity switches to the *Insecure methods, as Minecraft 26.3 and older still require the key-as-IV mode. --------- Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
5b59096 to
dfc0ac2
Compare
| private static final SecureRandom SECURE_RANDOM = new SecureRandom(); | ||
| // the server id in the 26.4+ key packet, which is also side A's name in the key derivation | ||
| // (vanilla uses "server") | ||
| private static final String KEY_EXCHANGE_SERVER_ID = "server"; |
There was a problem hiding this comment.
The client doesn't do anything with this except echoing whatever we send, it never exposes it anywhere.
Would it make sense to instead reply with "proxy" or maybe even "velocity"? The only tangible "benefit"/behavior change would be that a mod could then identify any velocity server as one, by reading this value.
…ing and greedy_string
…figures The client only sends its brand and mod list once, so replay them to each new backend connection. Not when the current backend reconfigures: it already has them, and 26.4+ servers disconnect the player when the brand or a mod property is sent a second time.
… of against itself
8e9c0de to
031ddf8
Compare
|
Tested & confirmed working on 26.4-rc-1 |
Adds support for 26.4.
Protocol changes
SetCompressionnow only announces the threshold.LoginSuccesscarries a new options byte, and compression is switched on aroundLoginAcknowledged(the last uncompressed packet in both directions).hasJoined: proxy sends newApplyOptions, waits forOptionsApplied, then encrypts. Auth-failure disconnects go out in plaintext.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 HMAChasJoinedserver id is now a base32hex HMAC digest.partialHashedSeedandisDebugwere removed.Map<String, String>properties field. Backend-initiated transfers now pass it through to the client.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 hitsensureConnected()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.add_entity_motionclientbound packetbrigadier:*becameminecraft:*.resource_keyandresource_or_tag_keywere removed, andpatternwas added.stringwas split intogreedy_string,quoted_stringandwordwithout properties.timesends optional min/max bounds instead of only a min.vec2/vec3gained a bool.loot_table,loot_predicate,loot_modifier,context_float_provider,context_int_providerandslot_sourcegained a context key set id.minecraft:literalprovider carries its own list of suggestions. They now pass through from backend to client, and proxy commands sendask_server.TODOs / needs deciding
Check all before merging!
ProtocolVersion.MINECRAFT_26_4(-1, ..., "26.4") // TODOJavaVelocityCipher#withIv->VelocityCipherFactory+ native implementations + rebuild natives)9bd706cNative encryption support for 26.4+ with tests #1928, which refactor the encryption flow and update/clean up the natives accordinglyserverIdHash(LoginEvent/GameProfileRequestEvent) is now the base32hex digest for 26.4 clients, not SHA-1 hex (document this?)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? -> No, costs nothing and this is more secure.VelocityCipherFactory#for[Encryption|Decryption]that do not consumebyte[] 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 thevelocity-nativesmodule (e.g. @astei's krypton) would have to deal with that too. -> handled in ecd4d31velocity-native.Not included
API surface, may be done in later PRs, maybe open issues after PR gets merged.
contactfield: the server list ping JSON gained an optionalcontactstring, whichServerPingdoesn't have yet. Issue opened (Server list ping contact field #1931)patternargument: passed through as-is, but not exposed as a real argument type for plugins.ClientConfigSessionHandler: any other client plugin message that arrives before the backend connection exists is now dropped with a warning. 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._o: 26.4 clients that resolved an SRV record send the SRV target as the host and the address the player typed in the_oquery property. Forced hosts could match on_oinstead of the SRV target.