Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

[WEB-7892] fix(security): scope attachment PATCH/DELETE/GET by issue_id, drop created_by overwrite (GHSA-5mxw-g5mw-3v3w) (#9315)

Manish Gupta5829f0febf07
diff --git a/apps/api/plane/app/views/issue/attachment.py b/apps/api/plane/app/views/issue/attachment.py
index 51248b8a42..c4e7f0b0c8 100644
--- a/apps/api/plane/app/views/issue/attachment.py
+++ b/apps/api/plane/app/views/issue/attachment.py
@@ -148,7 +148,9 @@ class IssueAttachmentV2Endpoint(BaseAPIView):
@allow_permission([ROLE.ADMIN], creator=True, model=FileAsset)
def delete(self, request, slug, project_id, issue_id, pk):
- issue_attachment = FileAsset.objects.get(pk=pk, workspace__slug=slug, project_id=project_id)
+ issue_attachment = FileAsset.objects.get(
+ pk=pk, workspace__slug=slug, project_id=project_id, issue_id=issue_id
+ )
issue_attachment.is_deleted = True
issue_attachment.deleted_at = timezone.now()
issue_attachment.save()
@@ -171,7 +173,7 @@ class IssueAttachmentV2Endpoint(BaseAPIView):
def get(self, request, slug, project_id, issue_id, pk=None):
if pk:
# Get the asset
- asset = FileAsset.objects.get(id=pk, workspace__slug=slug, project_id=project_id)
+ asset = FileAsset.objects.get(id=pk, workspace__slug=slug, project_id=project_id, issue_id=issue_id)
# Check if the asset is uploaded
if not asset.is_uploaded:
@@ -202,7 +204,9 @@ class IssueAttachmentV2Endpoint(BaseAPIView):
@allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])
def patch(self, request, slug, project_id, issue_id, pk):
- issue_attachment = FileAsset.objects.get(pk=pk, workspace__slug=slug, project_id=project_id)
+ issue_attachment = FileAsset.objects.get(
+ pk=pk, workspace__slug=slug, project_id=project_id, issue_id=issue_id
+ )
serializer = IssueAttachmentSerializer(issue_attachment)
# Send this activity only if the attachment is not uploaded before
@@ -219,9 +223,9 @@ class IssueAttachmentV2Endpoint(BaseAPIView):
origin=base_host(request=request, is_app=True),
)
- # Update the attachment
+ # Update the attachment β€” do NOT overwrite created_by; it is set at
+ # creation time and must not be reassigned (GHSA-5mxw-g5mw-3v3w).
issue_attachment.is_uploaded = True
- issue_attachment.created_by = request.user
# Get the storage metadata
if not issue_attachment.storage_metadata: