惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Engineering at Meta
Engineering at Meta
D
DataBreaches.Net
月光博客
月光博客
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
U
Unit 42
腾讯CDC
爱范儿
爱范儿
J
Java Code Geeks
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
B
Blog
Stack Overflow Blog
Stack Overflow Blog
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
Microsoft Azure Blog
Microsoft Azure Blog
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(gateway): reject malformed request targets (#82686) ·...
eleqtrizit · 2026-05-17 · via Recent Commits to openclaw:main

@@ -1,5 +1,5 @@

11

import type { IncomingMessage, ServerResponse } from "node:http";

2-

import type { Socket } from "node:net";

2+

import { connect, type Socket } from "node:net";

33

import type { Duplex } from "node:stream";

44

import { describe, expect, test } from "vitest";

55

import { WebSocket, WebSocketServer } from "ws";

@@ -172,6 +172,50 @@ async function expectWsConnected(url: string, headers?: Record<string, string>):

172172

});

173173

}

174174175+

async function sendRawHttpRequest(params: {

176+

host: string;

177+

port: number;

178+

requestTarget: string;

179+

headers?: readonly string[];

180+

}): Promise<string> {

181+

return new Promise<string>((resolve, reject) => {

182+

const socket = connect({ host: params.host, port: params.port }, () => {

183+

const headers = params.headers ?? ["Host: localhost", "Connection: close"];

184+

socket.write([`GET ${params.requestTarget} HTTP/1.1`, ...headers, "", ""].join("\r\n"));

185+

});

186+

let response = "";

187+

let settled = false;

188+

const finish = (fn: () => void) => {

189+

if (settled) {

190+

return;

191+

}

192+

settled = true;

193+

socket.setTimeout(0);

194+

fn();

195+

};

196+

socket.setEncoding("utf8");

197+

socket.setTimeout(WS_REJECT_TIMEOUT_MS, () => {

198+

const error = new Error("timeout");

199+

finish(() => {

200+

socket.destroy(error);

201+

reject(error);

202+

});

203+

});

204+

socket.on("data", (chunk) => {

205+

response += chunk;

206+

});

207+

socket.once("end", () => {

208+

finish(() => resolve(response));

209+

});

210+

socket.once("close", () => {

211+

finish(() => resolve(response));

212+

});

213+

socket.once("error", (err) => {

214+

finish(() => reject(err));

215+

});

216+

});

217+

}

218+175219

function makeWsClient(params: {

176220

connId: string;

177221

clientIp: string;

@@ -408,6 +452,53 @@ describe("gateway plugin node capability auth", () => {

408452

}, "openclaw-canvas-auth-test-");

409453

}, 60_000);

410454455+

test("rejects malformed raw HTTP request targets without disrupting gateway", async () => {

456+

await withCanvasGatewayHarness({

457+

resolvedAuth: tokenResolvedAuth,

458+

handleHttpRequest: allowCanvasHostHttp,

459+

run: async ({ listener }) => {

460+

for (const requestTarget of ["//", "///", "//${jndi:ldap://example}.action"]) {

461+

const response = await sendRawHttpRequest({

462+

host: "127.0.0.1",

463+

port: listener.port,

464+

requestTarget,

465+

});

466+

expect(response).toMatch(/^HTTP\/1\.1 401 /);

467+

}

468+469+

const res = await fetchCanvas(`http://127.0.0.1:${listener.port}${CANVAS_HOST_PATH}/`);

470+

expect(res.status).toBe(401);

471+

},

472+

});

473+

}, 60_000);

474+475+

test("rejects malformed raw WebSocket upgrade targets without disrupting gateway", async () => {

476+

await withCanvasGatewayHarness({

477+

resolvedAuth: tokenResolvedAuth,

478+

handleHttpRequest: allowCanvasHostHttp,

479+

run: async ({ listener }) => {

480+

for (const requestTarget of ["//", "///", "//${jndi:ldap://example}.action"]) {

481+

const response = await sendRawHttpRequest({

482+

host: "127.0.0.1",

483+

port: listener.port,

484+

requestTarget,

485+

headers: [

486+

"Host: localhost",

487+

"Upgrade: websocket",

488+

"Connection: Upgrade",

489+

"Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==",

490+

"Sec-WebSocket-Version: 13",

491+

],

492+

});

493+

expect(response).toMatch(/^HTTP\/1\.1 401 /);

494+

}

495+496+

const res = await fetchCanvas(`http://127.0.0.1:${listener.port}${CANVAS_HOST_PATH}/`);

497+

expect(res.status).toBe(401);

498+

},

499+

});

500+

}, 60_000);

501+411502

test("denies canvas auth when trusted proxy omits forwarded client headers", async () => {

412503

await withLoopbackTrustedProxy(async () => {

413504

await withCanvasGatewayHarness({