Skip to content
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ All notable changes to this project will be documented in this file.
- A warning is logged when the Redis connection is unencrypted and leaves the machine.
- Fabric: a logged-in player is no longer kicked by a connection under the same name from
another address on an offline-mode server; the new connection is refused, as on Paper.
- Paper: any console line with a password command and an argument is dropped, not only Paper's
own command line, so command-spy and chat-logging plugins no longer leak passwords. A chat line
such as "type /login to continue" is dropped too, as it cannot be told apart from a password.
- After `/authadmin resetpassword`, a player who ran it is reminded to clear the chat with F3 + D.

### Fixed
- Paper: on an online-mode server the owner can again take over their own connection from
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/lang/messages_en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ messages:
admin-temporary-password-copy: "&b&n{password}"
admin-temporary-password-hover: "&aClick to copy the temporary password."
admin-temporary-password-expires: "&7Expires at: {expires}. The player must use /changepassword <temporary> <new>."
admin-temporary-password-warning: "&cThe password stays in your chat history. Clear it with F3 + D, especially when streaming or recording."
admin-player-usage: "&cUsage: /authadmin {operation} <player>"
admin-operation-failed: "&cOperation failed. Check the server log."
admin-account-unlocked: "&aAccount unlocked."
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/lang/messages_es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ messages:
admin-temporary-password-copy: "&b&n{password}"
admin-temporary-password-hover: "&aHaz clic para copiar la contraseña temporal."
admin-temporary-password-expires: "&7Caduca el: {expires}. El jugador debe usar /changepassword <temporal> <nueva>."
admin-temporary-password-warning: "&cLa contraseña queda en el historial del chat. Bórralo con F3 + D, sobre todo si transmites o grabas."
admin-player-usage: "&cUso: /authadmin {operation} <jugador>"
admin-operation-failed: "&cLa operación falló. Revisa el registro del servidor."
admin-account-unlocked: "&aCuenta desbloqueada."
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/lang/messages_fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ messages:
admin-temporary-password-copy: "&b&n{password}"
admin-temporary-password-hover: "&aCliquez pour copier le mot de passe temporaire."
admin-temporary-password-expires: "&7Expire le : {expires}. Le joueur doit utiliser /changepassword <temporaire> <nouveau>."
admin-temporary-password-warning: "&cLe mot de passe reste dans l'historique du chat. Effacez-le avec F3 + D, surtout en stream ou en enregistrement."
admin-player-usage: "&cUtilisation : /authadmin {operation} <joueur>"
admin-operation-failed: "&cL'opération a échoué. Consultez le journal du serveur."
admin-account-unlocked: "&aCompte déverrouillé."
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/lang/messages_it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ messages:
admin-temporary-password-copy: "&b&n{password}"
admin-temporary-password-hover: "&aFai clic per copiare la password temporanea."
admin-temporary-password-expires: "&7Scade il: {expires}. Il giocatore deve usare /changepassword <temporanea> <nuova>."
admin-temporary-password-warning: "&cLa password resta nella cronologia della chat. Cancellala con F3 + D, soprattutto se trasmetti o registri."
admin-player-usage: "&cUso: /authadmin {operation} <giocatore>"
admin-operation-failed: "&cOperazione non riuscita. Controlla il log del server."
admin-account-unlocked: "&aAccount sbloccato."
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/lang/messages_ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ messages:
admin-temporary-password-copy: "&b&n{password}"
admin-temporary-password-hover: "&aНажмите ЛКМ, чтобы скопировать временный пароль."
admin-temporary-password-expires: "&7Действует до: {expires}. Игрок должен выполнить /changepassword <временный> <новый>."
admin-temporary-password-warning: "&cПароль остался в истории чата. Очистите её через F3 + D, особенно на стриме или при записи."
admin-player-usage: "&cИспользование: /authadmin {operation} <игрок>"
admin-operation-failed: "&cНе удалось выполнить операцию. Проверьте журнал сервера."
admin-account-unlocked: "&aАккаунт разблокирован."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ private static void deliverTemporaryPassword(AuthSecuredFabricMod mod, CommandSo
send(source, message(mod, "messages.admin-temporary-password-expires",
"&7Expires at: {expires}. The player must use /changepassword <temporary> <new>.",
Map.of("expires", reset.getExpiresAt().toString())));
if (source.isPlayer()) {
send(source, message(mod, "messages.admin-temporary-password-warning",
"&cThe password stays in your chat history. Clear it with F3 + D, especially when streaming or recording."));
}
} finally {
Arrays.fill(password, '\0');
reset.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ private void deliverTemporaryPassword(CommandSender sender, String target, Tempo
sender.sendMessage(message("messages.admin-temporary-password-expires",
"&7Expires at: {expires}. The player must use /changepassword <temporary> <new>.",
Map.of("expires", reset.getExpiresAt().toString())));
if (sender instanceof org.bukkit.entity.Player) {
sender.sendMessage(message("messages.admin-temporary-password-warning",
"&cThe password stays in your chat history. Clear it with F3 + D, especially when streaming or recording."));
}
} finally {
Arrays.fill(password, '\0');
reset.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import java.util.Locale;

/**
* Drops Paper's built-in player-command log record before it is formatted.
* Drops Paper's built-in player-command log record before it is formatted, and any other log line
* that carries a password command with an argument (command spies, chat loggers).
* Paper logs the raw command before firing PlayerCommandPreprocessEvent, so an
* event listener alone cannot keep password arguments out of the console.
*/
Expand Down Expand Up @@ -46,9 +47,10 @@ public Result filter(LogEvent event) {
static boolean containsSensitivePaperCommand(LogEvent event) {
if (event == null) return false;
Message message = event.getMessage();
String format = message == null ? null : message.getFormat();
if (message == null) return false;
String format = message.getFormat();
if (format == null || !format.toLowerCase(Locale.ROOT).contains(PAPER_COMMAND_MARKER)) {
return false;
return SensitiveCommandLogMatcher.containsCommandWithArgument(message.getFormattedMessage());
}

Object[] parameters = message.getParameters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,22 @@ static boolean isSensitiveCommand(String rawCommand) {
if (namespace >= 0) label = label.substring(namespace + 1);
return SecretRedactor.isPasswordCommand(label);
}

/**
* A password command with an argument anywhere in a log line, such as {@code "[Spy] Steve: /login x"}:
* other plugins log commands in their own formats. The slash must start a word, so a path like
* {@code /home/l x} does not match the {@code l} alias.
*/
static boolean containsCommandWithArgument(String line) {
if (line == null) return false;
for (int slash = line.indexOf('/'); slash >= 0; slash = line.indexOf('/', slash + 1)) {
if (slash > 0 && !Character.isWhitespace(line.charAt(slash - 1))
&& "\"'([<{".indexOf(line.charAt(slash - 1)) < 0) continue;
int end = slash + 1;
while (end < line.length() && !Character.isWhitespace(line.charAt(end))) end++;
if (!isSensitiveCommand(line.substring(slash, end))) continue;
if (!line.substring(end).isBlank()) return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,22 @@ void allowsUnrelatedCommandsAndMessages() {
assertTrue(SensitiveCommandLogMatcher.isSensitiveCommand(" /login secret"));
assertFalse(SensitiveCommandLogMatcher.isSensitiveCommand("/loginhistory"));
}

@Test
void findsPasswordCommandsLoggedByOtherPlugins() {
for (String line : new String[]{
"/login secret", "[Spy] Steve: /login secret", "Steve: /authsecured:register a a",
"Steve ran \"/cp old new\"", "(/l secret)",
// Indistinguishable from "/login to": a chat line like this is dropped on purpose.
"Type /login to continue"
}) {
assertTrue(SensitiveCommandLogMatcher.containsCommandWithArgument(line), line);
}
for (String line : new String[]{
"Steve: /login", "Loaded /home/l x", "https://example.com/login x",
"Steve: /help login secret", null
}) {
assertFalse(SensitiveCommandLogMatcher.containsCommandWithArgument(line), String.valueOf(line));
}
}
}
Loading