[engine.io-client] The Node.js cookie jar lets Expires override Max-Age
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 88/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- node.js, typescript
- Lĩnh vực
- backend, networking
Hướng nghiên cứu
Bắt đầu với parse() trong packages/engine.io-client/lib/globals.node.ts và bài kiểm thử “should parse a complex set-cookie header” trong packages/engine.io-client/test/node.js. Kiểm tra cách xử lý Expires và Max-Age khi cả hai cùng xuất hiện, sau đó cập nhật bài kiểm thử để bao quát cả hai thứ tự thuộc tính của header và mức độ ưu tiên mong đợi. Hoàn tất khi Max-Age quyết định thời hạn hết hạn của cookie bất kể thứ tự thuộc tính và các bài kiểm thử phân tích hiện có đều đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
With withCredentials: true in Node.js, the cookie jar of engine.io-client applies the Expires and Max-Age attributes in the order they appear in the Set-Cookie header, so whichever comes last wins. According to RFC 6265 (section 5.3, step 3) and MDN, Max-Age takes precedence over Expires when both are present.
Two consequences:
- A cookie like
sid=abc; Max-Age=3600; Path=/; Expires=<date>(which is what Express sends forres.cookie("sid", "abc", { maxAge: 3600000 })) is dropped right away when the client clock is ahead of the server clock by more than the max age, because theExpiresdate is already in the past for the client. WithMax-Agetaking precedence, the cookie would be kept for one hour. - A deletion like
sid=abc; Max-Age=0; Expires=<future date>is ignored, and the cookie keeps being sent.
The existing test "should parse a complex set-cookie header" in packages/engine.io-client/test/node.js also expects the Expires date for a header that carries Max-Age=1000 before Expires.
To Reproduce
Engine.IO server version: 6.6.11
Engine.IO client version: 6.6.8 (also reproduced on main at e94e021)
Server and client
const { createServer } = require("http");
const { attach } = require("engine.io");
const { Socket } = require("engine.io-client");
const setCookie = process.argv[2];
const httpServer = createServer();
const engine = attach(httpServer);
httpServer.prependListener("request", (req) => {
if (req.url.includes("sid=")) {
console.log("cookie header on a later request:", req.headers.cookie);
}
});
engine.on("initial_headers", (headers) => {
headers["set-cookie"] = [setCookie];
});
httpServer.listen(3000, () => {
const socket = new Socket("http://localhost:3000", {
transports: ["polling"],
withCredentials: true,
});
socket.on("open", () => {
setTimeout(() => {
socket.close();
engine.close();
httpServer.close();
}, 200);
});
});
Results:
Set-Cookie sent with the handshake |
cookie header on the next request |
|---|---|
sid=abc; Max-Age=3600; Path=/ |
sid=abc |
sid=abc; Max-Age=3600; Path=/; Expires=<one minute ago> |
none |
sid=abc; Max-Age=0; Path=/; Expires=Fri, 01 Jan 2100 00:00:00 GMT |
sid=abc |
Expected behavior
When a Set-Cookie header has both attributes, the expiry comes from Max-Age, whatever their order: the second cookie is kept for one hour and the third one is removed.
Platform:
- Device: desktop
- OS: Windows, Node.js 24.22.1 (the cookie jar is only used in Node.js)
Additional context
The parsing happens in parse() in packages/engine.io-client/lib/globals.node.ts. I'm happy to send a PR with a test.
AI-assisted: found and reproduced with an AI coding agent; the example above was run locally.
- Ngôn ngữ chính
- TypeScript
- Star
- 63.2k
- Fork
- 10.2k
- Merge trung bình
- 6 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của socketio/socket.io
-
Raise Engine.IO minimum to 6.6.10 for published security fixesCó thể đã có người làm @harshit-exe-dev đã nhận 27 ngày trước. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Can't set response headers in Server.handleUpgradeCó thể đã có người làm @MsfPablo đã nhận 89 ngày trước. Đang mởquestion
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
socketio/socket.io#5497 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
WebTransport ignores query parameters in URLCó thể đã có người làm @cyphercodes đã nhận 177 ngày trước. Đang mởneeds major release question
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
socketio/socket.io#5496 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
cleanupEmptyChildNamespaces releases a child namespace while a socket is in its middleware, and the cleanup unregisters a newer namespace by nameCó thể đã có người làm @Jeremiah-D đã nhận 5 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 54/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Direct Sockets APIĐang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của socketio/socket.io
Issue tương tự
-
Bug: Cloudflare Pages static _redirects identity rule causes RSC Flight to reload as HTMLCó thể đã có người làm @Donvero đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Mantitup-Org/vista#210 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
simstudioai/sim#9831 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
status: waiting for maintainer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
mui/material-ui#49751 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
diplodoc-platform/transform#1184 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
JonasKruckenberg/imagetools#973 ·
Maintainer thường phản hồi trong vòng 1 ngày