Skip to content

Reject invalid usernames from Votifier votes - #1533

Merged
BenCodez merged 4 commits into
masterfrom
agent/reject-invalid-vote-usernames
Jul 27, 2026
Merged

Reject invalid usernames from Votifier votes#1533
BenCodez merged 4 commits into
masterfrom
agent/reject-invalid-vote-usernames

Conversation

@BenCodez

Copy link
Copy Markdown
Owner

Summary

Reject invalid Minecraft usernames at the earliest VotingPlugin vote-ingress boundaries before any UUID generation or state mutation.

Valid Java Edition-style usernames continue to accept 1-16 ASCII letters, digits, and underscores, including previously unknown offline players and the exact 16-character value MchtNameOver16xx.

Root cause

Proxy offline mode resolved an offline UUID before validating the externally supplied Votifier username. Values containing traversal syntax, slashes, whitespace, punctuation, Unicode, controls, or more than 16 characters could therefore reach MySQL totals, vote caches, rewards, and backend/proxy forwarding.

Changes

  • Add a central MinecraftUsernameValidator using [A-Za-z0-9_]{1,16}.
  • Validate at the shared VotingPluginProxy.vote(...) boundary used by BungeeCord, Velocity, and multi-proxy vote replay.
  • Validate standalone Bukkit Votifier events before service-site, queue, or PlayerVoteEvent processing.
  • Sanitize and bound all rejected username/service values before logging.
  • Sanitize the informational BungeeCord and Velocity Votifier receipt logs.
  • Add regression coverage for invalid names and verify rejection happens before UUID lookup, totals/database access, vote-party/reward state, vote-cache access, backend messaging, or multi-proxy envelopes.
  • Cover the 15-, 16-, and 17-character boundaries explicitly.

Validation

  • git diff --check — passed.
  • Validator compiled directly and smoke tests passed for valid 15/16-character names and invalid 17-character, traversal, slash, whitespace, Unicode, and control-character values.
  • Full Maven tests could not be run in the available workspace because Maven and JDK 21 were unavailable.

MCHT follow-up

The MCHT harness is maintained outside this repository. Its invalid-length fixture must change from the valid 16-character MchtNameOver16xx to the genuine 17-character MchtNameOver16xxx before the next MCHT run.

@BenCodez
BenCodez marked this pull request as ready for review July 27, 2026 02:27
@BenCodez
BenCodez merged commit 34eb7dc into master Jul 27, 2026
4 checks passed
@BenCodez
BenCodez deleted the agent/reject-invalid-vote-usernames branch July 27, 2026 02:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3f089f02b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

public final class MinecraftUsernameValidator {
private static final int MAX_LENGTH = 16;
private static final int MAX_LOG_LENGTH = 32;
private static final Pattern VALID_USERNAME = Pattern.compile("[A-Za-z0-9_]{1," + MAX_LENGTH + "}");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Allow the configured Bedrock prefix

When the documented default BedrockPlayerPrefix: '.' is used, a valid Bedrock vote such as .Player fails this Java-only pattern, so both new ingress checks reject it before the existing Bedrock-aware resolution runs; proxy cache or multi-proxy replays containing the resolved prefixed name are rejected as well. Recognize and validate the configured prefix plus base name, or delegate validation to the existing Bedrock-aware validation path.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant