-
-
Notifications
You must be signed in to change notification settings - Fork 441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.x] Add DisallowSqliteAttach feature #1283
Merged
Merged
Conversation
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
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1283 +/- ##
============================================
- Coverage 84.74% 84.71% -0.03%
- Complexity 1025 1035 +10
============================================
Files 174 175 +1
Lines 3015 3043 +28
============================================
+ Hits 2555 2578 +23
- Misses 460 465 +5 ☔ View full report in Codecov by Sentry. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new
Feature
class to the package:DisallowSqliteAttach
.The feature serves as the SQLite version of our permission controlled DB managers — it limits the impact of a potential SQL injection by making it impossible to connect to other databases.
In SQLite, this is done via the
ATTACH
statement. SQLite can be compiled without it, but all setups I've checked hadATTACH
enabled in the libsqlite3 shipped with PHP. The other way to disableATTACH
is to use an authorizer, which is what this PR does. PHP 8.4 added driver specific PDO subclasses which means we may eventually getPdo\Sqlite::setAuthorizer()
, but until we do, we can usePdo\Sqlite::loadExtension()
(also a compile-time option, but all PHP setups I've tested support it). We check for the presence of that method at runtime in this feature.From what I've tested, it seems exploiting a SQL injection in a way that'd let you use
ATTACH
requires many stars to align:Nevertheless, for feature parity I'm happy to have this for SQLite. It does come at a small cost:
src/Events
directory which contains zero actual logic is ~200K.TODO: Confirm that all library files work:
noattach.dylib
locally via Rosettaarm/noattach.dylib
locallyarm/noattach.so
locally in Dockernoattach.so
in CI testsnoattach.dll
in a VM