-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"node:net.Socket": Data Cross-Reception Issue Between Independent Server-Socket Pairs #20188
Comments
@bartlomieju do you have an ETA for fixing this? |
No, not yet. Earliest I'll be able to look into it is next week. |
@DSergiu thank you greatly for the excellent repro. This was enough to track down the issue. I've turned it into a test case and we'll land a fix ASAP. |
Reported in #20188 This was caused by re-use of a global buffer `BUF` during simultaneous async reads.
Reported in #20188 This was caused by re-use of a global buffer `BUF` during simultaneous async reads.
(Redacted until better fix is merged.) Edit: Now that the fix is released, I should point out that this enabled bugs similar to CVE-2023-28858 @mmastrac it would be appropriate to issue a CVE here. I note Deno is not yet registered as a vendor: https://www.cve.org/PartnerInformation/ListofPartners which would be a good idea. |
There seems to still be an issue with concurrent reads. Here is a test using // To run this test:
// 1. Start a redis server instance: "docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest"
// 2. Run test: "deno test -A ./ioredis.test.ts"
import { assertEquals } from "https://deno.land/std@0.198.0/assert/assert_equals.ts";
import { Redis } from "npm:ioredis";
const redisCon = "redis://127.0.0.1:6379";
function buildRedisClient(db: number): Redis {
const logPrefix = `${redisCon} db=${db}`;
return new Redis(redisCon, {
db,
}).on("error", (err: Error) => {
console.error(`${logPrefix}: error`, err.message);
}).on("close", () => {
console.log(`${logPrefix}: close`);
}).on("end", () => {
console.log(`${logPrefix}: end`);
}).on("connect", () => {
console.log(`${logPrefix}: connected`, arguments);
}).on("reconnecting", () => {
console.log(`${logPrefix}: reconnecting`, arguments);
}).on("ready", () => {
console.log(`${logPrefix}: ready`, arguments);
});
}
Deno.test({
name: "Concurrent ioredis clients",
sanitizeResources: false,
sanitizeOps: false,
}, async (t) => {
const redis1 = buildRedisClient(1);
const redis2 = buildRedisClient(2);
await t.step("it should set and get a value from multiple dbs", async () => {
const key1 = "key1";
const key2 = "key2";
await Promise.all([
redis1.set(key1, "111"),
redis2.set(key2, "222"),
]);
const [actual1, actual2, none] = await Promise.all([
redis1.get(key1),
redis2.get(key2),
redis1.get("key3"),
]);
assertEquals(actual1, "111"); // This fails, actual1 is "222"
assertEquals(actual2, "222");
assertEquals(none, null);
});
await redis1.disconnect();
await redis2.disconnect();
}); here are some logs for stream
Deno version:
|
The fix for #20188 was not entirely correct -- we were unlocking the global buffer incorrectly. This PR introduces a lock state that ensures we only unlock a lock we have taken out.
|
The fix for #20188 was not entirely correct -- we were unlocking the global buffer incorrectly. This PR introduces a lock state that ensures we only unlock a lock we have taken out.
Issue Description
When testing two pairs of independent server-socket connections using the provided code, an unexpected data cross-reception issue occurs. The setup involves creating two separate servers, each with their corresponding client socket. The servers receive data from their respective sockets and echo the data back. However, during the test, the data sent by one socket is received by the other socket. This issue leads to incorrect data reception and potential data corruption.
This issue affects any Deno code using node packages that rely on
require(net)
. Example:. having 2ioredis.Redis
clients connecting to 2 Redis Servers results in issues since one client might receive data from the other client which does not correspond with the actual redis command being sent, thus it results in unexpected errors.Steps to Reproduce
socket.test.ts
with the provided test code.deno test -A ./socket.test.ts
Expected Behavior
The expected behavior is that each socket should receive the data it sent, without any cross-reception. Specifically:
Actual Behavior
After running the test, the issue arises where:
Environment Details
Test Code
The text was updated successfully, but these errors were encountered: