fix(execution): scope X-Sim-Via header to internal routes and enforce depth limit#3313
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile SummaryThis PR fixes a security issue where the
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Incoming Request\n(API or MCP)"] --> B["Parse X-Sim-Via Header\n(parseCallChain)"]
B --> C{"Validate Depth\n>= 10?"}
C -->|Yes| D["Return 409\nDepth Exceeded"]
C -->|No| E["Build Next Chain\n(append workflowId)"]
E --> F["Execute Workflow"]
F --> G{"Child Workflow\n(inline)?"}
G -->|Yes| H["Build Child Chain\n(append childWorkflowId)"]
H --> I{"Validate Child\nDepth >= 10?"}
I -->|Yes| J["Throw ChildWorkflowError"]
I -->|No| K["Execute Child\n(with childCallChain)"]
G -->|No| L{"Outgoing HTTP\nRequest?"}
L -->|Internal Route| M["Set X-Sim-Via Header\n(tools/index.ts)"]
L -->|External Route| N["No X-Sim-Via Header\n(prevents ID leakage)"]
M --> A
Last reviewed commit: 27e9560 |
…ld workflow depth validation - Move call chain header injection from HTTP tool layer (request.ts/utils.ts) to tool execution layer (tools/index.ts) gated on isInternalRoute, preventing internal workflow IDs from leaking to external third-party APIs - Remove cycle detection from validateCallChain — depth limit alone prevents infinite loops while allowing legitimate self-recursion (pagination, tree processing, batch splitting) - Add validateCallChain check in workflow-handler.ts before spawning child executor, closing the gap where in-process child workflows skipped validation - Remove unsafe `(params as any)._context` type bypass in request.ts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
|
@cursor review |
Collaborator
Author
Validate childCallChain (after appending current workflow ID) rather than ctx.callChain (parent). Prevents an off-by-one where a chain at depth 10 could still spawn an 11th workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
Collaborator
Author
|
@cursor review |
royceP2
pushed a commit
to arenadeveloper02/p2-sim
that referenced
this pull request
Mar 3, 2026
… depth limit (simstudioai#3313) * feat(execution): workflow cycle detection via X-Sim-Via header * fix(execution): scope X-Sim-Via header to internal routes and add child workflow depth validation - Move call chain header injection from HTTP tool layer (request.ts/utils.ts) to tool execution layer (tools/index.ts) gated on isInternalRoute, preventing internal workflow IDs from leaking to external third-party APIs - Remove cycle detection from validateCallChain — depth limit alone prevents infinite loops while allowing legitimate self-recursion (pagination, tree processing, batch splitting) - Add validateCallChain check in workflow-handler.ts before spawning child executor, closing the gap where in-process child workflows skipped validation - Remove unsafe `(params as any)._context` type bypass in request.ts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(execution): validate child call chain instead of parent chain Validate childCallChain (after appending current workflow ID) rather than ctx.callChain (parent). Prevents an off-by-one where a chain at depth 10 could still spawn an 11th workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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
X-Sim-Viaheader to internal routes only — previously it was attached to all outgoing HTTP requests, leaking internal workflow IDs to external third-party APIsvalidateCallChain— depth limit of 10 alone prevents infinite loops while allowing legitimate self-recursion (pagination, tree traversal, batch splitting)workflow-handler.tsbefore spawning child executors — previously in-process child workflows skipped validation entirely(params as any)._contexttype bypass inrequest.tsby moving header injection totools/index.tswhere_contextis already accessedType of Change
Testing
Checklist