5e9c6d6780
Add path validation to the copy method in both JS and Python SDKs to ensure source paths are always relative and don't escape the context directory. This prevents: - Absolute paths like /absolute/whatever (Unix) or C:\whatever (Windows) - Path traversal attacks like ../whatever or ./foo/../../../bar The validation works cross-platform using Node's path.isAbsolute/normalize and Python's os.path.isabs/normpath plus PureWindowsPath for detecting Windows paths on Unix. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes behavior of `copy`/`copy_items` to throw earlier for previously-accepted absolute or escaping paths, which could break some consumers; logic is localized and well-covered by tests. > > **Overview** > Prevents path traversal in template `copy` operations by validating `src` is *relative* and does not escape the context directory (rejects absolute paths and `..`-based escapes) in both the JS and Python SDKs. > > Updates `copyItems`/`copy_items` error handling to preserve the caller’s stack trace when validation fails, adds unit coverage for the new path validator plus new stack-trace tests for absolute-path failures, and ships as patch releases via a changeset. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c1a8eb978e3fd99fa829d571e811bb7ee18cd40b. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>