Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix forcelogin auth exploit #170

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,20 @@ public void register() {
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));
Expand Down Expand Up @@ -114,15 +119,11 @@ public EventTask executeAsync(final PluginMessageEvent event) {
});
}

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))) {
Expand Down