fix(function): validate custom tool param keys before code interpolation#4474
fix(function): validate custom tool param keys before code interpolation#4474waleedlatif1 merged 2 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Adds Reviewed by Cursor Bugbot for commit 507ccba. Configure here. |
Greptile SummaryThis PR hardens the custom tool executor by validating parameter key names before interpolating them into generated JS code in the isolated-vm path. Two complementary guards are added: a
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to adding two input-validation guards that are applied consistently at both code-generation sites. Both previously flagged issues (reserved-word bypass that caused SyntaxError at runtime, and silent key dropping with no observability) have been resolved. The JS_RESERVED_WORDS set covers the full ES2023 reserved-word list, isSafeParamKey composes the two checks correctly, and the warning log makes skipped keys visible. The E2B paths are unaffected because they serialise params as JSON rather than interpolating key names. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[POST handler receives executionParams] --> B{isCustomTool?}
B -- No --> F[Execute code directly]
B -- Yes --> C[Iterate param keys]
C --> D{isSafeParamKey check}
D -- Valid identifier and not reserved --> E[Emit const binding]
D -- Invalid or reserved word --> G[logger.warn and skip key]
E --> H[wrapperLines for isolated-vm]
E --> I[paramDestructuring in codeToExecute]
H --> J[executeInIsolatedVM]
I --> J
J --> K[Return result to caller]
Reviews (2): Last reviewed commit: "fix(function): exclude JS reserved words..." | Re-trigger Greptile |
waleedlatif1
left a comment
There was a problem hiding this comment.
Both issues addressed in the follow-up commit (507ccba):
P1 (reserved keywords): Added a JS_RESERVED_WORDS set at module level covering all ES2023 reserved words and strict-mode future-reserved words. The isSafeParamKey helper now checks both the identifier regex and the reserved-word exclusion — so return, const, class, etc. are filtered out before interpolation.
P2 (silent skip): Skipped keys now emit a logger.warn with the key name and request ID, so failures are visible in logs rather than producing a silent ReferenceError inside the sandbox.
|
@greptile |
|
@cursor review |
…ion (#4474) * fix(function): validate custom tool param keys before code interpolation * fix(function): exclude JS reserved words from param key injection guard
Summary
SAFE_IDENTIFIERregex (/^[a-zA-Z_][a-zA-Z0-9_]*$/) to filter param keys before they are interpolated into generated JS code in the custom tool executorCredit: @Maxx191
Type of Change
Testing
Tested manually
Checklist