Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F35720267
0001-SECURITY-Make-sqlite-DB-files-not-world-readable.patch
Bawolff (Brian Wolff)
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
Bawolff
Nov 8 2022, 2:51 PM
2022-11-08 14:51:25 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
0001-SECURITY-Make-sqlite-DB-files-not-world-readable.patch
View Options
From 50002b5d4630699e14a61d5d6c643fe7515a6c19 Mon Sep 17 00:00:00 2001
From: Brian Wolff <bawolff+wn@gmail.com>
Date: Tue, 8 Nov 2022 06:45:04 -0800
Subject: [PATCH] SECURITY: Make sqlite DB files not world readable
Ensure that SQLite DB files are created as 0600. Previously they
were created 0644 (world-readable). This was somewhat mitigated by
the fact that if MediaWiki had to create the parent directory, it
would be created as 0700. However if the parent directory already
existed and had loose permissions, than anyone on the server
could read the DB file and all the private data contained therein.
This only affects newly created DB files during the installation
process. It does not adjust previously created DB files.
Bug: T322637
Change-Id: I167ec1b5cd9a7e96919886fd20917b5733d59fc7
---
includes/installer/SqliteInstaller.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/includes/installer/SqliteInstaller.php b/includes/installer/SqliteInstaller.php
index 1270871ca22..0426d4a7c2c 100644
--- a/includes/installer/SqliteInstaller.php
+++ b/includes/installer/SqliteInstaller.php
@@ -322,13 +322,20 @@ EOT;
*/
protected function makeStubDBFile( $dir, $db ) {
$file = DatabaseSqlite::generateFileName( $dir, $db );
+
if ( file_exists( $file ) ) {
if ( !is_writable( $file ) ) {
return Status::newFatal( 'config-sqlite-readonly', $file );
}
- } elseif ( file_put_contents( $file, '' ) === false ) {
+ return Status::newGood();
+ }
+
+ $oldMask = umask( 0177 );
+ if ( file_put_contents( $file, '' ) === false ) {
+ umask( $oldMask );
return Status::newFatal( 'config-sqlite-cant-create-db', $file );
}
+ umask( $oldMask );
return Status::newGood();
}
--
2.30.2
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
9878116
Default Alt Text
0001-SECURITY-Make-sqlite-DB-files-not-world-readable.patch (1 KB)
Attached To
Mode
T322637: CVE-2022-47927: sqlite should not create DB file world-readable
Attached
Detach File
Event Timeline
Log In to Comment