Skip to content

Fix IDOR: Validate pinned_post belongs to account#60

Open
bellisabell wants to merge 1 commit intomainfrom
bell/fix-idor-pinned-post
Open

Fix IDOR: Validate pinned_post belongs to account#60
bellisabell wants to merge 1 commit intomainfrom
bell/fix-idor-pinned-post

Conversation

@bellisabell
Copy link
Member

Summary

Fixes #20 - Security: IDOR - Cross-account post pinning vulnerability

Problem

account_params in AccountController permits :pinned_post_id but never validates that the post actually belongs to the current account. This allows an attacker to pin any post from any account by manipulating the pinned_post_id parameter.

Solution

Added a model-level validation pinned_post_belongs_to_account that ensures:

  • If pinned_post_id is set, it must reference a post owned by the account
  • Uses posts.exists?(id: pinned_post_id) to verify ownership

This is implemented at the model level (rather than controller) to ensure the validation applies regardless of how the account is updated.

Severity

HIGH - This is an IDOR vulnerability that could expose private/unlisted posts from other accounts.

Fixes #20

Added model-level validation to ensure pinned_post_id can only be set
to a post that belongs to the current account. Previously,
account_params permitted :pinned_post_id without any ownership check,
allowing attackers to pin posts from other accounts.

Security: HIGH - Prevents cross-account post pinning vulnerability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: IDOR - Cross-account post pinning vulnerability

2 participants