Repository navigation
fix: constant-time game-server secret, loopback internal port, moderator-only /fly and /teleport - #47
Merged
NickMesser merged 4 commits intoOct 27, 2026
Conversation
… on mismatch Registration compared the shared secret with != (a timing oracle) and left the internal connection open after the error reply, so one connection could keep guessing. Compare with subtle::ConstantTimeEq and, after the existing five-second error reply, close the connection. Proof: new socket test wrong_secret_is_refused_and_the_connection_is_closed failed on the previous handler (error reply then no EOF after 2 s, 7.02 s run) and passes with the fix (5.22 s); full aaemu-login suite 201 lib + 5 network tests passed, 0 failed, 7 ignored.
The shipped login config listened on every interface for the game-server protocol, so an exposed host ran the internal unauthenticated surface (and default SecretKey) publicly. Bind 127.0.0.1 by default; the Docker login service explicitly asks for * because the game container reaches it over the compose network and the port is not published. Proof: new shipped_internal_network_binds_loopback test failed on the previous Config.json (left *, right 127.0.0.1) and passes with the loopback default.
AccessLevels.json shipped fly and teleport at level 0, and the command manager enforces exactly that table, so any player could toggle fly mode and teleport across the world. Move both commands to the moderator level (50), like the other moderator commands; the Web API loopback default and its bearer authentication are already upstream. Proof: new fly_and_teleport_require_moderator_access test loads the shipped AccessLevels.json and failed on the old table (level-0 fly was not refused: left [] vs Insufficient privileges) and passes now; the shipped_configuration_binds_every_section test also asserts both levels. Command suite: 164 passed, 0 failed; cargo clippy -p aaemu-game --all-targets -- -D warnings clean.
…cret The delayed reply task left the reader running for five seconds, so a peer could send more guesses, and a wrong secret followed by the correct one in that window registered the connection (the first task then closed it). Set a poisoned flag on the connection before scheduling the reply: handle_g2l ignores every later packet, the delayed Error reply is still sent, and the connection closes 200 ms later. Proof: new socket test wrong_secret_poisons_the_connection_before_a_correct_registration failed on the previous handler (the correct secret returned Success) and passes now; the existing token test now expects Error for the poisoned socket and Success for the unregistered one. Full aaemu-login: 202 lib + 6 network tests passed, 0 failed, 7 ignored.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The login server compared the game-server shared secret with
!=and left the internal connection open after a wrong secret, so one connection could keep guessing; the shipped internal listener also accepted connections on every interface. Separately,/flyand/teleportshipped at access level 0, so any player could toggle flight and teleport across the world.subtle::ConstantTimeEqand poison the connection on a mismatch: every later packet is ignored (a correct secret inside the five-second window cannot register it), the delayedErrorreply is still sent, then the connection closes.InternalNetworkto127.0.0.1; the Docker login service setsInternalNetwork__Host="*"because the game container reaches that port over the compose network and it is never published on the host. Packets from unregistered internal peers are already refused byauthorize_game_server.flyandteleportto the moderator level (50) in the shippedAccessLevels.json.Breaking change: the shipped login
InternalNetwork.Hostis now127.0.0.1. A game server running on a different host must setInternalNetwork:Host(for example"*"or the interface address); the compose login service already overrides it withInternalNetwork__Host.Validation of executed source
60358661e(tests and full CI; the live checks below ran on58481b71e, whose only later delta is the poison flag and its tests):wrong_secret_is_refused_and_the_connection_is_closedfails on the previous handler: it receivesLGRegisterGameServerwith resultErrorand then no EOF within 2 s (Err(Elapsed), 7.02 s run). With the fix it passes: error reply after the five-second delay, then EOF (5.22 s). A second socket testwrong_secret_poisons_the_connection_before_a_correct_registrationfails on the branch before this fix (the later correct secret returnedSuccess) and passes now: a wrong secret followed by the correct one produces only the delayedErrorreply.unauthorized_internal_tokens_are_rejected_over_socketsexpectsErrorfor the poisoned socket andSuccessfor the unregistered one, andsecret_comparison_accepts_only_the_exact_secretpasses. Fullaaemu-login: 202 lib + 6 network tests passed, 0 failed, 7 ignored (1 lib and 6 MySQL-gated).shipped_internal_network_binds_loopbackfails on the previousConfig.json(left "*", right "127.0.0.1") and passes with the loopback default.fly_and_teleport_require_moderator_accessloads the shippedAccessLevels.json; on the old table a level-0 player's/flyran instead of returning a refusal (left [] vs Insufficient privileges). Now both commands answer|cFFFF0000Insufficient privileges.|rwith no fly/teleport packet, while level 50 still runs both.shipped_configuration_binds_every_sectionalso asserts both levels. Command suite: 164 passed, 0 failed.aaemu-testclient, one account and character at access level 0:AccessLevels.json):/teleport solisreturned[teleport] Teleporting to |cFFFFFFFFSolis Headlands, Austera|randSCTeleportUnitPacket;/flyreturnedState changed to ...andSCUnitFlyingStateChangedPacket(2 commands).|cFFFF0000Insufficient privileges.|r, with noSCTeleportUnitPacketand noSCUnitFlyingStateChangedPacket(2 commands).03 00 00 00 01(LGRegisterGameServer, resultError) followed by EOF; the login log showsConnection 127.0.0.1, bad secret keyandGameServer from 127.0.0.1 disconnectedabout 6 s later (1 case).cargo xtask cion the branch: 3,929 passed, 0 failed, 177 ignored across 97 test binaries; workspace formatting, all-target Clippy with warnings denied, the packet coverage ratchet (517 S->C opcodes, 105 typeless, 65 typed but never sent) and 7 Python tests passed.Limits: constant-time comparison is by construction (
subtle::ConstantTimeEq), not a timing measurement. The five-second delayed error reply (retail/C# timing) is kept, with closure 200 ms later; a poisoned connection ignores later packets until that close, and new connections can still attempt registrations (no rate limit). The unregistered-connection handshake window and slot cap,AutoAccount, and the Docker MySQL/Adminer exposure are unchanged; the existing authorization already blocks actions from unregistered peers, but a peer can still hold an unregistered socket until it disconnects. Access levels change the shipped defaults only, so existingConfig.Local.json/AccessLevels.jsonoverrides still win. The live checks used the headless test client, not the retail 1.2 client, and/fly's per-character state cache makes the refusal, not the state text, the evidence. No full gameplay regression suite was run.Review: an independent reviewer (R1) read the diff, the close/poison logic against
network/internal.rs, every config and script that binds or uses the internal port, and every use of/flyand/teleportin scripts, the test client and the verify suites: qualified clear. Its one code finding (a correct secret sent inside the error-reply window could still register) is fixed in60358661ewith the poison test above.🤖 Generated with Claude Code