Skip to content

Conversation

@joel-rieke
Copy link
Collaborator

Potential fix for https://github.com/trimble-oss/go-mysql-server/security/code-scanning/368

To fix this issue, we need to ensure that single quotes and other potentially dangerous characters in v are escaped correctly before being embedded into the SQL query string. This can be achieved by using a dedicated sanitization mechanism such as strings.ReplaceAll or adopting a structured API that avoids manual string construction.

Best way to fix:

  1. Escape single quotes within the value of v using strings.ReplaceAll to ensure that embedded quotes do not break the SQL structure.
  2. Replace the fmt.Sprintf("'%v'", v) with a sanitized version of v where single quotes and backslashes are appropriately escaped.
  3. Implement this directly within the convertColumnDefaultToString function.

Required changes:

  • Add sanitization logic using strings.ReplaceAll in the convertColumnDefaultToString function in sql/rowexec/show_iters.go.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…ting

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@joel-rieke joel-rieke marked this pull request as ready for review July 15, 2025 20:56
@joel-rieke joel-rieke merged commit 18d5d5e into main Jul 15, 2025
13 of 14 checks passed
@joel-rieke joel-rieke deleted the alert-autofix-368 branch July 15, 2025 21:01
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.

2 participants