Cannot delete corrupted encrypted file "Bad Signature"

Nextcloud version 11.0.1:
Operating system and version (Debian):
Apache or nginx version don’t know, hosted:
PHP version (eg, 7.0.14):
Is this the first time you’ve seen this error and can you replicate it?:
Yes

The issue you are facing:
I have an encrypted file at a external storage, which is corrupted. I just want to delete it, and then to upload it again (or just to overwrite it).
But I have no chance to delete this corrupted file. Also not, if I try to delete the parent folder.
The only way would be, to delete the file at the external storage directly.

The output of your Nextcloud log in Admin > Logging:

> 	OC\HintException: Bad Signature
> /www/htdocs/w015300e/cloud/apps/encryption/lib/Crypto/Crypt.php - line 464: OCA\Encryption\Crypto\Crypt->checkSignature('OfpNiCWq3LdUZ0t...', 't\x06R\xDB\x88\x92\x17\x92\x84\xD5\xD7\x19\xB4\x1ED...', '67eaa49887ea0a3...')
> /www/htdocs/w015300e/cloud/apps/encryption/lib/Crypto/Encryption.php - line 372: OCA\Encryption\Crypto\Crypt->symmetricDecryptFileContent('OfpNiCWq3LdUZ0t...', 't\x06R\xDB\x88\x92\x17\x92\x84\xD5\xD7\x19\xB4\x1ED...', 'AES-256-CTR', 0, 0)
> /www/htdocs/w015300e/cloud/lib/private/Files/Stream/Encryption.php - line 460: OCA\Encryption\Crypto\Encryption->decrypt('OfpNiCWq3LdUZ0t...', 0)
> /www/htdocs/w015300e/cloud/lib/private/Files/Stream/Encryption.php - line 291: OC\Files\Stream\Encryption->readCache()
> [internal function] OC\Files\Stream\Encryption->stream_read(8192)
> /www/htdocs/w015300e/cloud/lib/private/legacy/helper.php - line 296: fread(Resource id #1046, 8192)
> /www/htdocs/w015300e/cloud/lib/private/Files/Storage/Wrapper/Encryption.php - line 745: OC_Helper streamCopy(Resource id #1046, Resource id #1047)
> /www/htdocs/w015300e/cloud/lib/private/Files/Storage/Wrapper/Encryption.php - line 642: OC\Files\Storage\Wrapper\Encryption->copyBetweenStorage(Object(OCA\Files_Trashbin\Storage), 'Musik/Sunshine ...', 'files_trashbin/...', false, true)
> /www/htdocs/w015300e/cloud/lib/private/Files/Storage/Wrapper/Encryption.php - line 737: OC\Files\Storage\Wrapper\Encryption->copyFromStorage(Object(OCA\Files_Trashbin\Storage), 'Musik/Sunshine ...', 'files_trashbin/...', false, true)
> /www/htdocs/w015300e/cloud/lib/private/Files/Storage/Wrapper/Encryption.php - line 614: OC\Files\Storage\Wrapper\Encryption->copyBetweenStorage(Object(OCA\Files_Trashbin\Storage), 'Musik/Sunshine ...', 'files_trashbin/...', true, true)
> /www/htdocs/w015300e/cloud/lib/private/Files/Storage/Wrapper/Wrapper.php - line 569: OC\Files\Storage\Wrapper\Encryption->moveFromStorage(Object(OCA\Files_Trashbin\Storage), 'Musik/Sunshine ...', 'files_trashbin/...')
> /www/htdocs/w015300e/cloud/apps/files_trashbin/lib/Trashbin.php - line 237: OC\Files\Storage\Wrapper\Wrapper->moveFromStorage(Object(OCA\Files_Trashbin\Storage), 'Musik/Sunshine ...', 'files_trashbin/...')
> /www/htdocs/w015300e/cloud/apps/files_trashbin/lib/Storage.php - line 161: OCA\Files_Trashbin\Trashbin move2trash('ACD/Musik/Sunsh...')
> /www/htdocs/w015300e/cloud/apps/files_trashbin/lib/Storage.php - line 107: OCA\Files_Trashbin\Storage->doDelete('Musik/Sunshine ...', 'rmdir')
> /www/htdocs/w015300e/cloud/lib/private/Files/View.php - line 1124: OCA\Files_Trashbin\Storage->rmdir('Musik/Sunshine ...')
> /www/htdocs/w015300e/cloud/lib/private/Files/View.php - line 345: OC\Files\View->basicOperation('rmdir', '/ACD/Musik/Suns...', Array)
> /www/htdocs/w015300e/cloud/apps/dav/lib/Connector/Sabre/Directory.php - line 277: OC\Files\View->rmdir('/ACD/Musik/Suns...')
> /www/htdocs/w015300e/cloud/3rdparty/sabre/dav/lib/DAV/Tree.php - line 179: OCA\DAV\Connector\Sabre\Directory->delete()
> /www/htdocs/w015300e/cloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 287: Sabre\DAV\Tree->delete('ACD/Musik/Sunsh...')
> [internal function] Sabre\DAV\CorePlugin->httpDelete(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
> /www/htdocs/w015300e/cloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array)
> /www/htdocs/w015300e/cloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 479: Sabre\Event\EventEmitter->emit('method DELETE', Array)
> /www/htdocs/w015300e/cloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 254: Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
> /www/htdocs/w015300e/cloud/apps/dav/appinfo/v1/webdav.php - line 60: Sabre\DAV\Server->exec()
> /www/htdocs/w015300e/cloud/remote.php - line 165: require_once('/www/htdocs/w01...')
> {main}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

$CONFIG = array (
'instanceid' => 'xxx',
'passwordsalt' => 'xxx',
'secret' => 'xxx',
'trusted_domains' =>
array (
0 => 'xxx',
),
'datadirectory' => '/www/htdocs/xxx/cloud/data',
'overwrite.cli.url' => 'https://xxx',
'dbtype' => 'mysql',
'version' => '11.0.1.2',
'dbname' => 'xxx',
'dbhost' => 'localhost',
'dbport' => '',
'dbtableprefix' => 'oc_',
'dbuser' => 'xxx',
'dbpassword' => 'xxx',
'logtimezone' => 'UTC',
'installed' => true,
'enable_previews' => true,
'preview_max_x' => 1024,
'preview_max_y' => 1024,
'preview_max_scale_factor' => 10,
'preview_max_filesize_image' => 50,
'preview_libreoffice_path' => '/usr/bin/libreoffice',
'preview_office_cl_parameters' => ' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir ',
'enabledPreviewProviders' =>
array (
0 => 'OC\\Preview\\PNG',
1 => 'OC\\Preview\\JPEG',
2 => 'OC\\Preview\\GIF',
3 => 'OC\\Preview\\BMP',
4 => 'OC\\Preview\\XBitmap',
5 => 'OC\\Preview\\TXT',
6 => 'OC\\Preview\\MarkDown',
),
'maintenance' => false,
'theme' => '',
'loglevel' => 2,
'tempdirectory' => '/www/htdocs/xxx/cloud/data/tmp/',
);

The output of your Apache/nginx/system log in /var/log/____:
not available


Remember, this information may be requested if it isn’t supplied; for fastest response please provide as much as you can :heart: Feel free to use a pastebin service, otherwise log files can be indented with 4 spaces on each line to present them in a friendlier way on the forum.

I got it!
The problem here is the “trashbin” app. This app tries to open/move the file to the trashbin, but fails because of the corrupt encryption.
I disabled the trashbin-app. After that, a deletion or overwrite was no problem.

Maybe the trashbin app should be fixed to handle such a case?!

Go for issue – https://github.com/nextcloud/server/issues :DD

see https://github.com/nextcloud/server/issues/3579