#5933·zeek

SQLite log writer should sanitize its table name

Author: evantypanskiCreated Sep 30, 2026Updated Sep 30, 2026
LabelsGood First Issue

Found when LLM vuln scanning. Scripts are considered trusted, so there's no reasonable way for an attacker to do this. But it's kind of funny.

The SQLite log writer doesn't sanitize its input, so you can technically SQL-injection yourself. That's a bit surprising, in my opinion.

Run this file:

# sqlite-tablename-injection.zeek
@load base/frameworks/logging/writers/sqlite

module SQLiteTableName;

export {
	redef enum Log::ID += { LOG };

	type Info: record {
		msg: string &log;
	};
}

event zeek_init()
	{
	local cfg: table[string] of string = table(
		["tablename"] = "mainlog (msg text); CREATE TABLE injected(marker text); --"
	);

	Log::create_stream(SQLiteTableName::LOG, [$columns=SQLiteTableName::Info]);
	Log::remove_default_filter(SQLiteTableName::LOG);
	Log::add_filter(SQLiteTableName::LOG,
	                [$name="sqlite", $path="sqlite-injection", $writer=Log::WRITER_SQLITE, $config=cfg]);
	Log::write(SQLiteTableName::LOG, [$msg="trigger"]);
	}

Run it:

$ zeek sqlite-tablename-injection.zeek
error: sqlite-injection/Log::WRITER_SQLITE: Error executing table creation statement: near "'msg'": syntax error
error: sqlite-injection/Log::WRITER_SQLITE: terminating thread

Then inspect the SQLite table and see injected:

$ python3 -c 'import sqlite3; db=sqlite3.connect("sqlite-injection.sqlite"); rows=db.execute("select name, sql from sqlite_master where type=\"table\" order by name").fetchall(); [print(repr(r)) for r in rows]'

('injected', 'CREATE TABLE injected(marker text)')
('mainlog', 'CREATE TABLE mainlog (msg text)')

I would expect this to sanitize, or even just error, when trying this.