Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-updateallpackages-validation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@voltagent/core": patch
---

fix(core): add package name validation to updateAllPackages to prevent command injection
10 changes: 10 additions & 0 deletions packages/core/src/utils/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,21 @@ export const updateAllPackages = async (
const packageManager = detectPackageManager(rootDir);

// 3. Prepare the package list for updating
const validPkgName = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
const packagesToUpdate = updateCheckResult.updates
.filter((pkg) => pkg.type !== "latest")
.filter((pkg) => validPkgName.test(pkg.name))
.map((pkg) => `${pkg.name}@latest`);

const logger = new LoggerProxy({ component: "update-checker" });

if (packagesToUpdate.length === 0) {
return {
success: true,
message: "No packages to update after filtering invalid package names",
};
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

logger.info(`Updating ${packagesToUpdate.length} packages in ${rootDir}`);

// 4. Run the update command based on package manager
Expand Down
Loading