Harden RP Spoofer detector: Stage A->B->C ordering, Corrupt pack.mcmeta honeypot, and Control-Bitmap sanitizer trap

This commit is contained in:
notme_ssa committed 2026-11-29 21:47:17 +07:00
1 parent 80436bbb5a
commit 90523b050e
4 files changed
+160 -20

No files matched your search

+6 -6
View File
@@ -29,12 +29,12 @@
- **Phase 1**: 1.20.6 vanilla edge keys (`item.minecraft.mace`) + nested mod `translate`/`keybind` inside `chat.type.text` `with` arguments.
- **Phase 2**: pushes a temporary server resource pack overriding mod keys (`key.meteor-client.open-gui`, `category.meteor-client`) and placing custom keys inside mod namespaces (`assets/meteor-client/lang/`, `assets/opsec/lang/`).
- **Phase 3**: calls `removeResourcePack`, waits 80 ticks (4s) for clean client reload, and verifies cache eviction.
- **4-Layer Resource-Pack Spoofer Detector (`ResourcePackSpoofDetector`)**:
- Catches server resource-pack bypass/spoofer mods (Meteor `ServerSpoof`, Wurst/LiquidBounce `ResourcePackSpoof`, `NoServerPack`, fake-accept & download-and-discard mods):
1. **Bad-SHA1 Honeypot Pack**: sends a tiny pack with inverted SHA-1 (Vanilla rejects with `FAILED_DOWNLOAD` and zero reload screen; spoofers blindly reply `SUCCESSFULLY_LOADED`).
2. **Zero-Fetch HTTP Verification**: flags clients claiming `DOWNLOADED`/`SUCCESSFULLY_LOADED` on a `no-store` one-time URL without ever hitting `ProbeHttpServer`.
3. **State-Machine & Timing Verification**: validates `ACCEPTED -> DOWNLOADED -> SUCCESSFULLY_LOADED` order (1.20.3+) and flags instantaneous `<15ms` reloads.
4. **Cryptographic Proof-of-Apply Sign Probe**: verifies via one-time secret translation key embedded in the pack that the client actually loaded it into `LanguageManager`.
- **Multi-Layer Resource-Pack Spoofer Detector (`ResourcePackSpoofDetector` & `AssetProbeListener`)**:
- Catches both packet-only spoofers (Meteor `ServerSpoof`, Wurst/LiquidBounce `ResourcePackSpoof`, `NoServerPack`) and smart font/reload sanitizers:
1. **Stage A — Bad-SHA1 Honeypot Pack**: inverted SHA-1 (Vanilla rejects with `FAILED_DOWNLOAD` and zero reload screen; spoofers blindly reply `SUCCESSFULLY_LOADED`).
2. **Stage B — Zero-Fetch HTTP + State/Timing + Cryptographic Sign Proof-of-Apply**: `no-store` one-time URL, strict 1.20.3+ `ACCEPTED -> DOWNLOADED -> SUCCESSFULLY_LOADED` order, `<15ms` reload check, and one-time secret translation key verification (`RP_OK_<secret>`).
3. **Stage C — Corrupt `pack.mcmeta` Honeypot**: valid-SHA1 ZIP with malformed `pack.mcmeta` JSON (Vanilla always returns `FAILED_RELOAD`; spoofers faking success get flagged).
4. **Control-Bitmap Sanitizer Trap (`AssetProbeListener`)**: randomized missing bitmap `antispoof_missing_<nonce>:nope.png` in `font/default.json` — on 1.20.5+, returning `SUCCESSFULLY_LOADED` flags `RESOURCE_PACK_SPOOF` directly.
- **Differential Bitmap Font Asset Probe (`AssetProbeListener` & `AssetProbeLabManager`)**:
- Config-driven `TEXTURES`, `FONT`, and `CORRUPTION` resource-pack rules (`asset-probe.rules`) with automatic A/B control pack verification (`FAILED_RELOAD` on guaranteed missing asset vs `SUCCESSFULLY_LOADED` on real mod texture paths like `meteor-client:meteor.png`).
- Works directly through `FontManager` / `ResourceManager`, detecting modded clients even when OpSec Key Spoof is active.
@@ -88,11 +88,12 @@ public final class AssetProbeListener implements Listener {
}
List<QueuedPack> queue = new ArrayList<>();
String ctrlNonce = TranslationProbeManager.generateNonce();
if (hasTextures) {
queue.add(new QueuedPack(null, AssetCheckType.TEXTURES, true, CONTROL_MISSING_BITMAP));
queue.add(new QueuedPack(null, AssetCheckType.TEXTURES, true, "antispoof_missing_" + ctrlNonce + ":nope.png"));
}
if (hasFont) {
queue.add(new QueuedPack(null, AssetCheckType.FONT, true, CONTROL_MISSING_TTF));
queue.add(new QueuedPack(null, AssetCheckType.FONT, true, "antispoof_missing_" + ctrlNonce + ":nope.ttf"));
}
for (AssetProbeRule rule : enabled) {
queue.add(new QueuedPack(rule, rule.getCheckType(), false, rule.getTargetPath()));
@@ -196,6 +197,15 @@ public final class AssetProbeListener implements Listener {
if (item.control()) {
if (item.checkType() == AssetCheckType.TEXTURES) {
session.bitmapControlStatus = status.name();
// On 1.20.5+ (protocol >= 766), a missing bitmap in font/default.json MUST return FAILED_RELOAD.
// Returning SUCCESSFULLY_LOADED proves a Resource-Pack Spoofer / Font-Sanitizer intercepted the pack!
if (status == PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED && isModernFontStrictProtocol(player)) {
String reason = "Impossible SUCCESSFULLY_LOADED on missing-bitmap control pack ("
+ item.targetPath() + ") — Resource-Pack Spoofer / Anti-Probe sanitizer detected";
plugin.getLogger().warning("[AssetProbe:SPOOF] " + player.getName() + " -> " + reason);
plugin.getPlayerLogManager().log(player, LogType.FLAG, "[AssetProbe:SPOOF] " + reason);
plugin.flagPlayer(player, ViolationType.RESOURCE_PACK_SPOOF, reason);
}
} else if (item.checkType() == AssetCheckType.FONT) {
session.fontControlStatus = status.name();
}
@@ -312,6 +322,15 @@ public final class AssetProbeListener implements Listener {
activeSessions.clear();
}
private static boolean isModernFontStrictProtocol(Player player) {
try {
// 1.20.5 = protocol 766
return player.getProtocolVersion() >= 766;
} catch (Throwable ignored) {
return true;
}
}
private static String escapeJson(String s) {
if (s == null) return "";
return s.replace("\\", "\\\\").replace("\"", "\\\"");
@@ -75,6 +75,7 @@ public final class ResourcePackSpoofDetector extends PacketListenerAbstract impl
STAGE_A_HONEYPOT,
STAGE_B_WAIT_PACK,
STAGE_B_SIGN_PROOF,
STAGE_C_CORRUPT_MCMETA,
DONE
}
@@ -95,6 +96,11 @@ public final class ResourcePackSpoofDetector extends PacketListenerAbstract impl
volatile boolean honeypotSawAccepted;
volatile long honeypotSentMs;
// Stage A2 (Corrupt pack.mcmeta Honeypot — catches FAILED_RELOAD -> SUCCESSFULLY_LOADED spoofers)
volatile UUID corruptMetaPackId;
volatile String corruptMetaToken;
volatile long corruptMetaSentMs;
// Stage B (Proof-of-Apply)
volatile UUID verifyPackId;
volatile String verifyToken;
@@ -210,7 +216,7 @@ public final class ResourcePackSpoofDetector extends PacketListenerAbstract impl
player.addResourcePack(s.honeypotPackId, url, badSha1, null, required);
} catch (Throwable t) {
plugin.getLogger().warning("[RPSpoof:StageA] addResourcePack error: " + t.getMessage());
advanceFromStageA(player, s);
advanceFromStageA(player, s, false);
}
});
@@ -220,15 +226,15 @@ public final class ResourcePackSpoofDetector extends PacketListenerAbstract impl
boolean fetched = httpServer.wasFetched(s.honeypotToken);
plugin.getLogger().info("[RPSpoof:StageA] Honeypot timed out for " + player.getName()
+ " (accepted=" + s.honeypotSawAccepted + ", httpFetched=" + fetched + ")");
advanceFromStageA(player, s);
advanceFromStageA(player, s, false);
}
}, 120L); // 6s max
}
private void advanceFromStageA(Player player, SpoofSession s) {
private void advanceFromStageA(Player player, SpoofSession s, boolean wasLoadedBySpoofer) {
SchedulerUtil.cancelQuietly(s.stageTimeoutTask);
// Clean up honeypot pack ID just in case a spoofer claimed it loaded
if (s.honeypotPackId != null && player.isOnline()) {
// Only send removeResourcePack if a spoofer falsely claimed it loaded (never on FAILED_DOWNLOAD)
if (wasLoadedBySpoofer && s.honeypotPackId != null && player.isOnline()) {
try {
player.removeResourcePack(s.honeypotPackId);
} catch (Throwable ignored) {
@@ -241,7 +247,72 @@ public final class ResourcePackSpoofDetector extends PacketListenerAbstract impl
}
}, 6L);
} else {
finalizeSession(player, s);
SchedulerUtil.runEntityDelayed(plugin, player, () -> {
if (player.isOnline() && sessions.get(s.playerId) == s) {
startStageCCorruptMcmeta(player, s);
}
}, 6L);
}
}
// =========================================================================
// STAGE C: Valid-SHA1 ZIP with Malformed pack.mcmeta (runs AFTER Stage B so rollback never races Stage B!)
// =========================================================================
private void startStageCCorruptMcmeta(Player player, SpoofSession s) {
s.stage = Stage.STAGE_C_CORRUPT_MCMETA;
s.corruptMetaPackId = UUID.randomUUID();
s.corruptMetaToken = "rphoney-meta-" + s.nonce + ".zip";
s.corruptMetaSentMs = System.currentTimeMillis();
byte[] zip = buildCorruptMcmetaZip(s.nonce);
byte[] sha1 = ProbeHttpServer.sha1(zip);
String url = httpServer.registerPack(s.playerId, s.corruptMetaToken, zip, false);
boolean required = plugin.getConfigManager().isRpSpoofRequirePack();
if (plugin.getConfigManager().isDebug()) {
plugin.getLogger().info("[RPSpoof:StageC] Pushing Corrupt-pack.mcmeta honeypot to " + player.getName()
+ " packId=" + s.corruptMetaPackId + " bytes=" + zip.length);
}
SchedulerUtil.runEntity(plugin, player, () -> {
if (!player.isOnline()) return;
try {
player.addResourcePack(s.corruptMetaPackId, url, sha1, null, required);
} catch (Throwable t) {
finishAfterStageC(player, s, false);
}
});
SchedulerUtil.cancelQuietly(s.stageTimeoutTask);
s.stageTimeoutTask = SchedulerUtil.runEntityDelayed(plugin, player, () -> {
if (sessions.get(s.playerId) == s && s.stage == Stage.STAGE_C_CORRUPT_MCMETA) {
plugin.getLogger().info("[RPSpoof:StageC] Corrupt-mcmeta timed out for " + player.getName());
finishAfterStageC(player, s, false);
}
}, 140L);
}
private void finishAfterStageC(Player player, SpoofSession s, boolean wasLoadedBySpoofer) {
SchedulerUtil.cancelQuietly(s.stageTimeoutTask);
if (wasLoadedBySpoofer && s.corruptMetaPackId != null && player.isOnline()) {
try {
player.removeResourcePack(s.corruptMetaPackId);
} catch (Throwable ignored) {
}
}
finalizeSession(player, s);
}
private static byte[] buildCorruptMcmetaZip(String nonce) {
try (java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
java.util.zip.ZipOutputStream zos = new java.util.zip.ZipOutputStream(baos, StandardCharsets.UTF_8)) {
zos.putNextEntry(new java.util.zip.ZipEntry("pack.mcmeta"));
zos.write(("{\"pack\":{INVALID_MCMETA_HONEYPOT_" + nonce).getBytes(StandardCharsets.UTF_8));
zos.closeEntry();
zos.finish();
return baos.toByteArray();
} catch (Exception e) {
return new byte[0];
}
}
@@ -327,7 +398,7 @@ public final class ResourcePackSpoofDetector extends PacketListenerAbstract impl
// IMPOSSIBLE on Vanilla: SHA-1 was deliberately inverted!
s.hits.add("RP_SPOOF_HONEYPOT_LOADED(acceptedBadSha1Pack,httpFetched=" + fetched
+ ",elapsedMs=" + (now - s.honeypotSentMs) + ")");
advanceFromStageA(player, s);
advanceFromStageA(player, s, true);
}
case FAILED_DOWNLOAD, FAILED_RELOAD, INVALID_URL -> {
// Expected legitimate Vanilla behavior!
@@ -335,18 +406,51 @@ public final class ResourcePackSpoofDetector extends PacketListenerAbstract impl
plugin.getLogger().info("[RPSpoof:StageA] " + player.getName()
+ " correctly rejected Bad-SHA1 honeypot (" + st + ", httpFetched=" + fetched + ")");
}
advanceFromStageA(player, s);
advanceFromStageA(player, s, false);
}
case DECLINED, DISCARDED -> {
if (plugin.getConfigManager().isDebug()) {
plugin.getLogger().info("[RPSpoof:StageA] " + player.getName() + " declined/discarded honeypot (" + st + ")");
}
advanceFromStageA(player, s);
advanceFromStageA(player, s, false);
}
}
return;
}
// --- Stage C: Corrupt pack.mcmeta Honeypot ---
if (s.stage == Stage.STAGE_C_CORRUPT_MCMETA && s.corruptMetaPackId != null && s.corruptMetaPackId.equals(packId)) {
boolean fetched = httpServer.wasFetched(s.corruptMetaToken);
if (plugin.getConfigManager().isDebug()) {
plugin.getLogger().info("[RPSpoof:StageC] " + player.getName()
+ " status=" + st + " elapsedMs=" + (now - s.corruptMetaSentMs) + " httpFetched=" + fetched);
}
switch (st) {
case ACCEPTED -> {
}
case DOWNLOADED -> {
if (!fetched) {
s.hits.add("RP_SPOOF_CORRUPT_META_NO_FETCH");
}
}
case SUCCESSFULLY_LOADED -> {
// IMPOSSIBLE on Vanilla: pack.mcmeta JSON is syntactically invalid!
s.hits.add("RP_SPOOF_CORRUPT_MCMETA_LOADED(fakedSuccessOnBrokenPack,httpFetched=" + fetched
+ ",elapsedMs=" + (now - s.corruptMetaSentMs) + ")");
finishAfterStageC(player, s, true);
}
case FAILED_RELOAD, FAILED_DOWNLOAD, INVALID_URL -> {
if (plugin.getConfigManager().isDebug()) {
plugin.getLogger().info("[RPSpoof:StageC] " + player.getName()
+ " correctly rejected Corrupt-pack.mcmeta (" + st + ")");
}
finishAfterStageC(player, s, false);
}
case DECLINED, DISCARDED -> finishAfterStageC(player, s, false);
}
return;
}
// --- Stage B: Valid Proof-of-Apply Pack ---
if (s.stage == Stage.STAGE_B_WAIT_PACK && s.verifyPackId != null && s.verifyPackId.equals(packId)) {
boolean fetched = httpServer.wasFetched(s.verifyToken);
@@ -517,7 +621,23 @@ public final class ResourcePackSpoofDetector extends PacketListenerAbstract impl
// Client claimed SUCCESSFULLY_LOADED, sign works, yet the pack's translation key is missing!
s.hits.add("RP_SPOOF_NOT_APPLIED(claimedLoadedButKeyUnresolved,raw=\"" + l1 + "\")");
}
finalizeSession(player, s);
// Remove Stage B verify pack cleanly, then run Stage C Corrupt-pack.mcmeta after reload settles
if (s.verifyPackId != null && player.isOnline()) {
try {
player.removeResourcePack(s.verifyPackId);
} catch (Throwable ignored) {
}
s.verifyPackId = null;
}
if (plugin.getConfigManager().isRpSpoofHoneypotEnabled()) {
SchedulerUtil.runEntityDelayed(plugin, player, () -> {
if (player.isOnline() && sessions.get(s.playerId) == s) {
startStageCCorruptMcmeta(player, s);
}
}, 30L);
} else {
finalizeSession(player, s);
}
});
}
@@ -559,7 +679,7 @@ public final class ResourcePackSpoofDetector extends PacketListenerAbstract impl
if (player.isOnline()) {
s.onComplete.run();
}
}, 20L);
}, 35L);
} else if (plugin.getProbeFreezeManager() != null) {
plugin.getProbeFreezeManager().tryUnfreezeIfClear(player);
}
@@ -623,6 +743,7 @@ public final class ResourcePackSpoofDetector extends PacketListenerAbstract impl
if (removePacks && player != null && player.isOnline()) {
try {
if (prev.honeypotPackId != null) player.removeResourcePack(prev.honeypotPackId);
if (prev.corruptMetaPackId != null) player.removeResourcePack(prev.corruptMetaPackId);
if (prev.verifyPackId != null) player.removeResourcePack(prev.verifyPackId);
} catch (Throwable ignored) {
}
+1 -1
View File
@@ -223,7 +223,7 @@ identity-linker:
probe-freeze:
enabled: false
timeout-seconds: 15
timeout-seconds: 25
allowed-commands:
- "^/(login|register|l|reg)(\\s.*)?$"