SQLite Forum

Disable -wal option
Login
Just to add to what Richard, David and others said:

There is no application on Earth that can provide the security you are looking for.
It's a bit like asking: "How can I give people my car keys, but make it so they cannot adjust the seats, or rip them out completely. Please help me make stronger adjust-resistant seats...".  It's not more absurd than the actual question about hardening a database file to which a user has inherent access - it's just that with the car analogy, the absurdity of the question is more clear.

Even with the big database engines, like MSSQL/MySQL/PostGres etc., if the user has access to the FILES on that machine, there is NOTHING, not a single thing that database Engine can do to protect against data loss by malicious attack.

The key for those systems lies mostly in the fact that the physical database files are hidden well-away from users' grabby little hands (hidden by file-system/OS/Server mechanics, not Database mechanics) and the only communication path to the engine is via a pipe or other secure tunnel.

With SQLite, the database ENGINE sits directly INSIDE the user-code operating on a file which already has user-access, and ANY code which understands SQLite can talk to that database if the file is accessible, and ANY code (no need to even understand SQLite) can hurt that file.

Hardening your own SQLite code against the user of your own program has Zero effect when they can simply open it with the next program, or their own thing, or even the freely downloadable SQLite CLI.

Either you CAN put the files where the user cannot reach it directly and use it in read-only mode or via different user (such as on /etc/) (not sure how one would do this in Windows, but there should be a way), or, give the user-program (and by inference, the user itself) write-access to the file, which means they can use anything to hurt it.

If your users are not malicious tech-savvy people, it's usually OK to just run their Queries through the SQLite Authorizer API in your application and avoid hurtful SQL. Any smart-protection on a user-editable file is folly and a complete waste of your time and resources. Just use PostGres or MariaDB then. It's equally free and can sit on a different machine which the User cannot reach. There are also Client-Server SQLite option out there, a bit of a google can find them, but by the time you have to do that, PostGres/MySQL/MariaDB is just better.

SQLite solves the "local-data-storage" problem, it can even be a player in the "data-security" playground in terms of using the SEE extension, but it is not, and never can be a player in the "data-hardening-against-attack" problem playground. That is up to File-systems, OSes and servers.