Security model
This document explains the threats OAuthMC defends against, the responsibilities of the calling platform, and the trade-offs baked into the protocol.
Why join alone never verifies an account#
Joining a Minecraft server in online mode proves which Mojang account connected. It does not prove which account on the platform started the verification. Because anyone can open a ticket for any Minecraft username, OAuthMC never marks a player verified on join alone.
A naive "auto-verify on join" design fails in three ways:
- Ticket hijacking: an attacker opens a ticket for victim
Vand waits untilVjoins to verify their own account. Both open tickets observeV's join. - Phishing: even with
exclusive: trueor per-ticket hostnames, an attacker can trickVinto joining a server address ("joinverify.example.comfor an event"). Joining a server does not look like handing over a credential. - Username squatting: with
exclusive: true, an attacker can keep opening tickets forVto blockVfrom verifying their own account.
In both code mode and link mode, OAuthMC generates an 8-character secret (XXXX-XXXX, drawn from an unambiguous 30-character alphabet, ~39.2 bits of entropy) using rejection sampling over OS randomness. OAuthMC sends the secret over the AES-128-CFB8 encrypted Minecraft connection after Mojang hasJoined succeeds. Only the player who owns the Minecraft account receives it, and verification completes only when the platform redeems that code through POST /v1/tickets/{id}/redeem.
exclusivedefaults tofalseso attackers cannot block other players from starting verification.- On join, OAuthMC hashes the fresh code with SHA-256 and stores the hash on every open ticket for that username (only when Mojang's canonical username matches the login username ASCII case-insensitively). Rejoining replaces the hash without resetting
attempts. GET /v1/tickets/{id}never returns the Mojang UUID, the code, or a filledlink_url. The UUID is returned once, on a successful redeem.- Redeeming consumes the ticket (
status: "redeemed"). Wrong codes decrementattempts_leftand lock the ticket at0.
Link mode requires session binding on the platform#
In link mode, OAuthMC substitutes {ticket} and {code} into link_url and displays an Open link button in Minecraft's Configuration dialog. When the player clicks it, Minecraft shows its built-in confirmation prompt and opens the URL in the player's browser.
Link mode is safe only if the platform enforces all three rules on the verification page:
- Check session ownership before redeeming. Verify that the authenticated browser session belongs to the user who created
{ticket}. If an attackerAcreates a link-mode ticket for victimVand tricksVinto joining and clicking Open link,V's browser carriesV's session (or no session), notA's. Reject the request and never call/redeemonA's ticket. - Never redeem on
GET. Render a confirmation page that shows which Minecraft username is being linked to which platform account, and redeem only on an explicitPOSTaction protected by the platform's normal session and CSRF checks. - Keep
{ticket}and{code}out of server logs andRefererheaders. Put both placeholders in the URL fragment (https://example.com/verify#ticket={ticket}&code={code}), strip the fragment withhistory.replaceStateafter reading it in JavaScript, and sendReferrer-Policy: no-referreron the page. Always usehttps://in production (OAUTHMC_ALLOW_HTTP_LINKSdefaults tofalse).
See Integrating OAuthMC for the full pattern.
Multi-tenant mode and message isolation#
Each key in OAUTHMC_API_KEYS is an isolated tenant. API reads, redeems, and deletes are strictly scoped to the owning key.
On the Minecraft port, a username may have open tickets from more than one tenant at the same time. OAuthMC applies link mode and per-ticket messages overrides only when every open ticket for the joining username belongs to the same tenant (and, for link mode, the newest open ticket uses link mode). If two tenants both have open tickets for the same username, OAuthMC ignores per-ticket overrides and forces code mode with server templates. One tenant cannot inject clickable URLs or phishing text into another tenant's verification flow, while every tenant's open ticket can still redeem the code.
Pre-encryption rejection trade-off#
When a client sends Login Start for a username with no open ticket, OAuthMC sends Login Disconnect immediately before Encryption Request.
- Benefit: port scanners and unsolicited connections cost zero RSA decryptions and zero Mojang
hasJoinedrequests. - Trade-off: anyone can probe whether a specific Minecraft username has an open ticket right now.
If your platform treats an in-flight verification attempt as sensitive, account for this disclosure in your own ticket-creation rate limits and UX.
Rate limiting and why there is no per-name limit#
After confirming an open ticket exists and before sending Encryption Request, OAuthMC checks a per-IP token bucket (OAUTHMC_AUTH_RATE_PER_MINUTE, default 6; OAUTHMC_AUTH_BURST, default 3). IPv4 peers are bucketed by /32 and IPv6 peers by /64, with IPv4-mapped IPv6 addresses (::ffff:a.b.c.d) folded back to IPv4 /32. Requests over the limit are kicked before encryption with the rate_limited message.
Outgoing Mojang hasJoined calls are also capped globally (OAUTHMC_MAX_SESSION_CALLS, default 32). Excess logins are kicked with rate_limited.
OAuthMC does not enforce a per-username login rate limit. A per-name limit would let an unauthenticated attacker flood Login Start packets for a victim's username and block the victim from verifying. Bounding abuse per source IP bucket and capping global hasJoined concurrency protects CPU and Mojang quota without creating a per-player denial-of-service vector.
Cryptography and protocol hardening#
- RSA-1024 PKCS#1 v1.5: generated fresh at startup from OS randomness (
getrandom). OAuthMC pinsrsa = 0.10.0, which uses constant-time implicit rejection for PKCS#1 v1.5 decryption (mitigating Marvin / RUSTSEC-2023-0071). Any decryption or framing error closes the connection identically with no error oracle and zero Mojang calls. - Verify token: 4 random bytes per Encryption Request, compared in constant time on Encryption Response.
- Minecraft 1.19 and 1.19.2 (
hasToken = false): protocols759and760allow clients with a Mojang profile public key to send a salt and signature instead of the encrypted verify token. OAuthMC acceptshasToken = falsewithout verifying the signature. This remains safe because:- The decrypted 16-byte shared secret is hashed with the server's RSA public key into Mojang's
hasJoinedserverId, so only a client holding the account's Mojang session token makeshasJoinedreturn200. - The code is sent in the encrypted Login Disconnect packet under that shared secret, so replaying an encrypted secret only produces ciphertext an attacker cannot decrypt.
- The decrypted 16-byte shared secret is hashed with the server's RSA public key into Mojang's
- Mojang
hasJoinedover TLS: usesrustlswithringand embeddedwebpki-roots(no host CA bundle needed indistroless/static). Responses are capped at 64 KiB with a 5-second default timeout and zero redirects. Mojang's returned canonical username must match the login username (ASCII case-insensitively), or OAuthMC kicks withunverifiedand mutates no ticket. Plainhttp://is used only whenOAUTHMC_SESSION_URLis explicitly overridden for local tests. - No secrets in logs: OAuthMC never logs verification codes, filled verification links, API keys, RSA private keys, or shared secrets.
API and resource protection#
- Bearer keys must be at least 32 characters and are checked across every configured key in constant time.
- HTTP request bodies are capped at 16 KiB (
413 body_too_large),metadataat 1024 bytes, andlink_urlat 512 bytes.link_urlis validated after substituting{ticket}and{code}to enforcehttps://(unlessOAUTHMC_ALLOW_HTTP_LINKS=1), a valid host without userinfo, and RFC 3986 URI characters only. - HTTP connections enforce header timeout (
OAUTHMC_API_HEADER_TIMEOUT_SECONDS, default10s), body timeout (OAUTHMC_API_BODY_TIMEOUT_SECONDS, default10s), and concurrency cap (OAUTHMC_MAX_API_CONNECTIONS, default256) to mitigate slowloris attacks. - Ticket storage is capped globally (
OAUTHMC_MAX_TICKETS, default10000) and per key (OAUTHMC_MAX_TICKETS_PER_KEY, default1000), counting expired tickets still inside their grace period. At capacity,POST /v1/ticketsreturns503 ticket_limit. - Minecraft connections enforce
OAUTHMC_MAX_PACKET_LEN(4096bytes during Handshake/Login; Configuration streams and discards non-Keep-Alive packets up to 1 MiB without buffering),OAUTHMC_MAX_HANDSHAKE_ADDR_LEN(255bytes),OAUTHMC_LOGIN_TIMEOUT_SECONDS(10s),OAUTHMC_MAX_CONNECTIONS(256), andOAUTHMC_MAX_CONNECTIONS_PER_IP(16). - Held link-mode DoS controls: held sessions stay open for up to
OAUTHMC_LINK_HOLD_SECONDS(default600s, capped by ticket TTL). Four controls keep them from starving code-mode logins or status pings:OAUTHMC_MAX_HELDdefaults to half ofOAUTHMC_MAX_CONNECTIONS(128), and startup rejects any value>= OAUTHMC_MAX_CONNECTIONS. Excess link-mode joins fall back to a code-mode disconnect.OAUTHMC_MAX_HELD_PER_IP(default2per/32or/64) caps held connections per IP bucket and falls back to code mode above the cap.- At most one held connection is kept per ticket. Rejoining disconnects the older held connection immediately with
replaced(omitting{code}and{link}). - Redeeming (
verified), locking (locked, omitting{code}and{link}), expiring or deleting (expired), or missing a Configuration Keep Alive for 30 seconds disconnects immediately and releases all slots.
Always bind OAUTHMC_API_ADDR to loopback or a private container network. Never expose the HTTP API to the public internet.