Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/core/workflow/WorkflowEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,26 @@
context: NodeContext,
timeout?: number
): Promise<NodeResult> {
if (!timeout) {
// Normalize and bound the timeout to prevent resource exhaustion from untrusted values
const MAX_NODE_TIMEOUT_MS = 60_000; // 60 seconds hard limit for node timeouts
const numericTimeout = typeof timeout === 'number' ? timeout : Number(timeout);
const safeTimeout =
Number.isFinite(numericTimeout) && numericTimeout > 0
? Math.min(Math.floor(numericTimeout), MAX_NODE_TIMEOUT_MS)
: 0;

// If there is no effective timeout, run the handler directly
if (!safeTimeout) {
return handler(node, context);
}

return Promise.race([
handler(node, context),
new Promise<NodeResult>((_, reject) =>
setTimeout(() => reject(new Error(`Node timeout: ${timeout}ms`)), timeout)
setTimeout(
() => reject(new Error(`Node timeout: ${safeTimeout}ms`)),
safeTimeout

Check failure

Code scanning / CodeQL

Resource exhaustion High

This creates a timer with a user-controlled duration from a
user-provided value
.

Copilot Autofix

AI 4 months ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

)
),
]);
}
Expand Down
Loading