This only happens if the characters are directly in the query string (most likely because of inlined text literals). For example, the following requests are vulnerable:
// Simple statement with values inlined in the query string:
session.execute(
SimpleStatement.newInstance("INSERT INTO test.foo (id,t) VALUES (0, '\uD83C\uDF55')"));
// Same with execute(String) shortcut:
session.execute("INSERT INTO test.foo (id,t) VALUES (0, '\uD83C\uDF55')");
// Built query with inlined literals:
session.execute(
insertInto("test", "foo")
.value("id", literal(0))
.value("t", literal("\uD83C\uDF55"))
.build());
However, if the characters appear in values that are provided separately from the query, you are safe. The following examples are NOT vulnerable:
// Simple statement with values provided separately:
session.execute(
SimpleStatement.newInstance(
"INSERT INTO test.foo (id,t) VALUES (?, ?)", 0, "\uD83C\uDF55"));
// Built query with bind markers, values provided separately:
session.execute(
insertInto("test", "foo")
.value("id", bindMarker())
.value("t", bindMarker())
.builder()
.addPositionalValue(0)
.addPositionalValue("\uD83C\uDF55")
.build());
// Prepared statement
PreparedStatement pst = session.prepare("INSERT INTO test.foo (id,t) VALUES (?, ?)");
session.execute(pst.bind(0, "\uD83C\uDF55"));
Note that providing the values separately is a best practice anyway, as it avoids other issues like CQL injection. We also recommend prepared statements for queries that are executed often in your application (see the manual).
--
Olivier Michallat
Driver & tools engineer, DataStax
--
Olivier Michallat
Driver & tools engineer, DataStax