I want to give my website users arbitrary read-only access to an SQLite3 database, without letting them write to the database or do any other damage. How?
Making the db file read-only helps a little, but commands like "ATTACH", ".load" and ".output" allow people to read/write other files, which may not be protected.
Of course, if I knew all such commands, I'd just filter against them, but I'm mostly worried about commands I haven't thought of.
I tried briefly to alter sqlite3's source code to disallow writes, but this is harder than it looks: even the SELECT statement appears to do some internal INSERTS/etc.
Note: I've considered DOS attacks, and will ulimit cputime to 5s or something. My main concern is damage to files/"hacking", not DOS.
chroot() may work, but seems extreme.
Thoughts?