Skip to content

Commit 3e80060

Browse files
committed
fix: convert AxiosHeaders to plain object to prevent invalid Cookie headers
1 parent 8e5f5fc commit 3e80060

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Common/Server/Utils/VM/VMRunner.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,25 @@ export default class VMRunner {
176176
throw new Error(`Unsupported HTTP method: ${method}`);
177177
}
178178

179+
// Convert AxiosHeaders to a plain object before serializing.
180+
// JSON.stringify calls AxiosHeaders.toJSON(key) with a truthy key,
181+
// which makes it join array headers (like set-cookie) with commas.
182+
// This produces invalid Cookie headers when user code forwards them.
183+
const plainHeaders: Record<string, unknown> = {};
184+
185+
if (response.headers) {
186+
for (const key of Object.keys(
187+
response.headers as Record<string, unknown>,
188+
)) {
189+
plainHeaders[key] = (
190+
response.headers as Record<string, unknown>
191+
)[key];
192+
}
193+
}
194+
179195
return JSON.stringify({
180196
status: response.status,
181-
headers: response.headers,
197+
headers: plainHeaders,
182198
data: response.data,
183199
});
184200
},

0 commit comments

Comments
 (0)