Security: Unsafe IPC handler accepts unknown type without validation#1978
Open
ed-thuando wants to merge 1 commit intostacklok:mainfrom
Open
Conversation
In main/src/ipc-handlers/utils.ts, the 'utils:get-workload-available-tools' handler accepts an `unknown` type for the workload parameter without validating the input. This allows any data to be passed to getWorkloadAvailableTools() without type checking or sanitization. Affected files: utils.ts Signed-off-by: ed-thuando <231172918+ed-thuando@users.noreply.github.com>
Collaborator
|
thank you @ed-thuando can we also add the correct type in preload/src/api/utils.ts it should be |
samuv
added a commit
that referenced
this pull request
Apr 17, 2026
…ools handler The handler previously forwarded the raw `workload` argument straight to getWorkloadAvailableTools, which expects the generated CoreWorkload type. An earlier attempt (#1978) introduced a local `Workload` interface with `name: string` and an `isWorkload` guard that only checked `typeof value' === `object`, so it neither matched the real type nor actually enforced a name. - Add `isCoreWorkload` that rejects non-objects, `null`, and arrays, and validates `name`, `url`, `transport_type`, `proxy_mode`, `port`, and `remote` match their declared types when present - Throw a `TypeError` at the IPC boundary for malformed payloads instead of forwarding them into the AI SDK / MCP client - Reuse `GithubComStacklokToolhivePkgCoreWorkload` from `@common/api/generated/types.gen` rather than defining a parallel type
samuv
added a commit
that referenced
this pull request
Apr 17, 2026
…ools handler The handler previously forwarded the raw `workload` argument straight to getWorkloadAvailableTools, which expects the generated CoreWorkload type. An earlier attempt (#1978) introduced a local `Workload` interface with `name: string` and an `isWorkload` guard that only checked `typeof value' === `object`, so it neither matched the real type nor actually enforced a name. - Add `isCoreWorkload` that rejects non-objects, `null`, and arrays, and validates `name`, `url`, `transport_type`, `proxy_mode`, `port`, and `remote` match their declared types when present - Throw a `TypeError` at the IPC boundary for malformed payloads instead of forwarding them into the AI SDK / MCP client - Reuse `GithubComStacklokToolhivePkgCoreWorkload` from `@common/api/generated/types.gen` rather than defining a parallel type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Security: Unsafe IPC handler accepts unknown type without validation
Problem
Severity:
High| File:main/src/ipc-handlers/utils.ts:L19In main/src/ipc-handlers/utils.ts, the 'utils:get-workload-available-tools' handler accepts an
unknowntype for the workload parameter without validating the input. This allows any data to be passed to getWorkloadAvailableTools() without type checking or sanitization.Solution
Add proper type validation for the workload parameter. Define an expected interface and validate the input before passing to getWorkloadAvailableTools(). Example: Create a type for Workload and use type guards to ensure the input matches expected structure.
Changes
main/src/ipc-handlers/utils.ts(modified)Testing
Generated by ContribAI v6.0.0