Skip to content

Conversation

@andyedison
Copy link

Description

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported
  • Tests were added or are not required
  • Documentation was added or is not required

Deployment Notes

vitess-bot bot and others added 18 commits September 15, 2025 18:18
…d of calling `curl`. (vitessio#18650) (vitessio#18651)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
…hat don't cover the full range (vitessio#18641) (vitessio#18653)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Co-authored-by: Arthur Schreiber <[email protected]>
…o#18579) (vitessio#18631)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Co-authored-by: Arthur Schreiber <[email protected]>
)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
…) (vitessio#18669)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
…o#18681)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
…on (vitessio#18713) (vitessio#18720)

Signed-off-by: Arthur Schreiber <[email protected]>
Signed-off-by: Matt Lord <[email protected]>
Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
Co-authored-by: Matt Lord <[email protected]>
…ness (vitessio#18722) (vitessio#18723)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
…definitions when EnableViews is disabled (vitessio#18734)

Signed-off-by: Harshit Gangal <[email protected]>
…ations. (vitessio#18736) (vitessio#18745)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
…18790) (vitessio#18792)

Signed-off-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
Co-authored-by: Arthur Schreiber <[email protected]>
…ps` RPC (vitessio#18814) (vitessio#18816)

Signed-off-by: Tim Vaillancourt <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Co-authored-by: Tim Vaillancourt <[email protected]>
…inary for lastpk (vitessio#18852) (vitessio#18857)

Signed-off-by: Nick Van Wiggeren <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings November 4, 2025 19:15
return nil, fmt.Errorf("failed to parse backup path %q: %w", path, err)
}

fi, err := os.ReadDir(path)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix

AI about 1 month ago

To mitigate this vulnerability robustly:

  1. We must validate any user-controllable inputs (e.g., keyspace and shard) to ensure they do not contain path separators or .., and ideally, are a single path component.
  2. The best location for this validation is in grpcvtctldserver/server.go within the GetBackups handler (lines 1459 onward; specifically, before using filepath.Join(req.Keyspace, req.Shard)) since all paths downstream rely on this. This prevents any invalid keyspace/shard value from being used in a path, regardless of backup engine or underlying storage.
  3. Add a helper function (private to the file) to encapsulate this validation, checking for the presence of /, \, or .. in keyspace and shard. Return an error if the input is invalid.
  4. Use this function before constructing the bucket path.

Files/Regions to change:

  • go/vt/vtctl/grpcvtctldserver/server.go:
    • Add validation to GetBackups for both req.Keyspace and req.Shard before joining into a path.
    • Add a new validation helper if one is not already present.

Methods/Imports/Definitions needed:

  • Add a validatePathComponent helper function.
  • Import "strings" if not already present (already present).

Suggested changeset 1
go/vt/vtctl/grpcvtctldserver/server.go
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/go/vt/vtctl/grpcvtctldserver/server.go b/go/vt/vtctl/grpcvtctldserver/server.go
--- a/go/vt/vtctl/grpcvtctldserver/server.go
+++ b/go/vt/vtctl/grpcvtctldserver/server.go
@@ -80,6 +80,17 @@
 	"vitess.io/vitess/go/vt/vttablet/tmclient"
 )
 
+// validatePathComponent ensures the given string does not contain path separators or parent directory references.
+func validatePathComponent(component string) error {
+	if component == "" {
+		return errors.New("component is empty")
+	}
+	if strings.Contains(component, "/") || strings.Contains(component, "\\") || strings.Contains(component, "..") {
+		return fmt.Errorf("component %q must not contain '/' '\\' or '..'", component)
+	}
+	return nil
+}
+
 const (
 	initShardPrimaryOperation = "InitShardPrimary"
 
@@ -1462,6 +1473,14 @@
 
 	defer panicHandler(&err)
 
+	// Validate keyspace and shard to ensure they are single, safe path components.
+	if err := validatePathComponent(req.Keyspace); err != nil {
+		return nil, fmt.Errorf("invalid keyspace name: %v", err)
+	}
+	if err := validatePathComponent(req.Shard); err != nil {
+		return nil, fmt.Errorf("invalid shard name: %v", err)
+	}
+
 	span.Annotate("keyspace", req.Keyspace)
 	span.Annotate("shard", req.Shard)
 	span.Annotate("limit", req.Limit)
EOF
@@ -80,6 +80,17 @@
"vitess.io/vitess/go/vt/vttablet/tmclient"
)

// validatePathComponent ensures the given string does not contain path separators or parent directory references.
func validatePathComponent(component string) error {
if component == "" {
return errors.New("component is empty")
}
if strings.Contains(component, "/") || strings.Contains(component, "\\") || strings.Contains(component, "..") {
return fmt.Errorf("component %q must not contain '/' '\\' or '..'", component)
}
return nil
}

const (
initShardPrimaryOperation = "InitShardPrimary"

@@ -1462,6 +1473,14 @@

defer panicHandler(&err)

// Validate keyspace and shard to ensure they are single, safe path components.
if err := validatePathComponent(req.Keyspace); err != nil {
return nil, fmt.Errorf("invalid keyspace name: %v", err)
}
if err := validatePathComponent(req.Shard); err != nil {
return nil, fmt.Errorf("invalid shard name: %v", err)
}

span.Annotate("keyspace", req.Keyspace)
span.Annotate("shard", req.Shard)
span.Annotate("limit", req.Limit)
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors GitHub Actions workflow execution by replacing manual skip logic with native GitHub Actions triggers. The changes include removing custom workflow skip steps, updating action versions, adding OS optimizations, upgrading MySQL APT repository package versions, fixing a bug in shard range generation, implementing connection pool close handling, adding security improvements for file path operations, and supporting tuple bind variables in SQL evaluation.

Key changes:

  • Replaced manual workflow skip logic with declarative on triggers for branches/tags
  • Updated actions/setup-go from v5.0.2 to v5.5.0 across all workflows
  • Fixed off-by-one error in GenerateShardRanges function
  • Enhanced connection pool closure to prevent deadlocks
  • Added path traversal protection using SafePathJoin
  • Implemented tuple bind variable support in evalengine

Reviewed Changes

Copilot reviewed 134 out of 134 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Test templates (unit_test.tpl, cluster_*.tpl) Replaced on: [push, pull_request] with explicit branch/tag triggers and removed skip-workflow steps
GitHub workflow files (.github/workflows/*.yml) Applied template changes to generated workflows, updated setup-go action version
go/vt/key/key.go Fixed loop condition in GenerateShardRanges to prevent off-by-one error
go/pools/smartconnpool/*.go Refactored waitlist and pool closure to handle context cancellation properly
go/vt/mysqlctl/filebackupstorage/file.go Added SafePathJoin for path traversal protection
go/fileutil/join.go New utility for safe path joining
go/vt/vtgate/evalengine/*.go Added support for tuple bind variables in IN expressions
Database schema files Updated column types for better scalability
MAINTAINERS.md Updated maintainer list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

shardRanges := make([]string, 0, shards)

for i := 1; i <= shards; i++ {
for i := 1; i < shards; i++ {
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop condition i < shards correctly fixes the off-by-one error that was present in the original code (i <= shards). The original bug would generate shards + 1 ranges instead of shards ranges. The fix ensures exactly shards ranges are generated by iterating from 1 to shards-1, then appending the final range after the loop.

Copilot uses AI. Check for mistakes.
@andyedison andyedison merged commit 6ca745e into release-21.0-github Nov 4, 2025
175 of 210 checks passed
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.

5 participants