镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[Bug]: The option forbidden_filenames is not considered in blacklist check blacklisted_files #49014

Closed

Description

@nvindice

⚠️ This issue respects the following points: ⚠️

Bug description

Emptying the forbidden_filenames option in config.php still blocks file uploads with the file name ".htaccess".
This might be due to the function isFileBlacklisted() in Filesystem.php, which considers the deprecated option blacklisted_files only. As soon as I empty this option, everything works as expected.

public static function isFileBlacklisted($filename) {
$filename = self::normalizePath($filename);
if (self::$blacklist === null) {
self::$blacklist = \OC::$server->getConfig()->getSystemValue('blacklisted_files', ['.htaccess']);
}
$filename = strtolower(basename($filename));
return in_array($filename, self::$blacklist);
}

Steps to reproduce

  1. In config.php add 'forbidden_filenames' => array()
  2. Create a file named .htaccess and try to sync it (not using an Apache web server, of course)
  3. The file will be blocked

Expected behavior

When allowing the upload of ".htaccess" files by emptying the forbidden_filenames option, the files should be synced.

Nextcloud Server version

30

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.3

Web server

Nginx

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 28 to 29)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

No response

List of activated Apps

No response

Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

No response

Activity

  1. added
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    on Oct 30, 2024
  2. changed the title [-][Bug]: The option forbidden_filenames is not considered in blacklist check[/-] [+][Bug]: The option `forbidden_filenames` is not considered in blacklist check `blacklisted_files`[/+] on Oct 31, 2024
  3. self-assigned this
    on Nov 9, 2024
  4. Moritz-Wohlgenannt commented on Jan 22, 2025

    @Moritz-Wohlgenannt

    I was just about to repot this as well. Took me 5 hours yesterday to find the offending code in the codebase. I found that lib/private/Files/FilenameValidator.php looks for forbidden_filenames and defaults to .htaccess while lib/private/Files/Filesystem.php looks for blacklisted_files and defaults to .htaccess if its empty. My workaround was to set both in my config.php. This brings back the issue that my log is flooded with the blacklisted_files is deprecated warning but at least our users can continue syncing .htaccess files as they ave before.
    Really I think both functions should evaluate forbidden_filenames and blacklisted_files or forbidden_filenames in the config should populate the blacklisted_files array as well for legacy code to not trip up...

  5. susnux commented on Jan 22, 2025

    @susnux
    Contributor

    forbidden_filenames cannot be used here, this function is used in system internal methods that need to allow to write files with e.g. non windows compatible filenames.
    Meaning this method is also used for non-user files (system only) and is intended for filenames that might have a bad impact on the server not on the user.

    So the difference is that one is to enforce sync compatibility (e.g. windows forbidden filenames) the other is to protect the server (forbid .htaccess which could make the data directory readable if badly configured by the admin).

  6. Moritz-Wohlgenannt commented on Jan 22, 2025

    @Moritz-Wohlgenannt

    Hi susnux,
    well this is problematic, since Nextcloud prints this to the logs: System config option “blacklisted_files” is deprecated and will be removed in Nextcloud 34, use “forbidden_filenames” instead.
    This prompted me to change my config from blacklisted_files to forbidden_filenames. If both are required and doing different things, then the message in the logs is highly misleading.
    I understand why .htaccess is a default for a blacklisted file, but if there is a configuration option to allow it (and there are good reasons to allow it, when using nginx for example) it is problematic if that configuration option does indeed not allow it and nextcloud keeps hindering users who try to upload upload .htaccess files.
    Best regards,

    Moritz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions