Skip to content

Conversation

@yuanoOo
Copy link
Contributor

@yuanoOo yuanoOo commented Sep 18, 2025

Description

Fixes SQL injection vulnerabilities in OceanBase connector's databaseExists and tableExists methods by replacing string concatenation with parameterized queries.

Changes

  • OceanBaseCatalog.java: Added parameterized query support to executeSingleColumnStatement
  • OceanBaseMySQLCatalog.java: Fixed databaseExists and tableExists to use PreparedStatement
  • OceanBaseTestMySQLCatalog.java: Updated method signature
  • Tests: Added SQL injection prevention test cases

Security Analysis

  • Fixed: databaseExists and tableExists methods now use parameterized queries
  • Already Secure: createTable method uses proper identifier quoting with backticks, no changes needed

Security Fix

Before: String.format("SELECT ... WHERE SCHEMA_NAME = '%s'", databaseName)
After: PreparedStatement with parameterized queries ✅

- Fix executeSingleColumnStatement method in OceanBaseCatalog.java to support parameterized queries
- Fix databaseExists and tableExists methods in OceanBaseMySQLCatalog.java to use parameterized queries instead of string concatenation
- Update method signature in OceanBaseTestMySQLCatalog.java to match parent class
- Add SQL injection prevention test cases to verify parameterized queries effectively prevent SQL injection attacks
- Adjust exception logging levels: SQL syntax errors use WARN level, other errors use ERROR level

This addresses the SQL injection security issues reported by the Apache team by using PreparedStatement parameterized queries to prevent malicious SQL injection attacks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant