Validate external file path at metadata load time - #9121
Open
Pyolar wants to merge 1 commit into
Open
Conversation
External tables store the file path in RDB$EXTERNAL_FILE at CREATE TABLE time without any check against the ExternalFileAccess policy. The path was validated only later, when the table was actually opened, so a table pointing outside the allowed directories could be created and the malicious path remained in metadata. Move the validation into a shared checkExternalFileAccess() helper and call it both when the relation metadata is loaded (met.epp) and when the external file is opened (ExternalFile::open). Paths escaping the configured directory list are now rejected at CREATE TABLE time with isc_conf_access_denied, and existing databases with such tables fail on first access instead of silently carrying the bad path.
This file contains hidden or 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
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.
External table paths are stored in RDB$EXTERNAL_FILE at CREATE TABLE time without any check against ExternalFileAccess. The path was only validated when the table was opened, so with a restricted directory list a user could create a table pointing outside the allowed directories and the bad path stayed in metadata.
This moves the check into checkExternalFileAccess(), shared by the metadata loader (met.epp) and ExternalFile::open(). Escaping paths are now rejected at CREATE TABLE with isc_conf_access_denied. Existing databases containing such tables fail on first access instead of keeping the invalid path silently.
Tested with ExternalFileAccess = Restrict: CREATE TABLE with a path outside the list fails with SQLSTATE 28000, tables inside the list work unchanged.
Companion tests: FirebirdSQL/firebird-qa#39