Skip to content

improvement(tools): prevent internal request self-hops - #7190

Merged
icecrasher321 merged 17 commits into
stagingfrom
codex/internal-operation-guidance
Aug 28, 2026
Merged

improvement(tools): prevent internal request self-hops#7190
icecrasher321 merged 17 commits into
stagingfrom
codex/internal-operation-guidance

Conversation

@icecrasher321

@icecrasher321 icecrasher321 commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • forbid tool definitions from routing execution through same-origin Sim API endpoints
  • document the in-process operation boundary across integration, tool, block, and trigger guidance
  • remove the obsolete request.internal audit policy and replace it with self-hop regression coverage

Type of Change

  • Improvement

Testing

  • bun run lint
  • bun run type-check
  • bun run check:audits
  • focused tool request and internal operation registry tests

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 28, 2026 5:35am

Request Review

@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR prevents integration tools from routing execution back through Sim’s own HTTP API and moves internal work behind registered in-process operations.

  • Adds static auditing and authoritative runtime rejection for same-origin tool requests, including self-hosted loopback aliases.
  • Migrates internal file, function, knowledge, memory, guardrail, table, MCP, and workflow functionality to typed operation handlers.
  • Updates execution context propagation, delegated principals, provenance handling, documentation, and regression coverage for the new boundary.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/tools/index.ts Adds the authoritative runtime self-origin guard, redirect checks, and loopback-alias matching; the previously reported alias bypass is fixed.
scripts/check-tool-request-boundary.ts Expands the static audit to resolve indirect request policies and URL expressions while failing closed on unresolved prohibited request forms.
apps/sim/tools/types.ts Defines the mutually exclusive external-request and registered internal-operation tool boundaries.
apps/sim/lib/internal/principals/executor.ts Centralizes executor-principal binding and supports deriving operation delegations from trusted execution deadlines.
apps/sim/lib/function-execution/execute-request.ts Replaces internal HTTP-oriented execution handoffs with scoped in-process execution and workspace-file delegated principals.
apps/sim/lib/core/security/input-validation.server.ts Supports the runtime network boundary with shared URL and loopback validation behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Tool[Tool invocation] --> Boundary{Execution boundary}
  Boundary -->|InternalToolConfig.operation| Registry[Internal operation registry]
  Registry --> Handler[In-process authorized handler]
  Boundary -->|External ToolConfig.request| Guard[Self-origin and SSRF guards]
  Guard -->|External origin| Provider[External provider]
  Guard -->|Sim origin| Reject[Reject self-hop]
Loading

Reviews (12): Last reviewed commit: "fix(tools): block self-hosted loopback a..." | Re-trigger Greptile

Comment thread scripts/check-tool-request-boundary.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread scripts/check-tool-request-boundary.ts Outdated
Comment thread scripts/check-tool-request-boundary.ts Outdated
Comment thread scripts/check-tool-request-boundary.ts Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 65 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/sim/lib/internal/file/execute-tool.ts Outdated
Comment thread apps/sim/lib/workspace-files/application/delegated-principal.ts Outdated
Comment thread apps/sim/tools/index.test.ts Outdated
Comment thread apps/sim/tools/params.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile-apps review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 72 files

Confidence score: 3/5

  • In apps/sim/lib/internal/file/parser.ts, actorless executions can no longer parse public profile-pictures, og-images, or workspace-logos files because assertUserFileContentAccess requires userId first; preserve the legacy world-readable access path for these public files.
  • In apps/sim/lib/internal/file/operations.test.ts, the mock and assertion target an authorization function that operations.ts no longer calls, leaving the in-process assertOperationFileAccess gate effectively unverified; update the test to mock and assert the current access check.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/sim/lib/internal/file/parser.ts">

<violation number="1" location="apps/sim/lib/internal/file/parser.ts:128">
P2: Actorless executions can no longer parse public `profile-pictures`, `og-images`, or `workspace-logos` files. `assertUserFileContentAccess` requires `userId` before reaching the legacy world-readable check; let public reads short-circuit without a user identity.</violation>
</file>

<file name="apps/sim/lib/internal/file/operations.test.ts">

<violation number="1" location="apps/sim/lib/internal/file/operations.test.ts:815">
P2: The mock module and its assertion point at a function the code under test never calls. operations.ts no longer imports @/app/api/files/authorization — its file-access gate is the in-process assertOperationFileAccess -> assertUserFileContentAccess from materialization.server — so expect(mockVerifyFileAccess).not.toHaveBeenCalled() is trivially true and provides no self-hop regression coverage (the PR's stated purpose). Either drop the dead @/app/api/files/authorization mock and its assertion, or assert against the actual in-process gate that materialization.server now uses; without that the test gives false assurance that the actorless path skips authorization.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread scripts/check-tool-request-boundary.ts
Comment thread apps/sim/lib/internal/file/parser.ts
Comment thread apps/sim/lib/internal/file/operations.test.ts Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile-apps review this PR

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

Comment thread scripts/check-tool-request-boundary.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 73 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread scripts/check-tool-request-boundary.ts Outdated
Comment thread apps/sim/lib/execution/payloads/materialization.server.ts Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile-apps review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 76 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

You’re at about 94% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Re-trigger cubic

Comment thread scripts/check-tool-request-boundary.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile-apps review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 79 files

You’re at about 96% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Re-trigger cubic

Comment thread apps/sim/tools/index.ts
Comment thread scripts/check-tool-request-boundary.ts Outdated
Comment thread scripts/check-tool-request-boundary.ts Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile-apps review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 81 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

You’re at about 97% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Re-trigger cubic

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile-apps review this PR

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

Greptile loopback-alias finding was valid and is fixed in f1d95a6. The runtime guard now treats loopback names/IPs as the same self-hosted origin only when protocol and effective port match, covering initial requests and every redirect hop. Different loopback ports remain valid local-provider targets, while the explicit http_request/webhook_request same-origin capability is unchanged. Regressions cover localhost, 127.0.0.1, another 127/8 alias, IPv6 ::1, redirects, different ports, and the generic HTTP exception.

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 81 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

You’re at about 98% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Re-trigger cubic

@icecrasher321
icecrasher321 merged commit d8ebcc0 into staging Aug 28, 2026
30 checks passed
@icecrasher321
icecrasher321 deleted the codex/internal-operation-guidance branch August 28, 2026 05:52
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.

1 participant