Merge pull request #170 from AlexProgrammerDE/master

Fix forcelogin auth exploit
This commit is contained in:
Adrian 2024-08-24 23:43:50 -05:00 committed by GitHub
commit ccd2903de8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,15 +58,20 @@ public final class PluginMessageListener implements Listener<PluginMessageEvent>
public EventTask executeAsync(final PluginMessageEvent event) {
return EventTask.async(() -> {
plugin.logDebug(() -> "PluginMessageEvent | Start");
if (notAllowedEvent(event)) {
plugin.logDebug(() -> "PluginMessageEvent | Not allowed");
if (notHandledEvent(event)) {
plugin.logDebug(() -> "PluginMessageEvent | Not handled");
return;
}
final ServerConnection connection = (ServerConnection) event.getSource();
// Set the result to handled, the message is dropped at the proxy
event.setResult(PluginMessageEvent.ForwardResult.handled());
// Make sure the message is S -> P, NOT P -> S
if (!(event.getSource() instanceof ServerConnection connection)) {
plugin.logDebug("PluginMessageEvent | Not ServerConnection");
return;
}
final ByteArrayDataInput input = event.dataAsDataStream();
final String message = input.readUTF();
final MessageType type = TYPES.valueOrThrow(message.toUpperCase(Locale.ROOT));
@ -114,15 +119,11 @@ public final class PluginMessageListener implements Listener<PluginMessageEvent>
});
}
private boolean notAllowedEvent(PluginMessageEvent event) {
private boolean notHandledEvent(PluginMessageEvent event) {
if (!event.getResult().isAllowed()) {
plugin.logDebug("PluginMessageEvent | Result not allowed");
return true;
}
if (!(event.getSource() instanceof ServerConnection)) {
plugin.logDebug("PluginMessageEvent | Not ServerConnection");
return true;
}
final var identifier = event.getIdentifier();
if (!(identifier.equals(AuthMeVelocityPlugin.MODERN_CHANNEL)
|| identifier.equals(AuthMeVelocityPlugin.LEGACY_CHANNEL))) {