-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQLite3: add DEFENSIVE config for SQLite >= 3.26.0 as a mitigation st…
…rategy against potential security flaws
- Loading branch information
Showing
6 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--TEST-- | ||
SQLite3 defensive mode ini setting | ||
--SKIPIF-- | ||
<?php require_once(__DIR__ . '/skipif.inc'); | ||
|
||
if (SQLite3::version()['versionNumber'] < 3026000) { | ||
die("skip: sqlite3 library version < 3.26: no support for defensive mode"); | ||
} | ||
|
||
?> | ||
--INI-- | ||
sqlite3.defensive=On | ||
--FILE-- | ||
<?php | ||
|
||
$db = new SQLite3(':memory:'); | ||
var_dump($db->exec('CREATE TABLE test (a, b);')); | ||
|
||
// This does not generate an error! | ||
var_dump($db->exec('PRAGMA writable_schema = ON;')); | ||
var_dump($db->querySingle('PRAGMA writable_schema;')); | ||
|
||
// Should be 1 | ||
var_dump($db->querySingle('SELECT COUNT(*) FROM sqlite_master;')); | ||
|
||
// Should generate an error! | ||
var_dump($db->querySingle('DELETE FROM sqlite_master;')); | ||
|
||
// Should still be 1 | ||
var_dump($db->querySingle('SELECT COUNT(*) FROM sqlite_master;')); | ||
?> | ||
--EXPECTF-- | ||
bool(true) | ||
bool(true) | ||
int(1) | ||
int(1) | ||
|
||
Warning: SQLite3::querySingle(): Unable to prepare statement: 1, table sqlite_master may not be modified in %s on line %d | ||
bool(false) | ||
int(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters