The security vulnerability, described as allowing arbitrary modification or deletion of attachments, is primarily addressed in the APIV1Service.SetMemoAttachments function within server/router/api/v1/memo_attachment_service.go. Before the patch, this function failed to check if the requesting user was the owner of the memo, thus permitting any authenticated user to alter attachments on any memo. The fix introduces a crucial authorization check, restricting this action to the memo's creator or a superuser.
The associated commit, however, reveals a broader pattern of missing authorization checks across multiple API services. The patch addresses several other improper access control vulnerabilities:
APIV1Service.SetMemoRelations: Similar to the attachment issue, it allowed any user to modify memo relationships.
APIV1Service.DeleteMemoReaction: Allowed any user to delete another user's reaction.
APIV1Service.UpdateIdentityProvider and APIV1Service.DeleteIdentityProvider: These administrative functions were exposed to all authenticated users.
APIV1Service.GetIdentityProvider and APIV1Service.ListIdentityProviders: These functions leaked sensitive OAuth2 client secrets to non-administrative users.
The root cause across all these functions was the absence of proper authorization logic to verify user permissions before executing sensitive operations. The patch systematically adds these checks, ensuring that actions are only performed by users with the appropriate roles and ownership.