Skip to content

fix(mongodb): escape SQL identifiers and literals in metadata/DDL paths (#1914)#2206

Open
HandSonic wants to merge 2 commits into
OtterMind:mainfrom
HandSonic:fix/sqli2-mongodb
Open

fix(mongodb): escape SQL identifiers and literals in metadata/DDL paths (#1914)#2206
HandSonic wants to merge 2 commits into
OtterMind:mainfrom
HandSonic:fix/sqli2-mongodb

Conversation

@HandSonic

Copy link
Copy Markdown
Contributor

Part of the SQL-injection hardening tracked in #1914. Prior art: #2052 (Oracle), #2053 (SQL Server), and the wave-1 batch (#2172-#2177).

These are second-order injection paths: values such as table/schema/view/index names originate from the connected database's own metadata, so exploitation requires a maliciously named object in a target database.

What changed (11 sites)

Shell-command hardening: requireMongoName allowlist for db/collection names at 11 command-building sites, JSON string values escaped in insert/update documents.

Verification

mvn -B -pl chat2db-community-plugins/chat2db-community-mongodb -f chat2db-community-server/pom.xml -Dmaven.test.skip=false -DskipTests=false -Dsurefire.includes=**/*Test.java -Dsurefire.failIfNoSpecifiedTests=false -Dmaven.test.failure.ignore=false test

Result: Tests run: 8, Failures: 0, Errors: 0, Skipped: 0.

This branch also passed a two-lens adversarial review (escape-correctness/coverage + regression/test-efficacy); all blocking findings were fixed and re-tested before submission.

…aintainer review (OtterMind#1914)

- non-SQL module: no SQL identifier/string escaping, default
  ISQLIdentifierProcessor left untouched
- requireMongoName allowlist + escapeJsonString are validation/JSON
  guards, not SQL escaping; class renamed accordingly
- callers rewired (DBManager/MetaData/ScriptExecutor/SqlBuilder)
- tests migrated to MongodbSqlGuardsTest (8 green)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants