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 unsigned commands detected as signed #1082

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
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 @@ -49,4 +49,12 @@ public void encode(ByteBuf buf) {
public boolean isEmpty() {
return acknowledged.isEmpty();
}

@Override
public String toString() {
return "LastSeenMessages{" +
"offset=" + offset +
", acknowledged=" + acknowledged +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void handlePlayerCommandInternal(KeyedPlayerCommand packet) {
&& playerKey.getKeyRevision().compareTo(IdentifiedKey.Revision.LINKED_V2) >= 0) {
logger.fatal("A plugin tried to deny a command with signable component(s). "
+ "This is not supported. "
+ "Disconnecting player " + player.getUsername());
+ "Disconnecting player " + player.getUsername() + ". Command packet: " + packet);
player.disconnect(Component.text(
"A proxy plugin caused an illegal protocol state. "
+ "Contact your network administrator."));
Expand All @@ -75,7 +75,7 @@ public void handlePlayerCommandInternal(KeyedPlayerCommand packet) {
&& playerKey.getKeyRevision().compareTo(IdentifiedKey.Revision.LINKED_V2) >= 0) {
logger.fatal("A plugin tried to change a command with signed component(s). "
+ "This is not supported. "
+ "Disconnecting player " + player.getUsername());
+ "Disconnecting player " + player.getUsername() + ". Command packet: " + packet);
player.disconnect(Component.text(
"A proxy plugin caused an illegal protocol state. "
+ "Contact your network administrator."));
Expand All @@ -95,7 +95,7 @@ public void handlePlayerCommandInternal(KeyedPlayerCommand packet) {
&& playerKey.getKeyRevision().compareTo(IdentifiedKey.Revision.LINKED_V2) >= 0) {
logger.fatal("A plugin tried to change a command with signed component(s). "
+ "This is not supported. "
+ "Disconnecting player " + player.getUsername());
+ "Disconnecting player " + player.getUsername() + ". Command packet: " + packet);
player.disconnect(Component.text(
"A proxy plugin caused an illegal protocol state. "
+ "Contact your network administrator."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void handlePlayerCommandInternal(SessionPlayerCommand packet) {
if (packet.isSigned()) {
logger.fatal("A plugin tried to deny a command with signable component(s). "
+ "This is not supported. "
+ "Disconnecting player " + player.getUsername());
+ "Disconnecting player " + player.getUsername() + ". Command packet: " + packet);
player.disconnect(Component.text(
"A proxy plugin caused an illegal protocol state. "
+ "Contact your network administrator."));
Expand All @@ -63,7 +63,7 @@ public void handlePlayerCommandInternal(SessionPlayerCommand packet) {
if (packet.isSigned()) {
logger.fatal("A plugin tried to change a command with signed component(s). "
+ "This is not supported. "
+ "Disconnecting player " + player.getUsername());
+ "Disconnecting player " + player.getUsername() + ". Command packet: " + packet);
player.disconnect(Component.text(
"A proxy plugin caused an illegal protocol state. "
+ "Contact your network administrator."));
Expand All @@ -87,7 +87,7 @@ public void handlePlayerCommandInternal(SessionPlayerCommand packet) {
if (packet.isSigned()) {
logger.fatal("A plugin tried to change a command with signed component(s). "
+ "This is not supported. "
+ "Disconnecting player " + player.getUsername());
+ "Disconnecting player " + player.getUsername() + ". Command packet: " + packet);
player.disconnect(Component.text(
"A proxy plugin caused an illegal protocol state. "
+ "Contact your network administrator."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,26 @@ public Instant getTimeStamp() {
}

public boolean isSigned() {
return salt != 0 || !lastSeenMessages.isEmpty() || !argumentSignatures.isEmpty();
if (salt == 0) return false;
return !lastSeenMessages.isEmpty() || !argumentSignatures.isEmpty();
}

@Override
public boolean handle(MinecraftSessionHandler handler) {
return handler.handle(this);
}

@Override
public String toString() {
return "SessionPlayerCommand{" +
"command='" + command + '\'' +
", timeStamp=" + timeStamp +
", salt=" + salt +
", argumentSignatures=" + argumentSignatures +
", lastSeenMessages=" + lastSeenMessages +
'}';
}

public static class ArgumentSignatures {

private final List<ArgumentSignature> entries;
Expand Down Expand Up @@ -104,6 +116,12 @@ public void encode(ByteBuf buf) {
entry.encode(buf);
}
}
@Override
public String toString() {
return "ArgumentSignatures{" +
"entries=" + entries +
'}';
}
}

public static class ArgumentSignature {
Expand All @@ -120,5 +138,12 @@ public void encode(ByteBuf buf) {
ProtocolUtils.writeString(buf, name);
buf.writeBytes(signature);
}

@Override
public String toString() {
return "ArgumentSignature{" +
"name='" + name + '\'' +
'}';
}
}
}