(invalid passphrase?): Message has been altered, do not trust content

Suddenly one of my backup job (on a usb drive attached to the router) started to yield the above error.
I’ve read a few messages about this error without finding the solution.
I’m sure that the passphrase is correct.
I’ve tried to repair the database, and I’ve purged the broken files. But the error still persists on the next job execution.
What can I do next?
If I did know there is a specific file that is the source of the error, I could delete it.
I just want to continue to run my backup job, even if I have to delete some files. Only, I would not want to delete all the files and restart it from scratch.
Thanks.

The issue is intermittent. For example today the job finished successfully, after three days of errors (it is a daily job).

At what phase does the error occur? Is it during backup, or is it after backup when it does a verification?

Also, it may help to post the job log.

What phase? I don’t remember exactly. I will specify it at the next occurrence of the error.
Here below the log I received by email the last time the error occurred:

Failed: Impossibile decriptare i dati (passphrase non valida?): Message has been altered, do not trust content
Details: System.Security.Cryptography.CryptographicException: Impossibile decriptare i dati (passphrase non valida?): Message has been altered, do not trust content ---> SharpAESCrypt.SharpAESCrypt+HashMismatchException: Message has been altered, do not trust content
   in SharpAESCrypt.SharpAESCrypt.Read(Byte[] buffer, Int32 offset, Int32 count)
   in Duplicati.Library.Utility.Utility.CopyStream(Stream source, Stream target, Boolean tryRewindSource, Byte[] buf)
   in Duplicati.Library.Encryption.EncryptionBase.Decrypt(Stream input, Stream output)
   --- Fine della traccia dello stack dell'eccezione interna ---
   in Duplicati.Library.Main.AsyncDownloader.AsyncDownloaderEnumerator.AsyncDownloadedFile.get_TempFile()
   in Duplicati.Library.Main.Operation.CompactHandler.DoCompact(LocalDeleteDatabase db, Boolean hasVerifiedBackend, IDbTransaction& transaction, BackendManager sharedBackend)
   in Duplicati.Library.Main.Operation.DeleteHandler.DoRun(LocalDeleteDatabase db, IDbTransaction& transaction, Boolean hasVerifiedBacked, Boolean forceCompact, BackendManager sharedManager)
   in Duplicati.Library.Main.Operation.BackupHandler.CompactIfRequired(BackendManager backend, Int64 lastVolumeSize)
   in Duplicati.Library.Main.Operation.BackupHandler.<RunAsync>d__20.MoveNext()
--- Fine traccia dello stack da posizione precedente dove è stata generata l'eccezione ---
   in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   in CoCoL.ChannelExtensions.WaitForTaskOrThrow(Task task)
   in Duplicati.Library.Main.Controller.<>c__DisplayClass14_0.<Backup>b__0(BackupResults result)
   in Duplicati.Library.Main.Controller.RunAction[T](T result, String[]& paths, IFilter& filter, Action`1 method)

Log data:
2019-11-10 15:31:10 +01 - [Error-Duplicati.Library.Main.Operation.BackupHandler-FatalError]: Fatal error
System.Security.Cryptography.CryptographicException: Impossibile decriptare i dati (passphrase non valida?): Message has been altered, do not trust content ---> SharpAESCrypt.SharpAESCrypt+HashMismatchException: Message has been altered, do not trust content
   in SharpAESCrypt.SharpAESCrypt.Read(Byte[] buffer, Int32 offset, Int32 count)
   in Duplicati.Library.Utility.Utility.CopyStream(Stream source, Stream target, Boolean tryRewindSource, Byte[] buf)
   in Duplicati.Library.Encryption.EncryptionBase.Decrypt(Stream input, Stream output)
   --- Fine della traccia dello stack dell'eccezione interna ---
   in Duplicati.Library.Main.AsyncDownloader.AsyncDownloaderEnumerator.AsyncDownloadedFile.get_TempFile()
   in Duplicati.Library.Main.Operation.CompactHandler.DoCompact(LocalDeleteDatabase db, Boolean hasVerifiedBackend, IDbTransaction& transaction, BackendManager sharedBackend)
   in Duplicati.Library.Main.Operation.DeleteHandler.DoRun(LocalDeleteDatabase db, IDbTransaction& transaction, Boolean hasVerifiedBacked, Boolean forceCompact, BackendManager sharedManager)
   in Duplicati.Library.Main.Operation.BackupHandler.CompactIfRequired(BackendManager backend, Int64 lastVolumeSize)
   in Duplicati.Library.Main.Operation.BackupHandler.<RunAsync>d__20.MoveNext()

I run the job another time and the error occurred again. It seems to me during the final upload phase.

Is there the following info useful to understand the source of the issue? I’ve copied it from the real time log. It happens after the compating phase.

26 gen 2020 09:58: Operation Get with file duplicati-b973bdc68a3c5408894ade34ab2020b82.dblock.zip.aes attempt 2 of 5 failed with message: Impossibile decriptare i dati (passphrase non valida?): Message has been altered, do not trust content
    {"ClassName":"System.Security.Cryptography.CryptographicException","Message":"Impossibile decriptare i dati (passphrase non valida?): Message has been altered, do not trust content","Data":null,"InnerException":{"ClassName":"SharpAESCrypt.SharpAESCrypt+HashMismatchException","Message":"Message has been altered, do not trust content","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":"   in SharpAESCrypt.SharpAESCrypt.Read(Byte[] buffer, Int32 offset, Int32 count)\r\n   in Duplicati.Library.Utility.Utility.CopyStream(Stream source, Stream target, Boolean tryRewindSource, Byte[] buf)\r\n   in Duplicati.Library.Encryption.EncryptionBase.Decrypt(Stream input, Stream output)","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":"8\nRead\nSharpAESCrypt, Version=1.3.3.0, Culture=neutral, PublicKeyToken=null\nSharpAESCrypt.SharpAESCrypt\nInt32 Read(Byte[], Int32, Int32)","HResult":-2146233296,"Source":"SharpAESCrypt","WatsonBuckets":null},"HelpURL":null,"StackTraceString":"   in Duplicati.Library.Main.BackendManager.coreDoGetPiping(FileEntryItem item, IEncryption useDecrypter, Int64& retDownloadSize, String& retHashcode)\r\n   in Duplicati.Library.Main.BackendManager.DoGet(FileEntryItem item)\r\n   in Duplicati.Library.Main.BackendManager.ThreadRun()","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":"8\ncoreDoGetPiping\nDuplicati.Library.Main, Version=2.0.5.101, Culture=neutral, PublicKeyToken=null\nDuplicati.Library.Main.BackendManager\nDuplicati.Library.Utility.TempFile coreDoGetPiping(FileEntryItem, Duplicati.Library.Interface.IEncryption, Int64 ByRef, System.String ByRef)","HResult":-2146233296,"Source":"Duplicati.Library.Main","WatsonBuckets":null}

Moreover: the log sent via email (or written to the disk) doesn’t show the file related to the error. So every time I encounter the error I’m forced to run the job task again checking the real time log. Is there a way to include the file name even to the other log channels?

or instead of --log-file-log-level (which can make a large log), narrow with –log-file-log-filter=*RetryGet

Example output from an intentionally corrupted file where I changed a character near the middle of file:

2020-01-26 09:24:10 -05 - [Retry-Duplicati.Library.Main.BackendManager-RetryGet]: Operation Get with file duplicati-b0379abeb61784c0eaeaf23000670e78c.dblock.zip.aes attempt 1 of 5 failed with message: Failed to decrypt data (invalid passphrase?): Message has been altered, do not trust content
System.Security.Cryptography.CryptographicException: Failed to decrypt data (invalid passphrase?): Message has been altered, do not trust content ---> SharpAESCrypt.SharpAESCrypt+HashMismatchException: Message has been altered, do not trust content
   at SharpAESCrypt.SharpAESCrypt.Read(Byte[] buffer, Int32 offset, Int32 count)
   at Duplicati.Library.Utility.Utility.CopyStream(Stream source, Stream target, Boolean tryRewindSource, Byte[] buf)
   at Duplicati.Library.Encryption.EncryptionBase.Decrypt(Stream input, Stream output)
   --- End of inner exception stack trace ---
   at Duplicati.Library.Main.BackendManager.coreDoGetPiping(FileEntryItem item, IEncryption useDecrypter, Int64& retDownloadSize, String& retHashcode)
   at Duplicati.Library.Main.BackendManager.DoGet(FileEntryItem item)
   at Duplicati.Library.Main.BackendManager.ThreadRun()

Example output from intentionally corrupting the first character of the file:

2020-01-26 15:44:41 -05 - [Error-Duplicati.Library.Main.Operation.TestHandler-RemoteFileProcessingFailed]: Failed to process file duplicati-b0379abeb61784c0eaeaf23000670e78c.dblock.zip.aes
System.Security.Cryptography.CryptographicException: Invalid header marker ---> System.IO.InvalidDataException: Invalid header marker
   at SharpAESCrypt.SharpAESCrypt.ReadEncryptionHeader(String password, Boolean skipFileSizeCheck)
   at SharpAESCrypt.SharpAESCrypt..ctor(String password, Stream stream, OperationMode mode, Boolean skipFileSizeCheck)
   at Duplicati.Library.Encryption.AESEncryption.Decrypt(Stream input)
   at Duplicati.Library.Encryption.EncryptionBase.Decrypt(Stream input, Stream output)
   at Duplicati.Library.Main.BackendManager.<>c__DisplayClass36_0.<coreDoGetPiping>b__0()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
   at Duplicati.Library.Main.AsyncDownloader.AsyncDownloaderEnumerator.AsyncDownloadedFile.get_TempFile()
   at Duplicati.Library.Main.Operation.TestHandler.DoRun(Int64 samples, LocalTestDatabase db, BackendManager backend)

but if you get the file name, what are you going to do with it? If you have a truly broken file, it’s lost.

Failed: Invalid header marker has lots of relevant information. One thing I wonder about is the idea:

Was this ever done, and was throttling either off or Duplicati at least 2.0.4.22_canary_2019-06-30?

I know you were on 2.0.4.37_canary_2019-12-12, otherwise I’d say you require at least 2.0.4.24 to avoid the temporary throttling corruption. The permanent corruption fix was in 2.0.4.22, so I wonder whether you have an old damaged backup and are slowly falling over all of the problems with that?

Did you try the suggestion to increase --backup-test-samples or --backup-test-percentage options? Finding a large number of broken files (maybe you’re noting names as you get them?) is bad news.

What sort of restore tests (if any) are you doing? Limping along with a broken backup is a bad idea.