Summary
Vikunja's task attachment handler previously loaded attachments solely by their numeric ID, ignoring the task context supplied in the request URL.
As a result, any authenticated user could pair a task they can access with an arbitrary attachment ID and download or delete attachments belonging to other tasks and projects.
Affected context
The vulnerability occurs in Vikunja's task attachment API, specifically in logic that reads a single attachment.
The TaskAttachment.ReadOne() function constrained the database query by attachment ID only, while permission checks in CanRead() were tied to the task ID from the URL.
In deployments where attachment IDs are sequential and globally visible to authenticated users, this mismatch between authorization context (task) and data lookup (attachment) makes horizontal privilege escalation possible.
Exploit preconditions
- Attack surface: Vikunja HTTP API endpoints that serve download or delete operations for task attachments.
- Required access: Any authenticated Vikunja account with access to at least one task that legitimately contains an attachment.
- Trigger point: Issuing a request that supplies:
- A task ID for which the attacker has read/delete rights, and
- A target attachment ID belonging to some other task/project.
- Why exploitation is possible: The permission check validates access to the task from the URL (
CanRead()), butTaskAttachment.ReadOne()fetches the attachment purely by its ID (WHERE id = ?) without verifying that it belongs to that task, enabling cross-task attachment access.
Why this happens
This issue is a classic IDOR / broken object-level authorization problem mapped to CWE-639.
Authorization logic is bound to one resource (task), but the actual database lookup for the sensitive object (attachment) does not enforce that relationship.
The code trusts a single global attachment ID as sufficient to identify the resource, instead of treating it as scoped to a parent task or project.
Without a join or additional predicate tying attachment.id to the authorized task.id, any valid attachment ID becomes accessible to any user who can pass the initial task-level permission check.
Potential impact
- Unauthorized download of attachments from tasks in other projects.
- Unauthorized deletion of attachments belonging to other users or teams.
- Exposure of sensitive information stored in attachments, such as documents, credentials, or internal files.
- Indirect information disclosure through enumeration of attachment IDs and observing which IDs are valid.
- Damage to data integrity where critical attachments are removed or tampered with.
General mitigation guidance
Effective mitigation focuses on enforcing object-level authorization that is consistently scoped to the correct parent resource:
- Ensure all attachment queries include constraints that bind them to the authenticated user's authorized context, such as
WHERE id = ? AND task_id = ?. - Model attachments as children of tasks/projects in both the data layer and the authorization layer, so access is always checked against the parent entity.
- Centralize authorization checks for object retrieval and deletion to avoid drift between what is authorized (task) and what is actually loaded (attachment).
- Treat globally sequential identifiers as untrusted; design APIs assuming that IDs can be guessed or enumerated and must be revalidated server-side.
- Apply least-privilege access patterns so that general authenticated users have only the minimal required permissions on attachments.
How teams detect issues like this
Detection strategies generally revolve around identifying missing or inconsistent object-level authorization:
- Static analysis: Search for data access patterns where child objects (e.g., attachments) are looked up solely by primary key without complementary predicates tying them to a parent resource or current user.
- Code review: Flag controller or handler methods where:
- Authorization is performed on one entity (task/project) but database queries operate on another (attachment/file) without enforcing the relationship.
- Sequential or globally unique IDs are used directly from request parameters with no additional checks.
- Automated tests: Add regression tests that simulate a user trying to access an attachment from a task or project they do not own, ensuring access is denied.
- Runtime monitoring: Instrument APIs to log mismatches between the task ID in the URL and the task ID associated with the fetched attachment, then alert on suspicious patterns.

