PaperMC / PaperMC/Paper

invoking retrieveCookie(NamespacedKey) with the same namespace twice deletes the first retrive from the map, resulting in kicks

Open
#14,211 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: needs triage
Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

Expected behavior

When calling retrieveCookie(NamespacedKey) twice, both futures should be completed and the client should not be kicked.

Currently

@Override
public void handleCookieResponse(ServerboundCookieResponsePacket packet) {
    if (this.paperConnection().handleCookieResponse(packet)) return; // Paper
    this.disconnect(DISCONNECT_UNEXPECTED_QUERY, io.papermc.paper.connection.DisconnectionReason.INVALID_COOKIE); // Paper - kick event cause
}

kicks the player.

Because the second retrieveCookie call overrides the first because its a map, then when both cookies arrive the last one is not handled
https://github.com/PaperMC/Paper/blob/37dc5450d9b7acb2e367e8f1fbe0f07bb01334d9/paper-server/src/main/java/io/papermc/paper/connection/ReadablePlayerCookieConnectionImpl.java#L19

Observed/Actual behavior

Kick for Component.translatable("multiplayer.disconnect.unexpected_query_response")

Steps/models to reproduce

retriving the same cookie twice directly

Plugin and Datapack List
Paper version

latest

Other

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in paper-server/src/main/java/io/papermc/paper/connection/ReadablePlayerCookieConnectionImpl.java, then trace retrieveCookie(NamespacedKey) and handleCookieResponse(ServerboundCookieResponsePacket). Reproduce the case by retrieving the same cookie twice and verify that both futures complete without disconnecting the client for an unexpected query response.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.