/

CVE-2026-27819

Severity:

HIGH RISK

(7.2)

Path Traversal in Archive Extraction in Vikunja Backup

CVE-2026-27819

Analyzed

Vulnerability type

Category:

Path Traversal in Archive Extraction

CWE:

CWE-22, CWE-248

Impact:

Arbitrary File Overwrite and Application Crash with Data Loss

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Vikunja's backup restore functionality trusts file paths embedded in ZIP archives and uses them directly when writing files to disk.

A malicious archive can escape the intended restore directory to overwrite arbitrary files on the host, and specially crafted "minimalist" archives can trigger an unhandled panic after the database has already been wiped, causing a crash and permanent data loss.

Affected context

This vulnerability occurs in Vikunja instances where administrators use the built-in backup restoration feature that accepts ZIP archives.

The restoreConfig function assumes ZIP entries are well-formed and confined to the expected directory structure, and it directly uses the zip.File.Name value when opening files on the host filesystem.

The code also assumes that certain slices derived from archive contents always have a minimum length, without validating these assumptions before indexing.

In environments where restore operations are performed on production systems, this behavior can expose the host filesystem and jeopardize data integrity if a crafted backup is restored.

Exploit preconditions

  • Attack surface: Vikunja backup/restore interface or any API/CLI path that accepts ZIP archives for configuration or data restoration.
  • Required access: Ability to supply a ZIP archive to the restoreConfig logic (e.g., authenticated admin, compromised admin account, or untrusted backup source).
  • Trigger point (path traversal): Restoration of a ZIP file containing entries with crafted path components (such as parent directory segments) that escape the intended restore directory.
  • Trigger point (panic/crash): Restoration of a "minimal" or malformed ZIP that breaks the assumed directory structure, leading to out-of-bounds slice access.
  • Why exploitation is possible: The application:
  • Trusts the Name field in zip.File and passes it directly to os.OpenFile without normalization, path cleaning, or confinement checks.
  • Does not enforce that extracted paths remain under a designated base directory.
  • Indexes into slices derived from archive paths (e.g., using len(ms)-2) without first confirming the slice length, allowing runtime panics when assumptions do not hold.

Why this happens

The primary issue is a path traversal flaw (CWE-22) in the archive extraction logic: the restoreConfig function interprets path strings from ZIP metadata as trusted, and uses them verbatim when creating or opening files on the filesystem.

Without canonicalization and validation of these paths against a known base directory, an attacker can embed directory traversal sequences or absolute paths in ZIP entry names to write outside the intended extraction root.

The secondary issue is an unhandled runtime panic (CWE-248) caused by unchecked assumptions about archive structure.

The restoration logic splits or processes archive-derived data into slices and then accesses indices relative to len(ms) (such as len(ms)-2) without verifying that the slice is long enough.

When a "minimalist" or malformed archive is provided, these assumptions fail, leading to an out-of-bounds index and a panic, which is not recovered from and therefore crashes the process.

Both problems stem from overly trusting external input (archive metadata and structure) and encoding those assumptions directly into filesystem operations and indexing logic without defensive validation or error handling.

Potential impact

  • Arbitrary file overwrite on the host system within the permissions of the Vikunja process.
  • Modification of application configuration files, potentially leading to further compromise or misconfiguration.
  • Overwriting of critical system or service files, which may cause denial of service or facilitate privilege escalation in some environments.
  • Permanent loss of application data if a restore operation wipes the database and then crashes before completing recovery.
  • Application downtime due to runtime panics during restore, requiring manual intervention to recover.

General mitigation guidance

Effective mitigation focuses on restricting filesystem writes during archive extraction and hardening assumptions about archive structure:

  • Constrain extraction paths:
  • Normalize and clean all paths from ZIP entries before use (e.g., via canonicalization functions).
  • Ensure the final extraction path is always joined with and confined to a predefined base directory, rejecting any entry that resolves outside it.
  • Ignore or fail the restore if a path is absolute, contains parent directory segments that escape the base, or attempts to target special filesystem locations.
  • Validate archive structure defensively:
  • Treat all metadata from the archive (file names, directory hierarchies) as untrusted and verify that required components are present before proceeding.
  • Perform length and bounds checks on slices derived from path splits or metadata before indexing into them.
  • Fail restore operations gracefully (with clear errors) when the archive does not conform to the expected structure rather than assuming it does.
  • Harden error handling and recovery:
  • Replace crash-prone patterns with explicit error checks and controlled error returns; avoid panics in routine restore paths.
  • Consider transactional or staged restore designs where destructive operations (e.g., wiping databases) are performed last, after the input archive has been fully validated.
  • Run the restore process with the least privileges necessary and consider isolating it from the rest of the system (e.g., dedicated user, restricted directories).
  • Trust boundaries and operational practices:
  • Treat backup archives as untrusted input unless their origin and integrity are strongly validated.
  • Encourage operators to store and handle backup files securely, limiting opportunities for tampering.

How teams detect issues like this

To detect and prevent similar vulnerabilities, organizations can combine static checks, code review practices, and runtime monitoring:

  • Static analysis and linting:
  • Configure static analysis rules to flag:
  • Direct usage of archive entry names (zip.File.Name, or equivalents) passed to filesystem APIs without prior normalization and validation.
  • Calls to os.OpenFile, os.Create, or similar functions using user-controlled or external-input-derived paths.
  • Slice indexing patterns that use len(s)-N without preceding length checks or early returns.
  • Integrate these rules into CI to fail builds when unsafe patterns are found.
  • Code review signals:
  • During review, pay close attention to:
  • Archive extraction loops that use user-supplied names or paths.
  • Logic that assumes a fixed directory structure or a minimum number of path segments.
  • Any use of panic or unrecovered runtime errors in non-critical, user-triggerable paths such as backup/restore.
  • Require reviewers to explicitly verify that path confinement and bounds checks are present in file-handling code.
  • Runtime and operational monitoring:
  • Monitor logs for failed restore attempts, unexpected panics, or error messages related to path handling or index out of range.
  • Implement structured logging around backup and restore operations, including information on rejected paths or validation failures.
  • Use host-based monitoring to detect unusual file write patterns from the Vikunja process, such as writes outside expected application directories.
  • Automated review tools:
  • Employ SAST tools and security-focused linters that understand Go idioms and can detect path traversal and unchecked indexing.
  • Periodically scan the codebase and dependencies for similar patterns in other components that handle archives or migration data.

Sources

SourceLink
github.comgithub.com/go-vikunja/vikunja/security/advisories/GHSA-42wg-38gx-85rh
vikunja.iovikunja.io/changelog/vikunja-v2.0.0-was-released

Frequently asked

questions

It can be, depending on how Vikunja is deployed and who can initiate restore operations.

If an attacker can upload or otherwise supply a ZIP archive to the restore endpoint (for example, by compromising an admin account or abusing a misconfigured management interface), they may be able to exploit it remotely.

Typically, the attacker needs access equivalent to someone who can trigger a backup restore in Vikunja—usually an administrative user or an automated process that accepts external backups.

The vulnerability is most dangerous when restore functionality is exposed to untrusted sources or when backup archives can be tampered with.

The safest pattern is to:

  1. Canonicalize and validate all archive entry paths against a dedicated base directory before any file operations, rejecting entries that do not conform.
  2. Introduce strict length and structure checks before indexing into slices derived from archive metadata.
  3. Replace panics with explicit error handling so that malformed archives cause controlled failures instead of crashes.

Treat all backup and archive contents as untrusted input.

Use well-established patterns for secure archive extraction (path normalization plus base-directory confinement), enforce rigorous input validation for assumed structures, and adopt coding guidelines that discourage panics in user-triggerable paths.

Complement these practices with static analysis, thorough code review of file-handling logic, and tests that cover malformed and adversarial archive inputs.

Find out what's already
exploitable in your codebase.