Replies: 1 comment
-
It depends how the responsability of pundit policy class is defined by team/community. If We define the responsibility of pundit policy classes as IMO: As for
Also if the team/community can't define/communicate the responsibility of the pundit class then a bit of more though/attention is needed to make a bit more clear Objects with clear Responsibility. |
Beta Was this translation helpful? Give feedback.
-
Hello,
apologies for the long post, I hope that this is clear
The (potential) problem
We've encountered a "problem" in our project related to the
index
policy implementation that might lead to unauthorized access and information disclosure. In our policies, we typically have:to override the
false
value from the default policy templateAnd in our controllers we verify the policies like this:
This setup means that we are not verifying that
index
is being authorized, which could lead to information disclosure. From the Pundit documentation, we see examples suggesting similar configurations:which is different from what we had before, but it has the same effect: the index policy is not being verified
The documentation states:
However, this can be confusing and may result in implementing insecure policies in controllers. For instance, consider the following situation:
Using the suggested approach in the controller, the policy unit specs might pass, but in reality:
index
action ifauthorize
is not called.destroy
, permitting users to destroy drafts from other users if the policy scope is not called.In most cases, we want to verify the policy scope and authorization everywhere. Currently, most of our
index
methods are set totrue
, for documentation rather than functionality or securityQuestions
index?
action be removed from the default application policy template?Beta Was this translation helpful? Give feedback.
All reactions