The vulnerability lies in a flawed backup and restore mechanism within nginx-ui, specifically a circular trust model for integrity verification. The system would encrypt a backup and provide the encryption key to the client. The integrity of the backup was checked using a hash_info.txt file which was itself part of the backup and encrypted with the same client-side key.
An attacker could obtain the backup and the key, decrypt the contents, modify them (e.g., inject a malicious command into a configuration file), recalculate the SHA-256 hashes of the modified files, update the hash_info.txt file, and then re-encrypt the entire backup.
The core of the exploitation occurs during the restore process. The vulnerable function Restore.DoRestore in controller/restore.go would receive this tampered backup. While it would perform a hash check, it would not abort the process upon failure. Instead, it would only issue a warning and proceed with the restoration, applying the attacker's malicious configuration.
The patch addresses this by introducing a proper cryptographic signature for the backup manifest, created using a server-side key. The Backup.CreateBackup function in controller/backup.go was modified to generate this signature. Correspondingly, the Restore.DoRestore function was updated to require and verify this signature, aborting the restore process if the verification fails. This breaks the circular trust model and prevents the restoration of tampered backups.