Repository navigation
fix(cloud-storage): resolve symlinks when enforcing local path boundaries - #3810
Conversation
…ries allowedLocalRoots and the download tool's destination_dir both decided whether a path was in bounds by inspecting the path string, then handed the unresolved name to os.Open/os.OpenFile. A symbolic link planted under an allowed root therefore passed the check and opened its target, wherever that was: upload_object would read a file outside the root and send it to Cloud Storage, and download_object would write through the link. The write escape did not require overwrite=true. O_CREATE|O_EXCL does reject a symlinked final component, but an intermediate directory link -- root/dir -> /elsewhere -- still lands the file outside the root under the default overwrite=false. Both boundaries now compare the symlink-resolved target in addition to the name. Roots are resolved as well, so a root reached through a link (/tmp on macOS, a symlinked workspace) keeps matching, and links resolving back inside a root keep working. Destinations that do not exist yet resolve as deeply as the filesystem allows; a dangling link is rejected rather than treated as a missing name, since creating that path would follow it. Two limits are documented rather than fixed: hard links are indistinguishable from regular files, and the check still precedes the open, so anything able to write into an allowed root can swap a component in between. OS permissions remain the enforcing boundary.
There was a problem hiding this comment.
Code Review
This pull request introduces robust symbolic link resolution and validation for local filesystem access within the cloud storage source. It updates validateLocalPath and ResolveWithinDir to resolve symlinks for both the input paths and the allowed root directories before performing boundary checks, preventing potential directory traversal bypasses via symlinks. Comprehensive unit tests and documentation updates have been added to cover these changes. No review comments were provided, so there is no feedback to address.
|
@twishabansal This seems good to me. Could you give it a review and make sure it fixes the CVE? Thanks! |
|
@duwenxin99 looks good to me. Thank you for the fix @huangjiahua ! |
|
/gcbrun |
|
/gcbrun |
|
/gcbrun |
…local path boundaries (#3810) ## Description `allowedLocalRoots` (source) and `destination_dir` (the download tool) both decided whether a local path was in bounds by inspecting the **path string**, then handed the unresolved name to `os.Open`/`os.OpenFile`. Neither resolved symbolic links, so a link placed under an allowed root passed the check and opened its target wherever that was: - `cloud-storage-upload-object` reads a file outside the root and sends it to Cloud Storage. - `cloud-storage-download-object` writes through the link to a file outside the root. The write escape does **not** require `overwrite=true`. `O_CREATE|O_EXCL` does reject a symlinked final component, but an intermediate directory link — `root/dir -> /elsewhere` — still lands the file outside the root under the default `overwrite=false`. ### Solution New `cloudstoragecommon.ResolveSymlinks` returns a path's final filesystem target, handling two cases a bare `filepath.EvalSymlinks` does not: - **Nonexistent leaves.** `EvalSymlinks` returns `ENOENT` for a path that doesn't exist yet, which is the normal case for a download destination. It resolves the deepest existing ancestor and reattaches the missing components literally. - **Dangling links.** These also return `ENOENT`, and treating one as "just a missing file" would reopen the escape, since a later create follows the link. Rejected instead. Both boundaries now compare the resolved target *in addition to* the name: - `Source.validateLocalPath` requires the path to be under an allowed root both as written and after resolution. Keeping the name check first means rejection messages still name what the caller asked for, and guarantees the new behavior is never looser than the old. - `ResolveWithinDir` gets the same treatment for `destination_dir`, which had the identical flaw. Roots are resolved too, so a root reached through a link (`/tmp` on macOS, a symlinked workspace) keeps matching, and links resolving back inside a root keep working. ### Known limits (documented, not fixed) - **Hard links** are indistinguishable from regular files to any resolver. - **TOCTOU**: the check still precedes the open, so anything able to write into an allowed root can swap a component in between. Closing this would mean moving enforcement to `os.Root`/`openat2` at the point of I/O — a larger change; happy to follow up if reviewers prefer it here. `source.md` now states the guarantee and both limits, and keeps the guidance that OS permissions are the enforcing boundary. ### Behavior change A workspace that legitimately symlinks *out* of an allowed root is now rejected. That is the intent of the fix, but it may surface as a bug report. ## PR Checklist - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/mcp-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/mcp-toolbox/issues/new/choose) before writing your code! — this came from an external security report rather than a filed issue; happy to open one if that is preferred - [x] Ensure the tests and linter pass — full unit suite (`./cmd/... ./internal/...`), `go vet`, and `gofmt` pass. `golangci-lint` was not available locally and has not been run - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change — tightens validation rather than changing an API, so filed as `fix`; see "Behavior change" above ## Testing Each fix was reverted in turn to confirm the new tests fail without it. `TestAllowedLocalRootSymlinkEscape` reproduces the reported scenario against the unpatched source: ``` --- FAIL: TestAllowedLocalRootSymlinkEscape validateLocalPath(".../allowed/innocent.txt") accepted a path escaping ".../allowed"; it reads "OUTSIDE_SECRET" from ".../outside/secret.txt" ``` All four `destination_dir` escape cases likewise fail against the unpatched `ResolveWithinDir`. Coverage added for: escaping link leaf, escaping intermediate directory link, new file under an escaping directory link, dangling link, links resolving back inside the root, roots reached through a link, and unset `allowedLocalRoots` remaining unrestricted — across both boundaries. 🛠️ Fixes #<issue_number_goes_here> Co-authored-by: Twisha Bansal <[email protected]> Co-authored-by: Wenxin Du <[email protected]>
…local path boundaries (googleapis#3810) ## Description `allowedLocalRoots` (source) and `destination_dir` (the download tool) both decided whether a local path was in bounds by inspecting the **path string**, then handed the unresolved name to `os.Open`/`os.OpenFile`. Neither resolved symbolic links, so a link placed under an allowed root passed the check and opened its target wherever that was: - `cloud-storage-upload-object` reads a file outside the root and sends it to Cloud Storage. - `cloud-storage-download-object` writes through the link to a file outside the root. The write escape does **not** require `overwrite=true`. `O_CREATE|O_EXCL` does reject a symlinked final component, but an intermediate directory link — `root/dir -> /elsewhere` — still lands the file outside the root under the default `overwrite=false`. ### Solution New `cloudstoragecommon.ResolveSymlinks` returns a path's final filesystem target, handling two cases a bare `filepath.EvalSymlinks` does not: - **Nonexistent leaves.** `EvalSymlinks` returns `ENOENT` for a path that doesn't exist yet, which is the normal case for a download destination. It resolves the deepest existing ancestor and reattaches the missing components literally. - **Dangling links.** These also return `ENOENT`, and treating one as "just a missing file" would reopen the escape, since a later create follows the link. Rejected instead. Both boundaries now compare the resolved target *in addition to* the name: - `Source.validateLocalPath` requires the path to be under an allowed root both as written and after resolution. Keeping the name check first means rejection messages still name what the caller asked for, and guarantees the new behavior is never looser than the old. - `ResolveWithinDir` gets the same treatment for `destination_dir`, which had the identical flaw. Roots are resolved too, so a root reached through a link (`/tmp` on macOS, a symlinked workspace) keeps matching, and links resolving back inside a root keep working. ### Known limits (documented, not fixed) - **Hard links** are indistinguishable from regular files to any resolver. - **TOCTOU**: the check still precedes the open, so anything able to write into an allowed root can swap a component in between. Closing this would mean moving enforcement to `os.Root`/`openat2` at the point of I/O — a larger change; happy to follow up if reviewers prefer it here. `source.md` now states the guarantee and both limits, and keeps the guidance that OS permissions are the enforcing boundary. ### Behavior change A workspace that legitimately symlinks *out* of an allowed root is now rejected. That is the intent of the fix, but it may surface as a bug report. ## PR Checklist - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/mcp-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/mcp-toolbox/issues/new/choose) before writing your code! — this came from an external security report rather than a filed issue; happy to open one if that is preferred - [x] Ensure the tests and linter pass — full unit suite (`./cmd/... ./internal/...`), `go vet`, and `gofmt` pass. `golangci-lint` was not available locally and has not been run - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change — tightens validation rather than changing an API, so filed as `fix`; see "Behavior change" above ## Testing Each fix was reverted in turn to confirm the new tests fail without it. `TestAllowedLocalRootSymlinkEscape` reproduces the reported scenario against the unpatched source: ``` --- FAIL: TestAllowedLocalRootSymlinkEscape validateLocalPath(".../allowed/innocent.txt") accepted a path escaping ".../allowed"; it reads "OUTSIDE_SECRET" from ".../outside/secret.txt" ``` All four `destination_dir` escape cases likewise fail against the unpatched `ResolveWithinDir`. Coverage added for: escaping link leaf, escaping intermediate directory link, new file under an escaping directory link, dangling link, links resolving back inside the root, roots reached through a link, and unset `allowedLocalRoots` remaining unrestricted — across both boundaries. 🛠️ Fixes #<issue_number_goes_here> Co-authored-by: Twisha Bansal <[email protected]> Co-authored-by: Wenxin Du <[email protected]>
…local path boundaries (googleapis#3810) ## Description `allowedLocalRoots` (source) and `destination_dir` (the download tool) both decided whether a local path was in bounds by inspecting the **path string**, then handed the unresolved name to `os.Open`/`os.OpenFile`. Neither resolved symbolic links, so a link placed under an allowed root passed the check and opened its target wherever that was: - `cloud-storage-upload-object` reads a file outside the root and sends it to Cloud Storage. - `cloud-storage-download-object` writes through the link to a file outside the root. The write escape does **not** require `overwrite=true`. `O_CREATE|O_EXCL` does reject a symlinked final component, but an intermediate directory link — `root/dir -> /elsewhere` — still lands the file outside the root under the default `overwrite=false`. ### Solution New `cloudstoragecommon.ResolveSymlinks` returns a path's final filesystem target, handling two cases a bare `filepath.EvalSymlinks` does not: - **Nonexistent leaves.** `EvalSymlinks` returns `ENOENT` for a path that doesn't exist yet, which is the normal case for a download destination. It resolves the deepest existing ancestor and reattaches the missing components literally. - **Dangling links.** These also return `ENOENT`, and treating one as "just a missing file" would reopen the escape, since a later create follows the link. Rejected instead. Both boundaries now compare the resolved target *in addition to* the name: - `Source.validateLocalPath` requires the path to be under an allowed root both as written and after resolution. Keeping the name check first means rejection messages still name what the caller asked for, and guarantees the new behavior is never looser than the old. - `ResolveWithinDir` gets the same treatment for `destination_dir`, which had the identical flaw. Roots are resolved too, so a root reached through a link (`/tmp` on macOS, a symlinked workspace) keeps matching, and links resolving back inside a root keep working. ### Known limits (documented, not fixed) - **Hard links** are indistinguishable from regular files to any resolver. - **TOCTOU**: the check still precedes the open, so anything able to write into an allowed root can swap a component in between. Closing this would mean moving enforcement to `os.Root`/`openat2` at the point of I/O — a larger change; happy to follow up if reviewers prefer it here. `source.md` now states the guarantee and both limits, and keeps the guidance that OS permissions are the enforcing boundary. ### Behavior change A workspace that legitimately symlinks *out* of an allowed root is now rejected. That is the intent of the fix, but it may surface as a bug report. ## PR Checklist - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/mcp-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/mcp-toolbox/issues/new/choose) before writing your code! — this came from an external security report rather than a filed issue; happy to open one if that is preferred - [x] Ensure the tests and linter pass — full unit suite (`./cmd/... ./internal/...`), `go vet`, and `gofmt` pass. `golangci-lint` was not available locally and has not been run - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change — tightens validation rather than changing an API, so filed as `fix`; see "Behavior change" above ## Testing Each fix was reverted in turn to confirm the new tests fail without it. `TestAllowedLocalRootSymlinkEscape` reproduces the reported scenario against the unpatched source: ``` --- FAIL: TestAllowedLocalRootSymlinkEscape validateLocalPath(".../allowed/innocent.txt") accepted a path escaping ".../allowed"; it reads "OUTSIDE_SECRET" from ".../outside/secret.txt" ``` All four `destination_dir` escape cases likewise fail against the unpatched `ResolveWithinDir`. Coverage added for: escaping link leaf, escaping intermediate directory link, new file under an escaping directory link, dangling link, links resolving back inside the root, roots reached through a link, and unset `allowedLocalRoots` remaining unrestricted — across both boundaries. 🛠️ Fixes #<issue_number_goes_here> Co-authored-by: Twisha Bansal <[email protected]> Co-authored-by: Wenxin Du <[email protected]>
…local path boundaries (googleapis#3810) ## Description `allowedLocalRoots` (source) and `destination_dir` (the download tool) both decided whether a local path was in bounds by inspecting the **path string**, then handed the unresolved name to `os.Open`/`os.OpenFile`. Neither resolved symbolic links, so a link placed under an allowed root passed the check and opened its target wherever that was: - `cloud-storage-upload-object` reads a file outside the root and sends it to Cloud Storage. - `cloud-storage-download-object` writes through the link to a file outside the root. The write escape does **not** require `overwrite=true`. `O_CREATE|O_EXCL` does reject a symlinked final component, but an intermediate directory link — `root/dir -> /elsewhere` — still lands the file outside the root under the default `overwrite=false`. ### Solution New `cloudstoragecommon.ResolveSymlinks` returns a path's final filesystem target, handling two cases a bare `filepath.EvalSymlinks` does not: - **Nonexistent leaves.** `EvalSymlinks` returns `ENOENT` for a path that doesn't exist yet, which is the normal case for a download destination. It resolves the deepest existing ancestor and reattaches the missing components literally. - **Dangling links.** These also return `ENOENT`, and treating one as "just a missing file" would reopen the escape, since a later create follows the link. Rejected instead. Both boundaries now compare the resolved target *in addition to* the name: - `Source.validateLocalPath` requires the path to be under an allowed root both as written and after resolution. Keeping the name check first means rejection messages still name what the caller asked for, and guarantees the new behavior is never looser than the old. - `ResolveWithinDir` gets the same treatment for `destination_dir`, which had the identical flaw. Roots are resolved too, so a root reached through a link (`/tmp` on macOS, a symlinked workspace) keeps matching, and links resolving back inside a root keep working. ### Known limits (documented, not fixed) - **Hard links** are indistinguishable from regular files to any resolver. - **TOCTOU**: the check still precedes the open, so anything able to write into an allowed root can swap a component in between. Closing this would mean moving enforcement to `os.Root`/`openat2` at the point of I/O — a larger change; happy to follow up if reviewers prefer it here. `source.md` now states the guarantee and both limits, and keeps the guidance that OS permissions are the enforcing boundary. ### Behavior change A workspace that legitimately symlinks *out* of an allowed root is now rejected. That is the intent of the fix, but it may surface as a bug report. ## PR Checklist - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/mcp-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/mcp-toolbox/issues/new/choose) before writing your code! — this came from an external security report rather than a filed issue; happy to open one if that is preferred - [x] Ensure the tests and linter pass — full unit suite (`./cmd/... ./internal/...`), `go vet`, and `gofmt` pass. `golangci-lint` was not available locally and has not been run - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change — tightens validation rather than changing an API, so filed as `fix`; see "Behavior change" above ## Testing Each fix was reverted in turn to confirm the new tests fail without it. `TestAllowedLocalRootSymlinkEscape` reproduces the reported scenario against the unpatched source: ``` --- FAIL: TestAllowedLocalRootSymlinkEscape validateLocalPath(".../allowed/innocent.txt") accepted a path escaping ".../allowed"; it reads "OUTSIDE_SECRET" from ".../outside/secret.txt" ``` All four `destination_dir` escape cases likewise fail against the unpatched `ResolveWithinDir`. Coverage added for: escaping link leaf, escaping intermediate directory link, new file under an escaping directory link, dangling link, links resolving back inside the root, roots reached through a link, and unset `allowedLocalRoots` remaining unrestricted — across both boundaries. 🛠️ Fixes #<issue_number_goes_here> Co-authored-by: Twisha Bansal <[email protected]> Co-authored-by: Wenxin Du <[email protected]>
…3846) ## Description Three gaps in the `review-prs` maintainer skill surfaced while using it to review #3810 (a symlink-escape fix in the Cloud Storage source). - **Verification** (`## Rules`): `[UNVERIFIED]` was being reached for where fetching the branch and running a scratch test would have settled the question. Records the worktree + package-local `probe_test.go` technique — package-local placement is what reaches unexported symbols. In that one review, probing changed the verdict four times, twice shrinking a claimed regression to a much narrower one. - **Security** (Step 6): the dimension covers *introducing* vulnerabilities but says nothing about reviewing a *fix* to one, where reachability of the residual attack primitive and the direction the failure leans decide blocker vs. tracked follow-up. - **Docs** (Step 6): covers CI-enforced structure and missing updates, but not prose asserting a guarantee the implementation does not deliver. Skill prose only — no code, config, or tooling changes.
🤖 I have created a release *beep* *boop* --- ## [1.10.0](v1.9.0...v1.10.0) (2026-08-27) ### Features * **falkordb:** Add FalkorDB source and tools ([#3692](#3692)) ([a94702c](a94702c)) * **firestore-mongodb:** Add firestore-execute-mql and firestore-get-… ([#3826](#3826)) ([4a85d75](4a85d75)) * **mcp:** Add Secure Parameters support as Toolbox experimental extension ([#3394](#3394)) ([9750d2d](9750d2d)) * **server/mcp:** Support com.google.cloud/toolbox.v1 extension in v20260728 ([#3801](#3801)) ([f4f7da6](f4f7da6)) * **skill:** Add fix-failing-tests skill for mcp-toolbox ([#3821](#3821)) ([168e69c](168e69c)) * **sources:** Support native read-only mode and dynamic tool annotations ([#3872](#3872)) ([c257022](c257022)), refs [#3615](#3615) [#3816](#3816) [#3618](#3618) [#3851](#3851) [#3619](#3619) [#3617](#3617) * **tool/mongodb:** Allow collection to be specified at runtime ([#3715](#3715)) ([7626eaf](7626eaf)) ### Bug Fixes * **cloud-storage:** Resolve symlinks when enforcing local path boundaries ([#3810](#3810)) ([c2ada64](c2ada64)) * **config:** Compare env var offsets in rune space when skipping comments ([#3856](#3856)) ([2e76934](2e76934)) * Merge prebuilt tools when reloading custom config ([#3864](#3864)) ([5a6d865](5a6d865)) * Normalize postgres UUIDs to strings ([#3806](#3806)) ([3b02f1d](3b02f1d)) * **postgres:** Filter background processes in postgres-list-active-queries ([#3885](#3885)) ([3d9e62a](3d9e62a)) * **test/alloydbainl:** Use explicit SQL alias prompts to stabilize AI… ([#3877](#3877)) ([50e45ed](50e45ed)) * **tests:** Prevent resource leaks by using context.WithoutCancel ([#3849](#3849)) ([f97a4f9](f97a4f9)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Yuan Teoh <[email protected]>
🤖 I have created a release *beep* *boop* --- ## [1.10.0](v1.9.0...v1.10.0) (2026-08-27) ### Features * **falkordb:** Add FalkorDB source and tools ([#3692](#3692)) ([a94702c](a94702c)) * **firestore-mongodb:** Add firestore-execute-mql and firestore-get-… ([#3826](#3826)) ([4a85d75](4a85d75)) * **mcp:** Add Secure Parameters support as Toolbox experimental extension ([#3394](#3394)) ([9750d2d](9750d2d)) * **server/mcp:** Support com.google.cloud/toolbox.v1 extension in v20260728 ([#3801](#3801)) ([f4f7da6](f4f7da6)) * **skill:** Add fix-failing-tests skill for mcp-toolbox ([#3821](#3821)) ([168e69c](168e69c)) * **sources:** Support native read-only mode and dynamic tool annotations ([#3872](#3872)) ([c257022](c257022)), refs [#3615](#3615) [#3816](#3816) [#3618](#3618) [#3851](#3851) [#3619](#3619) [#3617](#3617) * **tool/mongodb:** Allow collection to be specified at runtime ([#3715](#3715)) ([7626eaf](7626eaf)) ### Bug Fixes * **cloud-storage:** Resolve symlinks when enforcing local path boundaries ([#3810](#3810)) ([c2ada64](c2ada64)) * **config:** Compare env var offsets in rune space when skipping comments ([#3856](#3856)) ([2e76934](2e76934)) * Merge prebuilt tools when reloading custom config ([#3864](#3864)) ([5a6d865](5a6d865)) * Normalize postgres UUIDs to strings ([#3806](#3806)) ([3b02f1d](3b02f1d)) * **postgres:** Filter background processes in postgres-list-active-queries ([#3885](#3885)) ([3d9e62a](3d9e62a)) * **test/alloydbainl:** Use explicit SQL alias prompts to stabilize AI… ([#3877](#3877)) ([50e45ed](50e45ed)) * **tests:** Prevent resource leaks by using context.WithoutCancel ([#3849](#3849)) ([f97a4f9](f97a4f9)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Yuan Teoh <[email protected]>
mcp-toolbox 1.10.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## [1.10.0](googleapis/mcp-toolbox@v1.9.0...v1.10.0) (2026-08-27) ### Features * **falkordb:** Add FalkorDB source and tools ([#3692](googleapis/mcp-toolbox#3692)) ([a94702c](googleapis/mcp-toolbox@a94702c)) * **mcp:** Add Secure Parameters support as Toolbox experimental extension ([#3394](googleapis/mcp-toolbox#3394)) ([9750d2d](googleapis/mcp-toolbox@9750d2d)) * **server/mcp:** Support com.google.cloud/toolbox.v1 extension in v20260728 ([#3801](googleapis/mcp-toolbox#3801)) ([f4f7da6](googleapis/mcp-toolbox@f4f7da6)) * **skill:** Add fix-failing-tests skill for mcp-toolbox ([#3821](googleapis/mcp-toolbox#3821)) ([168e69c](googleapis/mcp-toolbox@168e69c)) * **sources:** Support native read-only mode and dynamic tool annotations ([#3872](googleapis/mcp-toolbox#3872)) ([c257022](googleapis/mcp-toolbox@c257022)), refs [#3615](googleapis/mcp-toolbox#3615) [#3816](googleapis/mcp-toolbox#3816) [#3618](googleapis/mcp-toolbox#3618) [#3851](googleapis/mcp-toolbox#3851) [#3619](googleapis/mcp-toolbox#3619) [#3617](googleapis/mcp-toolbox#3617) * **tools/firestore-mongodb:** Add tools for execute mql and get schema ([#3826](googleapis/mcp-toolbox#3826)) ([4a85d75](googleapis/mcp-toolbox@4a85d75)) * **tool/mongodb:** Allow collection to be specified at runtime ([#3715](googleapis/mcp-toolbox#3715)) ([7626eaf](googleapis/mcp-toolbox@7626eaf)) ### Bug Fixes * **cloud-storage:** Resolve symlinks when enforcing local path boundaries ([#3810](googleapis/mcp-toolbox#3810)) ([c2ada64](googleapis/mcp-toolbox@c2ada64)) * **config:** Compare env var offsets in rune space when skipping comments ([#3856](googleapis/mcp-toolbox#3856)) ([2e76934](googleapis/mcp-toolbox@2e76934)) * Merge prebuilt tools when reloading custom config ([#3864](googleapis/mcp-toolbox#3864)) ([5a6d865](googleapis/mcp-toolbox@5a6d865)) * Normalize postgres UUIDs to strings ([#3806](googleapis/mcp-toolbox#3806)) ([3b02f1d](googleapis/mcp-toolbox@3b02f1d)) * **postgres:** Filter background processes in postgres-list-active-queries ([#3885](googleapis/mcp-toolbox#3885)) ([3d9e62a](googleapis/mcp-toolbox@3d9e62a)) | **OS/Architecture** | **Description** | **SHA256 Hash** | | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------- | | [linux/amd64](https://storage.googleapis.com/mcp-toolbox-for-databases/v1.10.0/linux/amd64/toolbox) ([Signature](https://storage.googleapis.com/mcp-toolbox-for-databases/v1.10.0/linux/amd64/toolbox.asc)) | For **Linux** systems running on **Intel/AMD 64-bit processors**. | 7e15dba09e6f957f64ce5924a0aa06b12cdf83ab26119813b0fa40edab566dd4 | | [darwin/arm64](https://storage.googleapis.com/mcp-toolbox-for-databases/v1.10.0/darwin/arm64/toolbox) | For **macOS** systems running on **Apple Silicon** (M1, M2, M3, etc.) processors. | c994f06781462abba4171cb4844776c45605e391c57dc96adb3e130c81b53825 | | [darwin/amd64](https://storage.googleapis.com/mcp-toolbox-for-databases/v1.10.0/darwin/amd64/toolbox) | For **macOS** systems running on **Intel processors**. | 12ebf78d9d05e8f3fe90c5d02ae14f2ccd96cf036f3dfba430bc32e3cfeadfd4 | | [windows/amd64](https://storage.googleapis.com/mcp-toolbox-for-databases/v1.10.0/windows/amd64/toolbox.exe) | For **Windows** systems running on **Intel/AMD 64-bit processors**. | 734783941cb5864c0e5d4d78be625f8b12be23b01d94781d7fa7db9b3c25aac6 | | [windows/arm64](https://storage.googleapis.com/mcp-toolbox-for-databases/v1.10.0/windows/arm64/toolbox.exe) | For **Windows** systems running on **ARM 64-bit processors**. | d9be7c2ce1d2e29c20f2974cbac4cde857adad836cee565d2584f3fbcc97f096 |</pre> <p>View the full release notes at <a href="https://github.com/googleapis/mcp-toolbox/releases/tag/v1.10.0">https://github.com/googleapis/mcp-toolbox/releases/tag/v1.10.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!17982
Description
allowedLocalRoots(source) anddestination_dir(the download tool) both decided whether a local path was in bounds by inspecting the path string, then handed the unresolved name toos.Open/os.OpenFile. Neither resolved symbolic links, so a link placed under an allowed root passed the check and opened its target wherever that was:cloud-storage-upload-objectreads a file outside the root and sends it to Cloud Storage.cloud-storage-download-objectwrites through the link to a file outside the root.The write escape does not require
overwrite=true.O_CREATE|O_EXCLdoes reject a symlinked final component, but an intermediate directory link —root/dir -> /elsewhere— still lands the file outside the root under the defaultoverwrite=false.Solution
New
cloudstoragecommon.ResolveSymlinksreturns a path's final filesystem target, handling two cases a barefilepath.EvalSymlinksdoes not:EvalSymlinksreturnsENOENTfor a path that doesn't exist yet, which is the normal case for a download destination. It resolves the deepest existing ancestor and reattaches the missing components literally.ENOENT, and treating one as "just a missing file" would reopen the escape, since a later create follows the link. Rejected instead.Both boundaries now compare the resolved target in addition to the name:
Source.validateLocalPathrequires the path to be under an allowed root both as written and after resolution. Keeping the name check first means rejection messages still name what the caller asked for, and guarantees the new behavior is never looser than the old.ResolveWithinDirgets the same treatment fordestination_dir, which had the identical flaw.Roots are resolved too, so a root reached through a link (
/tmpon macOS, a symlinked workspace) keeps matching, and links resolving back inside a root keep working.Known limits (documented, not fixed)
os.Root/openat2at the point of I/O — a larger change; happy to follow up if reviewers prefer it here.source.mdnow states the guarantee and both limits, and keeps the guidance that OS permissions are the enforcing boundary.Behavior change
A workspace that legitimately symlinks out of an allowed root is now rejected. That is the intent of the fix, but it may surface as a bug report.
PR Checklist
./cmd/... ./internal/...),go vet, andgofmtpass.golangci-lintwas not available locally and has not been run!if this involve a breaking change — tightens validation rather than changing an API, so filed asfix; see "Behavior change" aboveTesting
Each fix was reverted in turn to confirm the new tests fail without it.
TestAllowedLocalRootSymlinkEscapereproduces the reported scenario against the unpatched source:All four
destination_direscape cases likewise fail against the unpatchedResolveWithinDir. Coverage added for: escaping link leaf, escaping intermediate directory link, new file under an escaping directory link, dangling link, links resolving back inside the root, roots reached through a link, and unsetallowedLocalRootsremaining unrestricted — across both boundaries.🛠️ Fixes #<issue_number_goes_here>