diff --git a/Minecraft.Client/PlayerConnection.cpp b/Minecraft.Client/PlayerConnection.cpp index e7ed9ca1..2803e794 100644 --- a/Minecraft.Client/PlayerConnection.cpp +++ b/Minecraft.Client/PlayerConnection.cpp @@ -59,9 +59,6 @@ #if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD) #include "../Minecraft.Server/ServerLogManager.h" #include "../Minecraft.Server/Access/Access.h" -#include "../Minecraft.Server/Security/IdentityTokenManager.h" -#include "../Minecraft.Server/Security/SecurityConfig.h" -#include "../Minecraft.Server/Security/ConnectionCipher.h" #include "../Minecraft.Server/FourKitBridge.h" extern bool g_Win64DedicatedServer; #endif @@ -119,9 +116,6 @@ PlayerConnection::PlayerConnection(MinecraftServer *server, Connection *connecti m_onlineXUID = INVALID_XUID; m_bHasClientTickedOnce = false; m_logSmallId = 0; - m_identityVerified = false; - m_identityChallengeTick = -1; - m_securityGateOpen = true; // default open; closed when cipher is required // Cache the first valid transport smallId because disconnect teardown can clear it before the server logger runs. if (this->connection != NULL && this->connection->getSocket() != NULL) @@ -982,22 +976,6 @@ void PlayerConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, L"", getWasKicked(), fourKitHandledQuit); } -void PlayerConnection::openSecurityGate() -{ - if (m_securityGateOpen) - return; - - m_securityGateOpen = true; - - // Flush all buffered packets now that the cipher is active - for (auto &buffered : m_securityBuffer) - { - send(buffered); - } - m_securityBuffer.clear(); - m_securityBuffer.shrink_to_fit(); -} - void PlayerConnection::onUnhandledPacket(shared_ptr packet) { // logger.warning(getClass() + " wasn't prepared to deal with a " + packet.getClass()); @@ -1008,39 +986,6 @@ void PlayerConnection::send(shared_ptr packet) { if( connection->getSocket() != nullptr ) { -#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD) - // Security gate: when require-secure-client is enabled, buffer ALL outgoing - // packets until the cipher handshake completes. Only the cipher handshake - // CustomPayloadPacket (MC|CKey) is sent immediately. Once the cipher activates, - // openSecurityGate() flushes the buffer. This prevents unsecured/old clients - // from receiving any game data (PlayerInfoPackets, XUIDs, etc.) before being kicked. - if (!m_securityGateOpen) - { - // Allow cipher handshake packets through immediately - if (packet->getId() == 250) - { - auto cpp = dynamic_pointer_cast(packet); - if (cpp != nullptr && - (cpp->identifier == CustomPayloadPacket::CIPHER_KEY_CHANNEL || - cpp->identifier == CustomPayloadPacket::CIPHER_ACK_CHANNEL || - cpp->identifier == CustomPayloadPacket::CIPHER_ON_CHANNEL)) - { - // Fall through to send - } - else - { - m_securityBuffer.push_back(packet); - return; - } - } - else - { - m_securityBuffer.push_back(packet); - return; - } - } -#endif - if( !server->getPlayers()->canReceiveAllPackets( player ) ) { // Check if we are allowed to send this packet type @@ -3345,44 +3290,6 @@ void PlayerConnection::handlePlayerAbilities(shared_ptr p void PlayerConnection::handleCustomPayload(shared_ptr customPayloadPacket) { -#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD) - // Identity token response from client - if (CustomPayloadPacket::IDENTITY_TOKEN_RESPONSE.compare(customPayloadPacket->identifier) == 0) - { - PlayerUID xuid = m_offlineXUID; - if (xuid == INVALID_XUID) xuid = m_onlineXUID; - - bool tokenValid = false; - if (customPayloadPacket->length == ServerRuntime::Security::IdentityTokenManager::TOKEN_SIZE && - customPayloadPacket->data.length == ServerRuntime::Security::IdentityTokenManager::TOKEN_SIZE && - customPayloadPacket->data.data != nullptr) - { - tokenValid = ServerRuntime::Security::GetIdentityTokenManager().VerifyToken(xuid, customPayloadPacket->data.data); - } - - if (tokenValid) - { - m_identityVerified = true; - app.DebugPrintf("SECURITY: Identity token verified for player %ls\n", player->getName().c_str()); - INetworkPlayer *npLog = getNetworkPlayer(); - if (npLog != nullptr) - ServerRuntime::ServerLogManager::OnIdentityTokenVerified(npLog->GetSmallId()); - } - else - { - app.DebugPrintf("SECURITY: Identity token MISMATCH for player %ls - will disconnect\n", player->getName().c_str()); - app.DebugPrintf("SECURITY: If this player lost their token, use: revoketoken %ls\n", player->getName().c_str()); - INetworkPlayer *npLog = getNetworkPlayer(); - if (npLog != nullptr) - ServerRuntime::ServerLogManager::OnIdentityTokenMismatch(npLog->GetSmallId(), player->getName()); - // Defer disconnect to avoid re-entrancy issues during packet dispatch - setWasKicked(); - closeOnTick(); - } - return; - } -#endif - if (CustomPayloadPacket::CUSTOM_BOOK_PACKET.compare(customPayloadPacket->identifier) == 0) { ByteArrayInputStream bais(customPayloadPacket->data); diff --git a/Minecraft.Client/PlayerConnection.h b/Minecraft.Client/PlayerConnection.h index 2ea1d36e..04b8cd01 100644 --- a/Minecraft.Client/PlayerConnection.h +++ b/Minecraft.Client/PlayerConnection.h @@ -142,21 +142,6 @@ public: // 4J Added bool hasClientTickedOnce() { return m_bHasClientTickedOnce; } - // Identity token verification state (accessed from both recv and main threads) - std::atomic m_identityVerified; - std::atomic m_identityChallengeTick; - - // Security gate: buffer packets until cipher handshake completes - bool m_securityGateOpen; - vector> m_securityBuffer; - - bool isIdentityVerified() const { return m_identityVerified; } - int getIdentityChallengeTick() const { return m_identityChallengeTick; } - void setIdentityChallengeTick(int tick) { m_identityChallengeTick = tick; } - void setIdentityVerified(bool v) { m_identityVerified = v; } - bool isSecurityGateOpen() const { return m_securityGateOpen; } - void openSecurityGate(); - private: bool m_bCloseOnTick; vector m_texturesRequested; diff --git a/Minecraft.Server/Console/ServerCliEngine.cpp b/Minecraft.Server/Console/ServerCliEngine.cpp index 037c7a8c..2196ff67 100644 --- a/Minecraft.Server/Console/ServerCliEngine.cpp +++ b/Minecraft.Server/Console/ServerCliEngine.cpp @@ -23,7 +23,6 @@ #include "commands/tp/CliCommandTp.h" #include "commands/weather/CliCommandWeather.h" #include "commands/whitelist/CliCommandWhitelist.h" -#include "commands/revoketoken/CliCommandRevokeToken.h" #include "../Common/StringUtils.h" #include "../ServerShutdown.h" #include "../ServerLogger.h" @@ -102,7 +101,6 @@ namespace ServerRuntime m_registry->Register(std::unique_ptr(new CliCommandPardonIp())); m_registry->Register(std::unique_ptr(new CliCommandBanList())); m_registry->Register(std::unique_ptr(new CliCommandWhitelist())); - m_registry->Register(std::unique_ptr(new CliCommandRevokeToken())); m_registry->Register(std::unique_ptr(new CliCommandTp())); m_registry->Register(std::unique_ptr(new CliCommandTime())); m_registry->Register(std::unique_ptr(new CliCommandWeather())); diff --git a/Minecraft.Server/Console/commands/revoketoken/CliCommandRevokeToken.cpp b/Minecraft.Server/Console/commands/revoketoken/CliCommandRevokeToken.cpp deleted file mode 100644 index 81537c38..00000000 --- a/Minecraft.Server/Console/commands/revoketoken/CliCommandRevokeToken.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "stdafx.h" - -#include "CliCommandRevokeToken.h" - -#include "../../ServerCliEngine.h" -#include "../../ServerCliParser.h" -#include "../../../Access/Access.h" -#include "../../../Security/IdentityTokenManager.h" -#include "../../../ServerLogManager.h" - -namespace ServerRuntime -{ - const char *CliCommandRevokeToken::Name() const - { - return "revoketoken"; - } - - const char *CliCommandRevokeToken::Usage() const - { - return "revoketoken "; - } - - const char *CliCommandRevokeToken::Description() const - { - return "Revoke a player's identity token. They will be issued a new one on next login."; - } - - bool CliCommandRevokeToken::Execute(const ServerCliParsedLine &line, ServerCliEngine *engine) - { - if (line.tokens.size() < 2) - { - engine->LogWarn(std::string("Usage: ") + Usage()); - return false; - } - - PlayerUID xuid = INVALID_XUID; - - // Try parsing as XUID first - if (ServerRuntime::Access::TryParseXuid(line.tokens[1], &xuid)) - { - // Direct XUID - } - else - { - // Try name lookup from cache - std::vector cachedXuids; - int count = ServerRuntime::ServerLogManager::GetCachedXuids(line.tokens[1], &cachedXuids); - if (count == 0) - { - engine->LogWarn("Unknown player: " + line.tokens[1]); - engine->LogWarn("The player must have attempted to connect, or use: revoketoken "); - return false; - } - if (count > 1) - { - engine->LogWarn("Ambiguous: " + std::to_string(count) + " XUIDs seen for '" + line.tokens[1] + "':"); - for (size_t i = 0; i < cachedXuids.size(); ++i) - { - std::string label = (i == cachedXuids.size() - 1) ? " (most recent)" : ""; - engine->LogWarn(" " + ServerRuntime::Access::FormatXuid(cachedXuids[i]) + label); - } - engine->LogWarn("Re-run with the explicit XUID: revoketoken "); - return false; - } - xuid = cachedXuids.back(); - engine->LogInfo("Resolved '" + line.tokens[1] + "' to XUID " + ServerRuntime::Access::FormatXuid(xuid)); - } - - if (!ServerRuntime::Security::GetIdentityTokenManager().HasToken(xuid)) - { - engine->LogWarn("No identity token found for XUID " + ServerRuntime::Access::FormatXuid(xuid)); - return false; - } - - if (!ServerRuntime::Security::GetIdentityTokenManager().RevokeToken(xuid)) - { - engine->LogError("Failed to revoke token."); - return false; - } - - engine->LogInfo("Revoked identity token for XUID " + ServerRuntime::Access::FormatXuid(xuid) + - ". Player will receive a new token on next login."); - return true; - } -} diff --git a/Minecraft.Server/Console/commands/revoketoken/CliCommandRevokeToken.h b/Minecraft.Server/Console/commands/revoketoken/CliCommandRevokeToken.h deleted file mode 100644 index 89cf7ad1..00000000 --- a/Minecraft.Server/Console/commands/revoketoken/CliCommandRevokeToken.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "..\IServerCliCommand.h" - -namespace ServerRuntime -{ - class CliCommandRevokeToken : public IServerCliCommand - { - public: - virtual const char *Name() const; - virtual const char *Usage() const; - virtual const char *Description() const; - virtual bool Execute(const ServerCliParsedLine &line, ServerCliEngine *engine); - }; -} diff --git a/Minecraft.Server/cmake/sources/Common.cmake b/Minecraft.Server/cmake/sources/Common.cmake index dfd816c5..e4a4d363 100644 --- a/Minecraft.Server/cmake/sources/Common.cmake +++ b/Minecraft.Server/cmake/sources/Common.cmake @@ -695,8 +695,6 @@ set(_MINECRAFT_SERVER_COMMON_SERVER_CONSOLE_COMMANDS "${_MS_SRC}/Console/commands/weather/CliCommandWeather.h" "${_MS_SRC}/Console/commands/whitelist/CliCommandWhitelist.cpp" "${_MS_SRC}/Console/commands/whitelist/CliCommandWhitelist.h" - "${_MS_SRC}/Console/commands/revoketoken/CliCommandRevokeToken.cpp" - "${_MS_SRC}/Console/commands/revoketoken/CliCommandRevokeToken.h" ) source_group("Server/Console/Commands" FILES ${_MINECRAFT_SERVER_COMMON_SERVER_CONSOLE_COMMANDS})