FastLogin icon indicating copy to clipboard operation
FastLogin copied to clipboard

FastLogin breaks java reflection with TinyProtocol

Open Th0rgal opened this issue 5 years ago • 13 comments

What behaviour is observed:

//: When using a plugin like HackedServer with FastLogin, I get a "Cannot access reflection" error.

What behaviour is expected:

//: Reflection should stay accessible

Steps/models to reproduce:

//: Install HackedServer, HackedCore, LoginSecurity or Authme and FastLogin on paperspigot 1.16.1

Screenshots (if applicable)

Plugin list:

//: HackedServer, HackedCore, LoginSecurity and FastLogin

Environment description

//: Paper spigot 1.16.1 build 330 (same with other setups tho)

Plugin version or build number (don't write latest):

//: # build 953 from jenkins

Server Log:

java.lang.RuntimeException: Cannot access reflection.
	at io.th0rgal.hackedserver.utils.tinyprotocol.Reflection$1.get(Reflection.java:151) ~[?:?]
	at io.th0rgal.hackedserver.utils.tinyprotocol.TinyProtocolFixed.getChannel(TinyProtocolFixed.java:401) ~[?:?]
	at io.th0rgal.hackedserver.utils.tinyprotocol.TinyProtocolFixed$5.onPlayerLogin(TinyProtocolFixed.java:176) ~[?:?]
	at com.destroystokyo.paper.event.executor.MethodHandleEventExecutor.execute(MethodHandleEventExecutor.java:37) ~[patched_1.16.1.jar:git-Paper-130]
	at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.16.1.jar:git-Paper-130]
	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.16.1.jar:git-Paper-130]
	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607) ~[patched_1.16.1.jar:git-Paper-130]
	at net.minecraft.server.v1_16_R1.PlayerList.attemptLogin(PlayerList.java:663) ~[patched_1.16.1.jar:git-Paper-130]
	at net.minecraft.server.v1_16_R1.LoginListener.c(LoginListener.java:154) ~[patched_1.16.1.jar:git-Paper-130]
	at net.minecraft.server.v1_16_R1.LoginListener.tick(LoginListener.java:65) ~[patched_1.16.1.jar:git-Paper-130]
	at net.minecraft.server.v1_16_R1.NetworkManager.a(NetworkManager.java:369) ~[patched_1.16.1.jar:git-Paper-130]
	at net.minecraft.server.v1_16_R1.ServerConnection.c(ServerConnection.java:142) ~[patched_1.16.1.jar:git-Paper-130]
	at net.minecraft.server.v1_16_R1.MinecraftServer.b(MinecraftServer.java:1379) ~[patched_1.16.1.jar:git-Paper-130]
	at net.minecraft.server.v1_16_R1.DedicatedServer.b(DedicatedServer.java:377) ~[patched_1.16.1.jar:git-Paper-130]
	at net.minecraft.server.v1_16_R1.MinecraftServer.a(MinecraftServer.java:1213) ~[patched_1.16.1.jar:git-Paper-130]
	at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:1001) ~[patched_1.16.1.jar:git-Paper-130]
	at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$a$0(MinecraftServer.java:177) ~[patched_1.16.1.jar:git-Paper-130]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_261]
Caused by: java.lang.NullPointerException
	at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source) ~[?:1.8.0_261]
	at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.get(Unknown Source) ~[?:1.8.0_261]
	at java.lang.reflect.Field.get(Unknown Source) ~[?:1.8.0_261]
	at io.th0rgal.hackedserver.utils.tinyprotocol.Reflection$1.get(Reflection.java:149) ~[?:?]
	... 17 more

Configuration:

Th0rgal avatar Aug 01 '20 15:08 Th0rgal

The plugin doesn't drop the accessibility state. As you can see in the error message it's caused by NPE. That means that the given object is null. I see that the official source code of TinyProtocol was modified and the HackedServer plugin is closed source. Therefore it's not possible for me to test it on my own.

Does it happen only in combination with FastLogin?

TuxCoding avatar Aug 02 '20 07:08 TuxCoding

The plugin doesn't drop the accessibility state. As you can see in the error message it's caused by NPE. That means that the given object is null. I see that the official source code of TinyProtocol was modified and the HackedServer plugin is closed source. Therefore it's not possible for me to test it on my own.

Does it happen only in combination with FastLogin?

Yeah it happens only in combination with FastLogin.

Th0rgal avatar Aug 02 '20 08:08 Th0rgal

Please report it to them, I cannot really debug a paid plugin, sorry.

EDIT: They changed something in TinyProtocol, so only they are able to look into it.

TuxCoding avatar Aug 02 '20 09:08 TuxCoding

Please report it to them, I cannot really debug a paid plugin, sorry.

EDIT: They changed something in TinyProtocol, so only they are able to look into it.

I added you a license but the problem is reflection access actually. Here is the TinyProtocolFixed code: https://hasteb.in/utavohib.java

Th0rgal avatar Aug 02 '20 09:08 Th0rgal

I added you a license but the problem is reflection access actually

Why? NPE, means that the supplied object was null. In this instance it's the network manager.

TuxCoding avatar Aug 02 '20 09:08 TuxCoding

I added you a license but the problem is reflection access actually

Why? NPE, means that the supplied object was null. In this instance it's the network manager.

The description of the Exception is "Cannot access reflection." and according to the traceback it wasn't able to access a field. Am I wrong?

Th0rgal avatar Aug 02 '20 11:08 Th0rgal

Yes you are not able to access the field, because the supplied object is null. The NPE is wrapped into the RuntimeException. You can see that by the Caused by notation.

TuxCoding avatar Aug 02 '20 11:08 TuxCoding

Yes you are not able to access the field, because the supplied object is null. The NPE is wrapped into the RuntimeException. You can see that by the Caused by notation.

You are right but what's the link between this object and fastlogin? xD

Th0rgal avatar Aug 02 '20 14:08 Th0rgal

FastLogin uses ProtocolLib and in the early login process. That hooks into the network protocol the same way. I guess that is conflicting with each other. However that shouldn't happen. Do you have other plugins installed like ProtocolSupport? Maybe it's combination of multiple factors.

TuxCoding avatar Aug 03 '20 09:08 TuxCoding

FastLogin uses ProtocolLib and in the early login process. That hooks into the network protocol the same way. I guess that is conflicting with each other. However that shouldn't happen. Do you have other plugins installed like ProtocolSupport? Maybe it's combination of multiple factors.

Nope I only have ProtocolLib, FastLogin, LoginSecurity (or Authme), Hackedserver and HackedCore.

Th0rgal avatar Aug 03 '20 09:08 Th0rgal

I could reproduce it and it could be connected to the asynchronous behavior of ProtocolLib. It doesn't happen for synchronous listeners.

TuxCoding avatar Aug 05 '20 13:08 TuxCoding

I could reproduce it and it could be connected to the asynchronous behavior of ProtocolLib. It doesn't happen for synchronous listeners.

Hmm so this might be a ProtocolLib issue? Do you mind take a look at it @dmulloy2?

Th0rgal avatar Aug 05 '20 16:08 Th0rgal

Hi guys!

I have the same issue using the the latest builds (tested on Java 8 and Java 11):

  • Paper version git-Paper-593 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
  • ProtocolLib 4.6.1-SNAPSHOT-b499
  • FastLogin 1.11-SNAPSHOT-7192dcd
  • HackedServer 2.78.2
[10:53:27] [FastLogin Pool Thread #0/INFO]: [FastLogin] Handling player RazrCraft
[10:53:27] [FastLogin Pool Thread #0/INFO]: [FastLogin] Requesting premium login for registered player: RazrCraft
[10:53:29] [FastLogin Pool Thread #1/INFO]: [FastLogin] Profile RazrCraft has a verified premium account: Verification{id=c4fcbd68-e89c-4fa2-88c6-fb0cf2022bb9, name='RazrCraft', properties=[SkinProperty{value='ewogICJ0aW1lc3RhbXAiIDogMTYxODc1NDAxMDE2MiwKICAicHJvZmlsZUlkIiA6ICJjNGZjYmQ2OGU4OWM0ZmEyODhjNmZiMGNmMjAyMmJiOSIsCiAgInByb2ZpbGVOYW1lIiA6ICJSYXpyQ3JhZnQiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTQ2ZGIyY2VhOTEyNjM1YWJjYzFjNzAwNmJmMWQwMTU4MDNjNzdjZjVkOWMyNGEzYzhiYzVlNzQ2MTNlMGYwNiIKICAgIH0KICB9Cn0=', signature='r5Zt54Okq6nD1fcWUWnAs9tiYpURh6IwBYl8WSMOuN3/LuTkadHDq/o3V1Tv/XvdheKNjo6jQXDRfBM4zHK7u//lcZ3kAwOtPzc/vHfdVRHVyWECgfTlaiDUgn85IkHs5eR75RHRDhtVLetWS5xS4zx+218Qt67LCpZV+yCVQ7j3n82NG39N+LCtY7AnNMVBwua8LKS+4by7bxGBt27SV4DrtmheYaqOLyps8PMbHPtafjMWqLzPYqem5fVTsif3eeX8VqYOWrd6A2xnpXO2GszKZ+ysbtwsn2zRhyJVsuCgDP039ylhYDJLNxPvEMGNbcrb/cOr3fc5x+QebJGiF9CiFgb9UIhNHC9FbcyPiZytPCOeQb3Y6pGO8TkqnmAH6xOlYpa9nYpGdq2x45bz5Fxogj67FHsRfipwFhYlRNkyzlmS6I+6817Au6lbDEkhT/ryIXWbqPIXEynHHE2qsXgBO4xNIsRkkDBtFE/1e12N+OmT5VCjUl5H3HzM2hkBl1Kw2BIKowfKO2moHz6UQApTF8XIndBUGUtEYbFZuOdJ33e988eVZ7zpPwyI9qK2DMkeP+YbaleCfosm0m3Jo6JQI9olO1x0ZpBccgT56Weds9GcksGgzXDYGcATecAWrkzElAhDgwWqgfSc3ZTSFJ7vx9/ts9y4olCnZ1BG+TI='}]}
[10:53:29] [User Authenticator #1/INFO]: UUID of player RazrCraft is 4b44fd6f-8c2c-3a90-a10b-57b5a08e60f2
[10:53:29] [Server thread/ERROR]: Could not pass event PlayerLoginEvent to HackedServer v2.78.2
java.lang.RuntimeException: Cannot access reflection.
	at io.th0rgal.hackedserver.utils.tinyprotocol.Reflection$1.get(Reflection.java:154) ~[?:?]
	at io.th0rgal.hackedserver.utils.tinyprotocol.TinyProtocolFixed.getChannel(TinyProtocolFixed.java:416) ~[?:?]
	at io.th0rgal.hackedserver.utils.tinyprotocol.TinyProtocolFixed$5.onPlayerLogin(TinyProtocolFixed.java:190) ~[?:?]
	at com.destroystokyo.paper.event.executor.MethodHandleEventExecutor.execute(MethodHandleEventExecutor.java:37) ~[patched_1.16.5.jar:git-Paper-592]
	at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.16.5.jar:git-Paper-592]
	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.16.5.jar:git-Paper-592]
	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607) ~[patched_1.16.5.jar:git-Paper-592]
	at net.minecraft.server.v1_16_R3.PlayerList.attemptLogin(PlayerList.java:768) ~[patched_1.16.5.jar:git-Paper-592]
	at net.minecraft.server.v1_16_R3.LoginListener.c(LoginListener.java:169) ~[patched_1.16.5.jar:git-Paper-592]
	at net.minecraft.server.v1_16_R3.LoginListener.tick(LoginListener.java:87) ~[patched_1.16.5.jar:git-Paper-592]
	at net.minecraft.server.v1_16_R3.NetworkManager.a(NetworkManager.java:403) ~[patched_1.16.5.jar:git-Paper-592]
	at net.minecraft.server.v1_16_R3.ServerConnection.c(ServerConnection.java:158) ~[patched_1.16.5.jar:git-Paper-592]
	at net.minecraft.server.v1_16_R3.MinecraftServer.b(MinecraftServer.java:1501) ~[patched_1.16.5.jar:git-Paper-592]
	at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:418) ~[patched_1.16.5.jar:git-Paper-592]
	at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1328) ~[patched_1.16.5.jar:git-Paper-592]
	at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1116) ~[patched_1.16.5.jar:git-Paper-592]
	at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-592]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_281]
Caused by: java.lang.NullPointerException
	at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source) ~[?:1.8.0_281]
	at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.get(Unknown Source) ~[?:1.8.0_281]
	at java.lang.reflect.Field.get(Unknown Source) ~[?:1.8.0_281]
	at io.th0rgal.hackedserver.utils.tinyprotocol.Reflection$1.get(Reflection.java:152) ~[?:?]
	... 17 more
[10:53:31] [Server thread/INFO]: RazrCraft joined the game
[10:53:31] [Server thread/INFO]: RazrCraft[/127.0.0.1:64734] logged in with entity id 224 at ([world]255.43394527767538, 80.69661634784185, -368.12905764882294)

Any update on this? @dmulloy2 @games647 @Th0rgal (Sorry for the tags)

Thanks in advance!

R4z0rX avatar Apr 18 '21 14:04 R4z0rX