Skip to content

Potential fix for code scanning alert no. 10: Resource exhaustion#12

Draft
noisyloop wants to merge 1 commit into
mainfrom
alert-autofix-10
Draft

Potential fix for code scanning alert no. 10: Resource exhaustion#12
noisyloop wants to merge 1 commit into
mainfrom
alert-autofix-10

Conversation

@noisyloop

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/m0rs3c0d3/EverythingOS/security/code-scanning/10

In general, the problem is that a user‑controlled value (node.timeout) is being passed directly to setTimeout as a delay in milliseconds. To fix this in a robust way, we need to validate and constrain any timeout value before it is used: ensure it is a finite integer within a reasonable range (for example between 0 and some maximum like 30_000 or 60_000 milliseconds). If the value is invalid or exceeds the maximum, we should either reject it (throw an error / fail the node), or fall back to a safe default.

The single best fix with minimal functional impact is to enforce bounds in WorkflowEngine.executeWithTimeout, because that is the single choke point where timeouts are applied for all nodes, regardless of how the workflow was created or where timeout came from. We can:

  • Normalize timeout to a number (e.g., Number(timeout)),
  • Reject non‑finite or negative values,
  • Clamp very large values to a configured maximum duration MAX_NODE_TIMEOUT_MS, and
  • Use that sanitized value in setTimeout.

If the sanitized timeout ends up as 0 (due to invalid input), we can treat it as "no timeout" and simply call the handler directly to preserve existing behavior where no timeout was intended. This avoids having to modify the API server or the registry logic and keeps all changes localized to WorkflowEngine.ts. No new external dependencies are required; we can rely on built‑in JS/TS functionality.

Concretely, in src/core/workflow/WorkflowEngine.ts, we will modify executeWithTimeout to:

  • Compute a safeTimeout from the input timeout:
    • If timeout is not a finite number or is negative, treat it as 0 (no timeout).
    • If it exceeds a chosen maximum (e.g. 60 seconds), clamp it to that maximum.
  • If safeTimeout is 0, call handler(node, context) directly.
  • Otherwise, use safeTimeout in setTimeout and in the error message instead of the raw timeout.

This directly prevents attackers from creating arbitrarily long timers while maintaining current functionality for sane timeout values.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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.

noisyloop pushed a commit that referenced this pull request Mar 10, 2026
- Bump tar to 7.5.11 and minimatch to 3.1.5 (dependabot PRs #16, #17)
- Fix resource exhaustion (alert #10): add 1MB body size limit in API
  server parseBody and 10MB line buffer cap in MCP stdio transport
- Fix unvalidated dynamic method call (alert #12): validate plugin/action
  identifiers against allowlist pattern before dynamic dispatch
- Add input schema validation in PluginRegistry.execute
- Add command allowlist to MCPStdioTransport to prevent arbitrary spawns
- Fix symlink sandbox escape in file-ops by resolving real paths
- Block internal event types from external API emission

https://claude.ai/code/session_019XKgAhVu9mEc6NuLMMb5Wn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants