Skip to content

Add permissions to enforce access to specific resource types [SEC-3811] #15655

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

Merged
merged 6 commits into from
Apr 15, 2021

Conversation

Mark-H
Copy link
Collaborator

@Mark-H Mark-H commented Apr 8, 2021

What does it do?

Adds dedicated permissions for weblinks, symlinks, and static resources to control who can:

  • create resources of that type (permission already existed, wasn't enforced)
  • edit resources of that type (new permission)
  • delete resources of that type (new permission)

Also includes a small tweak to the modManagerController to make sure a missing permission uses the "nice" error page, rather than a blank page.

Default policies for content editor, admin and developer are also updated to include these new permissions with the upgrade.

Why is it needed?

SEC3801 reported static resources allowing access to things it shouldn't, which included proof from the more demo site. That demo site is heavily restricted, which led me down a very deep rabbit hole where it turns out the relevant permission (new_static_resource) was not actually enforced. That resulted in this security fix to add missing permissions and making sure they're enforced.

How to test

First rebuild and run setup to add the new permissions.

  • On a user with these permissions, confirm the different resource types can be interacted with as usual (create, edit, delete).
  • On a user without these permissions, confirm you're presented with a friendly permission denied error.

Related issue(s)/PR(s)

https://community.modx.com/t/new-static-resource-permission-not-checked/3811/6

@Mark-H Mark-H added area-security urgent The issue requires attention and has higher priority over others. pr/review-needed Pull request requires review and testing. labels Apr 8, 2021
@Mark-H Mark-H added this to the v2.8.2 milestone Apr 8, 2021
@Mark-H Mark-H requested a review from opengeek as a code owner April 8, 2021 14:25
@cla-bot cla-bot bot added the cla-signed CLA confirmed for contributors to this PR. label Apr 8, 2021
Mark-H added a commit to Mark-H/revolution that referenced this pull request Apr 8, 2021
…lute paths [SEC-3801]

Reported by wfoojjaec, static resources can be used to read any file on the server through the use of absolute paths. This is a tricky balance between feature and vulnerability, and this fix shifts the balance to secure-by-default by requiring static resources to be within a certain path.

In the new default for all sites (including upgrades), static resources **must** be in the assets folder. It supports paths that are relative to the configured path (foo.pdf => assets/foo.pdf), relative to the MODX base path if the configured path is within that path (assets/foo.pdf), and absolute paths within the configured path (/home/user/public_html/assets/foo.pdf) for maximum compatibility.

By enabling the resource_static_allow_absolute setting, the previous behavior of allowing any valid absolute path to be used is restored. While that allows the user to access any file and should not be enabled lightly, some existing sites may need to do so in order to keep existing static resources working. At least then it's a conscious and informed decision to trust your users (which can be further enhanced by limiting access to static resources per modxcms#15655)

I have another patch https://github.com/Mark-H/revolution/commits/security-3801 which also supports media sources, however that's a feature that needs more work/discussion and is not suitable to introduce as a security fix, so I've only included the required paths here. Sorry, Susan. That will hopefully get picked up for 3.x.
@Mark-H
Copy link
Collaborator Author

Mark-H commented Apr 11, 2021

Can some people please test this to make sure I didn't typo any permission checks and users can still edit things after the upgrade?

@alroniks
Copy link
Collaborator

I will do Mark, don't worry

opengeek pushed a commit that referenced this pull request Apr 15, 2021
Reported by wfoojjaec, static resources can be used to read any file on the server through the use of absolute paths. This is a tricky balance between feature and vulnerability, and this fix shifts the balance to secure-by-default by requiring static resources to be within a certain path.

In the new default for all sites (including upgrades), static resources **must** be in the assets folder. It supports paths that are relative to the configured path (foo.pdf => assets/foo.pdf), relative to the MODX base path if the configured path is within that path (assets/foo.pdf), and absolute paths within the configured path (/home/user/public_html/assets/foo.pdf) for maximum compatibility.

By enabling the resource_static_allow_absolute setting, the previous behavior of allowing any valid absolute path to be used is restored. While that allows the user to access any file and should not be enabled lightly, some existing sites may need to do so in order to keep existing static resources working. At least then it's a conscious and informed decision to trust your users (which can be further enhanced by limiting access to static resources per #15655)

I have another patch https://github.com/Mark-H/revolution/commits/security-3801 which also supports media sources, however that's a feature that needs more work/discussion and is not suitable to introduce as a security fix, so I've only included the required paths here. Sorry, Susan. That will hopefully get picked up for 3.x.
@opengeek opengeek merged commit 2e05d94 into modxcms:2.x Apr 15, 2021
@opengeek opengeek removed the pr/review-needed Pull request requires review and testing. label Apr 15, 2021
@Mark-H Mark-H deleted the security-3811 branch April 16, 2021 12:42
@Mark-H Mark-H added the pr/port-to-3 Pull request has to be ported to 3.x. label Apr 16, 2021
@Mark-H
Copy link
Collaborator Author

Mark-H commented Oct 19, 2021

Could I convince someone to help port this to 3.x with a high five from this incredibly cute puppy?

afbeelding

@alroniks
Copy link
Collaborator

alroniks commented Nov 3, 2021

FYI, it is under WIP

@alroniks
Copy link
Collaborator

alroniks commented Nov 4, 2021

Port is added, so I guess the mission completed here :) I removed related label.

@alroniks alroniks removed the pr/port-to-3 Pull request has to be ported to 3.x. label Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-security cla-signed CLA confirmed for contributors to this PR. urgent The issue requires attention and has higher priority over others.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants