0x01 S01PacketEncryptionRequest
Requests the client to enable encryption by sending the server's RSA public key, a verify token (random challenge), and server ID for Mojang session auth.
Published 2026-06-18 · Updated 2026-10-14
Fields
| Field | Type | Description |
|---|---|---|
| serverId | String | Server ID for Mojang session auth (empty string in 1.8.9) |
| publicKey | byte[] (DER-encoded) | Server's RSA public key for encrypting the shared secret |
| verifyToken | byte[] (4 random bytes) | Random challenge bytes the client must encrypt and return |
Wire Encoding
| Field | Type | Notes |
|---|---|---|
| Server ID | String | Usually empty for auth |
| Public Key Length | VarInt | Length of DER-encoded RSA public key |
| Public Key | byte[] | Server's RSA public key in DER format |
| Verify Token Length | VarInt | Length of verify token |
| Verify Token | byte[] | 4 random bytes for challenge-response |
MCP References
NetHandlerLoginClient.handleEncryptionRequest()Handler Interface
INetHandlerLoginClientNotes
Vanilla Source
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
Deobfuscated MCP 1.8.9 source of S01PacketEncryptionRequest, fetched directly from Marcelektro/MavenMCP-1.8.9 (net/minecraft/network/login/server/S01PacketEncryptionRequest.java) at build time and verified present.
Deep Dive
Role in the protocol
The LOGIN-state RSA challenge. NetHandlerLoginServer sends it once the client has identified itself with C00PacketLoginStart: new S01PacketEncryptionRequest(this.serverId, this.server.getKeyPair().getPublic(), this.field_147330_e). It carries the server's DER-encoded RSA public key, a random 4-byte verify token, and a server id that is empty in 1.8.9 because authentication hashes the key material itself. Receiving it is the client's first proof that the server runs online mode; offline-mode servers skip encryption and go straight to S02PacketLoginSuccess.
Vanilla handling
NetHandlerLoginClient.handleEncryptionRequest generates a fresh AES secret (CryptManager.createNewSharedKey()), computes the server-hash sha1(serverId + DER key + secret) as a hex BigInteger, and calls the session service's joinServer with the profile, token, and hash. On success it replies with C01PacketEncryptionResponse(secret, key, token) and, via the packet's GenericFutureListener, calls networkManager.enableEncryption(secret) so the stream switches to AES/CFB8 on flush. Failure paths close the channel with disconnect.loginFailedInfo variants.
Why clients touch it
No module in the original 8 clients references it; their full corpus for S01PacketEncryptionRequest is vanilla login plumbing: NetHandlerLoginClient, EnumConnectionState registration, INetHandlerLoginClient, the packet class, and NetHandlerLoginServer. LiquidSense Dev breaks that: MixinNetHandlerLoginClient intercepts handleEncryptionRequest and, when an MCLeaks alt session is active, replaces the Mojang session-server join with the mcleaks.net join-server API, then completes the handshake through ClientUtils.sendEncryption. November Recode 2.0 ships the stock handler with no corpus hit, consistent with a vanilla login path.
Exploit surface
The crypto handshake is where session security lives, and it is unauthenticated: 1.8.9 validates neither the certificate chain nor key size, so a MITM proxy that terminates TLS and re-encrypts with its own key can read and rewrite everything, including harvesting the joinServer call. The verify token exists to prove the server holds the private key matching the public key it sent; a proxy must replay it. Server-side, a malicious server can only force a client to do a session-server round trip per join. No client-side abuse is present in the corpus. No client-side abuse is present in the original 8 clients; LiquidSense Dev's MCLeaks integration is the one client-side alteration, substituting the mcleaks.net auth endpoint for the Mojang session server on alt sessions.
Server-Side Handling
NetHandlerLoginServer.func_147326_c runs the handshake: if the server is online-mode and the connection is not already local, it stores the verify token and sends S01PacketEncryptionRequest. The login state has a timeout; a client that never answers with C01PacketEncryptionResponse is dropped by the network read timeout. After processing the response, the server decrypts with its private key, verifies the token, joins the session server with the hashed server id, and only then proceeds to compression and S02PacketLoginSuccess.
Protocol Analysis
Wire layout: String serverId, then VarInt length + RSA public key bytes (X.509 DER), then VarInt length + verify token bytes (4 random bytes). The client's reply C01PacketEncryptionResponse carries the same key and token encrypted with the server's public key plus the AES secret encrypted the same way. Encryption starts after the response flushes, so the first encrypted frame is the next packet after C01. Compression, when enabled, is negotiated separately in login state via S03PacketEnableCompression.
Anti-Cheat Landscape
None. This packet predates world state and is identical for every legitimate client; the only players here are the session server and the Mojang account backend. For cracked servers the whole exchange disappears. The realistic threat model is impersonation of the server (unvalidated public key), which is a network-level problem, not a module-level one.
implementation Implementation Cases
The LOGIN-state encryption challenge. Zero module hits in the original 8 clients; LiquidSense Dev instruments the handshake for MCLeaks alt accounts (MixinNetHandlerLoginClient plus ClientUtils.sendEncryption), and November Recode 2.0 has no corpus hit. Online-mode detection in the other clients is implicit (the packet simply never arrives on cracked servers) and happens in the vanilla handler, not in module code.
Authenticate MCLeaks alt sessions during the login handshake by substituting the mcleaks.net join-server API for the Mojang session server.
@Inject on handleEncryptionRequest HEAD, cancellable, active only when MCLeaks.isAltActive(): generate a fresh AES secret, compute the server hash from serverId + public key + secret, POST {session, mcname, serverhash, server} to https://auth.mcleaks.net/v1/joinserver, close the channel on any failure, and on success call ClientUtils.sendEncryption and cancel the vanilla handler.
// ===== FILE: LiquidSense Dev, net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetHandlerLoginClient.java =====
/*
* LiquidBounce Hacked Client
* A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge.
* https://github.com/CCBlueX/LiquidBounce/
*/
package net.ccbluex.liquidbounce.injection.forge.mixins.network;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import net.ccbluex.liquidbounce.utils.ClientUtils;
import net.mcleaks.MCLeaks;
import net.mcleaks.Session;
import net.minecraft.client.network.NetHandlerLoginClient;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.login.server.S01PacketEncryptionRequest;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.CryptManager;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import javax.crypto.SecretKey;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.PublicKey;
@Mixin(NetHandlerLoginClient.class)
@SideOnly(Side.CLIENT)
public class MixinNetHandlerLoginClient {
@Shadow
@Final
private NetworkManager networkManager;
@Inject(method = "handleEncryptionRequest", at = @At("HEAD"), cancellable = true)
private void handleEncryptionRequest(S01PacketEncryptionRequest packetIn, CallbackInfo callbackInfo) {
if(MCLeaks.isAltActive()) {
final SecretKey secretkey = CryptManager.createNewSharedKey();
String s = packetIn.getServerId();
PublicKey publickey = packetIn.getPublicKey();
String s1 = (new BigInteger(CryptManager.getServerIdHash(s, publickey, secretkey))).toString(16);
final Session session = MCLeaks.getSession();
final String server = ((InetSocketAddress) this.networkManager.getRemoteAddress()).getHostName() + ":" + ((InetSocketAddress) this.networkManager.getRemoteAddress()).getPort();
try {
final String jsonBody = "{\"session\":\"" + session.getToken() + "\",\"mcname\":\"" + session.getUsername() + "\",\"serverhash\":\"" + s1 + "\",\"server\":\"" + server + "\"}";
final HttpURLConnection connection = (HttpURLConnection) new URL("https://auth.mcleaks.net/v1/joinserver").openConnection();
connection.setConnectTimeout(10000);
connection.setReadTimeout(10000);
connection.setRequestMethod("POST");
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0");
connection.setDoOutput(true);
final DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.write(jsonBody.getBytes(StandardCharsets.UTF_8));
outputStream.flush();
outputStream.close();
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
final StringBuilder outputBuilder = new StringBuilder();
String line;
while((line = reader.readLine()) != null)
outputBuilder.append(line);
reader.close();
final JsonElement jsonElement = new Gson().fromJson(outputBuilder.toString(), JsonElement.class);
if(!jsonElement.isJsonObject() || !jsonElement.getAsJsonObject().has("success")) {
this.networkManager.closeChannel(new ChatComponentText("Invalid response from MCLeaks API"));
callbackInfo.cancel();
return;
}
if(!jsonElement.getAsJsonObject().get("success").getAsBoolean()) {
String errorMessage = "Received success=false from MCLeaks API";
if(jsonElement.getAsJsonObject().has("errorMessage"))
errorMessage = jsonElement.getAsJsonObject().get("errorMessage").getAsString();
this.networkManager.closeChannel(new ChatComponentText(errorMessage));
callbackInfo.cancel();
return;
}
}catch(final Exception e) {
this.networkManager.closeChannel(new ChatComponentText("Error whilst contacting MCLeaks API: " + e.toString()));
callbackInfo.cancel();
return;
}
ClientUtils.sendEncryption(networkManager, secretkey, publickey, packetIn);
callbackInfo.cancel();
}
}
}
// NOTE (AI): The mixin only diverts alt sessions; real accounts keep the vanilla joinServer path. The server hash is computed identically to vanilla, and sendEncryption completes the C01 exchange, so the handshake is wire-compatible.
Send the C01PacketEncryptionResponse and enable AES stream encryption after the S01 challenge is handled.
sendEncryption(networkManager, secretKey, publicKey, encryptionRequest) builds C01PacketEncryptionResponse(secretKey, publicKey, encryptionRequest.getVerifyToken()) and sends it with a GenericFutureListener that calls networkManager.enableEncryption(secretKey) on completion, mirroring the vanilla handler's flow.
// ===== FILE: LiquidSense Dev, net/ccbluex/liquidbounce/utils/ClientUtils.java =====
/*
* LiquidBounce Hacked Client
* A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge.
* https://github.com/CCBlueX/LiquidBounce/
*/
package net.ccbluex.liquidbounce.utils;
import com.google.gson.JsonObject;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.login.client.C01PacketEncryptionResponse;
import net.minecraft.network.login.server.S01PacketEncryptionRequest;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.crypto.SecretKey;
import java.lang.reflect.Field;
import java.security.PublicKey;
@SideOnly(Side.CLIENT)
public final class ClientUtils extends MinecraftInstance {
private static final Logger logger = LogManager.getLogger("LiquidBounce");
private static Field fastRenderField;
static {
try {
fastRenderField = GameSettings.class.getDeclaredField("ofFastRender");
if(!fastRenderField.isAccessible())
fastRenderField.setAccessible(true);
}catch(final NoSuchFieldException ignored) {
}
}
public static Logger getLogger() {
return logger;
}
public static void disableFastRender() {
try {
if(fastRenderField != null) {
if(!fastRenderField.isAccessible())
fastRenderField.setAccessible(true);
fastRenderField.setBoolean(mc.gameSettings, false);
}
}catch(final IllegalAccessException ignored) {
}
}
public static void sendEncryption(final NetworkManager networkManager, final SecretKey secretKey, final PublicKey publicKey, final S01PacketEncryptionRequest encryptionRequest) {
networkManager.sendPacket(new C01PacketEncryptionResponse(secretKey, publicKey, encryptionRequest.getVerifyToken()), p_operationComplete_1_ -> networkManager.enableEncryption(secretKey));
}
public static void displayChatMessage(final String message) {
if (mc.thePlayer == null) {
getLogger().info("(MCChat)" + message);
return;
}
final JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("text", message);
mc.thePlayer.addChatMessage(IChatComponent.Serializer.jsonToComponent(jsonObject.toString()));
}
}
// NOTE (AI): sendEncryption mirrors the vanilla enableEncryption-on-flush listener; the mixin path reuses it so the MCLeaks flow and any future callers share one continuation.
anticheat Anti-Cheat Checks
The login encryption challenge is the least instrumented packet in this set: exactly one anticheat references it, and only as packet-library plumbing. Artemis maps SERVER_LOGIN + 2 to PacketLoginOutEncryptionBegin so login-state traffic is typed; no anticheat validates the RSA handshake, because the exchange is identical for every legitimate client and predates world state.
Registers the encryption-request packet in Artemis's packet repository so the login-state stream is typed and readable.
PacketRepository puts SERVER_LOGIN + 2 at PacketLoginOutEncryptionBegin.class and the PacketLoginOutEncryptionBegin interface extends PacketServer. The interface is the full extent of Artemis's interest: no wrapper class and no check subscribes to the packet.
// ===== FILE: artemisac-artemis-minecraft-anticheat, ac.artemis.packet.api/src/main/java/ac/artemis/packet/wrapper/server/PacketLoginOutEncryptionBegin.java =====
package ac.artemis.packet.wrapper.server;
import ac.artemis.packet.wrapper.PacketServer;
public interface PacketLoginOutEncryptionBegin extends PacketServer {
}
// NOTE (AI): This 5-line interface is the only corpus artifact for the encryption request. The repository mapping lives in PacketRepository.java at SERVER_LOGIN + 2.Related Packets
Wiki Cross-Reference
LOGIN id 0x01: String serverId (empty in 1.8.9), VarInt length plus DER RSA public key, then 4-byte verify token challenge.
Client answers with C01 carrying AES secret plus token encrypted under server key, then enables AES/CFB8 stream on flush.
MCP 1.8.9 S01PacketEncryptionRequest implements Packet
1.8.9 callers: NetHandlerLoginServer.processLoginStart sends new S01PacketEncryptionRequest (line 164): https://github.com/Marcelektro/MavenMCP-1.8.9/blob/master/src/main/java/net/minecraft/server/network/NetHandlerLoginServer.java
Cross-checked against minecraft.wiki (CC BY-SA 3.0) for 1.8.9 accuracy.
Vanilla Internals
Full 1.8.9 logic-class sources that send or handle this packet, stored verbatim.