Ir al contenido

📕 FIELD MANUAL 22.1: CQL INJECTION (CASSANDRA BIG DATA)

Objective: We will inject commands into Apache Cassandra clusters by exploiting CQL (Cassandra Query Language) syntax.

0views

Classification: RED TEAM EYES ONLY

Objective: We will inject commands into Apache Cassandra clusters by exploiting CQL (Cassandra Query Language) syntax.

MITRE ATT&CK: T1190.

1. INTEL & RECON: IT LOOKS LIKE SQL, BUT IT'S NOT

Sección titulada «1. INTEL & RECON: PARECE SQL, PERO NO LO ES»

CQL looks like SQL: SELECT * FROM users WHERE id = '123';

Critical Differences for the Attacker:

  1. No JOINs: We will not be able to join tables to steal cross-referenced data.
  2. Strict PK: In older versions, we will ONLY be able to filter by the Primary Key.
  3. ALLOW FILTERING: To search by non-indexed columns, the query MUST include ALLOW FILTERING.

We often won't be able to easily change the WHERE logic due to partitioning restrictions, but we can inject execution options.

  • Scenario: Backend concatenates input. query = "SELECT * FROM logs WHERE type = '" + type + "'";
  • Payload: ' ALLOW FILTERING;
    • In Cassandra, we will attempt to filter by a non-indexed column and trigger an error. By injecting ALLOW FILTERING, we will enable the query and extract data that the developer thought was “protected” by the index restriction.

TECHNIQUE: JSON Injection (Modern Cassandra)

Sección titulada «TÉCNICA: JSON Injection (Modern Cassandra)»

Cassandra supports insertion via JSON. INSERT INTO users JSON '{"id": 1, "name": "..."}'

  • Payload: If we control the JSON, we can attempt to overwrite attributes we shouldn't touch (privilege escalation) if the app simply concatenates the JSON string.
  • Defense:
    1. Prepared Statements: CQL supports ? just like SQL. We will always use prepared statements.
    2. Input Validation: Cassandra is very strict with types (UUID, TimeUUID). We will validate the format before sending the query to prevent 99% of injections.