Skip to content

fix(vector): keep embedding inputs, zip entries and stored documents inside their folders - #3386

Merged
kunal0137 merged 6 commits into
devfrom
fix-snyk-vector-paths
Nov 24, 2026
Merged

kunal0137 merged 6 commits into
devfrom
fix-snyk-vector-paths

Conversation

@kunal0137

@kunal0137 kunal0137 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Snyk Code path traversal findings in the vector reactors and engines, plus the same bug class in removeDocument found in review.

  • CreateEmbeddingsFromDocumentsReactor / CreateEmbeddingsFromVectorCSVFileReactor:
    • filePaths now go through the existing Utility.resolveContainedFile. Before, ../../x reached the vector engine, so any user with edit access to a vector DB could read arbitrary files into it.
    • The hand-rolled zip loops (the CSV one wrote entries to disk unchecked, a zip slip) are replaced by ZipUtils.unzipNested. It is built on the existing limit-checked ZipUtils.unzip, with one shared entry/byte budget and one rollback across all nesting levels (depth cap 5), and a separate folder per zip.
    • Both reactors clean up their extract folder.
  • AbstractVectorDatabaseEngine.storedDocument: a listed or removed document's local copy is used only when it is a regular file directly inside the documents folder (no ., .., separators, NUL or symlink escape).
    • listDocuments uses it in eight engines.
    • removeDocument uses it in nine engines, so a crafted name can no longer delete a parent folder.

Behaviour changes

  • An embedding path that is missing or outside the insight/project space fails with "File path for does not exist within the insight or project space."
  • Zips of documents now actually extract (the old loop only listed entries). Nested zip content lands in <name>-<random> folders.
  • Removing a document that has no stored copy logs a warning and still removes the index entries.

Testing

  • Compile, plus a standalone check:
    • a zip with a ../ entry is refused and leaves nothing behind;
    • the cumulative entry/byte caps trip across nesting levels and roll back;
    • a next to a.zip and a file named .zip extract correctly;
    • storedDocument refuses .., sub/../a, symlinks out of the folder and directories.
  • Not exercised live (needs a vector DB plus an embedding model).

Notes

AwsS3VectorDatabaseEngine has the same pattern but belongs to #3016; apply storedDocument there after #3016 merges. Rows whose room-folder path is fixed by #3016 were left for it.

Related Snyk PRs

Independent of each other unless noted; none are stacked.

…ight space

Resolve filePaths with Utility.resolveContainedFile and extract zips with the
limit-checked ZipUtils.unzip (new unzipNested for nested zips) instead of the
hand-rolled ZipInputStream loops that trusted entry names.
…n the documents folder

The source names a vector database returns can be arbitrary (CSV Source column); a name with a path no longer reaches new File(documentsDir, name).
@snyk-io

snyk-io Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@kunal0137
kunal0137 merged commit 15fe5f9 into dev Nov 24, 2026
2 of 3 checks passed
@kunal0137
kunal0137 deleted the fix-snyk-vector-paths branch November 24, 2026 21:51
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