From d39f6f471964cc7130c64c58270cda3cd9093cbf Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Mon, 3 Nov 2025 19:03:16 +0100 Subject: [PATCH 1/2] Temporary backups return deep copies This PR fixes an issue with restore from config that would mask the internal objects passphrase and cause all requests to fail due to invalid passphrase. --- Duplicati/Library/RestAPI/Database/Backup.cs | 18 ++++++++++++++++++ .../Library/RestAPI/Database/Connection.cs | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Duplicati/Library/RestAPI/Database/Backup.cs b/Duplicati/Library/RestAPI/Database/Backup.cs index 0eb658ed6..97b57cdba 100644 --- a/Duplicati/Library/RestAPI/Database/Backup.cs +++ b/Duplicati/Library/RestAPI/Database/Backup.cs @@ -175,6 +175,24 @@ namespace Duplicati.Server.Database } } } + + public Backup Clone() + { + return new Backup() + { + ID = this.ID, + ExternalID = this.ExternalID, + Name = this.Name, + Description = this.Description, + Tags = (string[])this.Tags.Clone(), + TargetURL = this.TargetURL, + DBPath = this.DBPath, + Sources = (string[])this.Sources.Clone(), + Settings = this.Settings.Select(s => new Setting { Name = s.Name, Value = s.Value, Filter = s.Filter }).ToArray(), + Filters = this.Filters.Select(f => new Filter { Order = f.Order, Include = f.Include, Expression = f.Expression }).ToArray(), + Metadata = new Dictionary(this.Metadata) + }; + } } } diff --git a/Duplicati/Library/RestAPI/Database/Connection.cs b/Duplicati/Library/RestAPI/Database/Connection.cs index dee9642fa..abb78a5cc 100644 --- a/Duplicati/Library/RestAPI/Database/Connection.cs +++ b/Duplicati/Library/RestAPI/Database/Connection.cs @@ -226,7 +226,7 @@ namespace Duplicati.Server.Database lock (m_lock) { m_temporaryBackups.TryGetValue(id, out var b); - return b; + return b?.Clone(); } } From 247131118e0bb44df4d741d5e538d5f994537321 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Mon, 3 Nov 2025 19:24:16 +0100 Subject: [PATCH 2/2] Fixed edge cases for Clone --- Duplicati/Library/RestAPI/Database/Backup.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Duplicati/Library/RestAPI/Database/Backup.cs b/Duplicati/Library/RestAPI/Database/Backup.cs index 97b57cdba..ed2c11217 100644 --- a/Duplicati/Library/RestAPI/Database/Backup.cs +++ b/Duplicati/Library/RestAPI/Database/Backup.cs @@ -184,12 +184,12 @@ namespace Duplicati.Server.Database ExternalID = this.ExternalID, Name = this.Name, Description = this.Description, - Tags = (string[])this.Tags.Clone(), + Tags = (string[])this.Tags?.Clone() ?? [], TargetURL = this.TargetURL, DBPath = this.DBPath, - Sources = (string[])this.Sources.Clone(), - Settings = this.Settings.Select(s => new Setting { Name = s.Name, Value = s.Value, Filter = s.Filter }).ToArray(), - Filters = this.Filters.Select(f => new Filter { Order = f.Order, Include = f.Include, Expression = f.Expression }).ToArray(), + Sources = (string[])this.Sources?.Clone() ?? [], + Settings = this.Settings?.Select(s => new Setting { Name = s.Name, Value = s.Value, Filter = s.Filter }).ToArray() ?? [], + Filters = this.Filters?.Select(f => new Filter { Order = f.Order, Include = f.Include, Expression = f.Expression }).ToArray() ?? [], Metadata = new Dictionary(this.Metadata) }; }