The vulnerability is a classic path traversal that leads to arbitrary file write and potential remote code execution. The root cause is the lack of input validation on the X-Name HTTP header, which is used as a filename for uploaded assets.
The exploitation occurs in two stages:
-
Injection: An authenticated attacker uploads an asset and provides a malicious filename containing path traversal sequences (e.g., ../../../../../../etc/passwd) in the X-Name header. The AssetsHandler.PostNoteAsset function in backend/handlers/assets.go accepted this input without sanitization and stored it in the database.
-
Execution: When an administrator triggers a data export using the application's CLI, the commandMigrateExportData or commandMigrateExportDataV1 functions in backend/cli/migrate.go are executed. These functions read the malicious filename from the database and use it to construct a file path for the exported asset. The filepath.Join and path.Join functions normalize this path, causing the file to be written outside the intended export directory. If the process is running as a privileged user (e.g., root), the attacker can overwrite critical system files, leading to remote code execution.
The patch addresses the vulnerability at both stages. It adds input validation in AssetsHandler.PostNoteAsset to reject filenames with path separators. As a defense-in-depth measure, it also modifies the export functions to sanitize the filename using filepath.Base() before using it, preventing exploitation even if malicious data already exists in the database.