Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associations are not validated #342

Open
schovi opened this issue Sep 30, 2024 · 0 comments
Open

Associations are not validated #342

schovi opened this issue Sep 30, 2024 · 0 comments

Comments

@schovi
Copy link

schovi commented Sep 30, 2024

Imagine following structure:

account (Account)
  -> posts (Post)
    -> owner (User)

And following malicious code that assigns the post to an owner from a different account:

account_malicious = Account.create
user_malicious = account_malicious.users.create!

account_1 = Account.create
ActsAsTenant.current_tenant = account_1

user_1 =  account_1.users.create!
post_1 = account_1.posts.create!(owner: user_1)

post_1.update!(owner_id: user_malicious.id) # passes

Expected behaviour: Acts as tenant will prevent such malicious update.

I understand this is not always possible, for example for raw sql updates, but when using ORM I would expect such validation.

The example above is quite artificial, but imagine a common controller update, where you can pass the params via curl

params = {
  post: {
    owner_id: malicious_id
  }
}
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

No branches or pull requests

1 participant