-
-
Notifications
You must be signed in to change notification settings - Fork 439
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
Support symlinks while not allowing malicious template paths. #442
Support symlinks while not allowing malicious template paths. #442
Conversation
I haven't tested this code so I apologize if this is a stupid question. Do these changes break using something like modman to keep the external modules outside of the core code directory? Something like |
It works with the files outside the Magento root because by default the
But you could create a symlink and reference it as usual with this patch. If an attacker has the capability of writing a symlink they would also be able to write a regular file as well. For example, the "symlink" check could be bypassed by just writing a file that has |
Iam against merging this without having at least one security expert reviewing this. |
@Flyingmana Please ask a security expert to review. :) |
I certainly don't consider myself an expert, but I approve @colinmollenhour's code here. We've been running essentially this code in production for clients for a long time now, mostly because up until the release of In my mind, the logic behind this code makes more sense than the original feature ever did, because it allows for symlinks to work inside the directory, but not allow arbitrary inclusion of any file path. As Colin mentioned, if somebody can write the symlink to include a malicious external file, they could likely have written the malicious file directly anyway. If there is a flaw in this implementation, I've been unable to see it. |
I keep repeating myself here: all of the attack vectors have not been seen by anyone here before.
this does not matter the sightliest for security vulnerabilities. There are some, which survive more then ten years. |
I'm well aware, I've reported a significant number of the ones patched by Magento. But if my opinions on the code don't matter in the slightest, I'll keep them to myself. |
Thanks for the review, @pocallaghan. I've seen your name on many of the vulnerability discoveries for bugs which existed for years and nobody else found so thanks for your continued contributions to Magento's security as well. I'm very happy to see you have some interest in this project, because if you're not a Magento security expert I don't know who is. :) @Flyingmana wrote:
When someone who has a proven track record of finding security vulnerabilities looks at an alternative solution for a well known vulnerability speficially in the context of examining security and says they don't see any flaws I think this means a lot more than you're giving credit for. This logic could otherwise be applied to every patch made on this project and so we should not accept any patches since every patch could introduce some new vulnerability. So, what exactly is your definition of a security expert and how can we determine which code is safe to update and which code is not? |
you are right @colinmollenhour , This is a proven track record of finding security vulnerabilities and totally counts. @pocallaghan |
+1 glad you got it sorted
And for all contributions!
…On Thu, 15 Mar 2018 at 17:12, Daniel Fahlke ***@***.***> wrote:
you are right @colinmollenhour <https://github.com/colinmollenhour> ,
This is a proven track record of finding security vulnerabilities and
totally counts.
@pocallaghan <https://github.com/pocallaghan>
I need to apologize and hope for forgiveness, as I usually dont check the
background of participants.
Could you then also add your approval to the PullRequest?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#442 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAn0a79At6jGbBEdp-HeNN6oc5euVS5qks5tepLvgaJpZM4R0Kv4>
.
|
@Flyingmana no apologies necessarily. As I said, I don't consider myself an expert, but I'm happy to offer my opinions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
I found that there is no way to load non inline CSS files in transactional emails when I'm using symlinks. magento-lts/app/code/core/Mage/Core/Model/Email/Template/Abstract.php Lines 238 to 247 in 40720ca
I think "$positionSkinDirectory" should be refactored too. |
LGTM. Can we get a couple reviewers? I just added an exception to be thrown for all fallback-based file paths if they contain '..' which should fix the issue observed by @idziakjakub while also reducing the chances of there being new or unknown vulnerabilities. |
Would be great to see this completed. Currently, the settings ( below ) mess up our installation as we use composer to install and manage all modules. Setting this to "0" breaks lots of templates in Amasty Nav modules and other modules The way we get around this is to use this command in our go-live scripts n98-magerun config:set dev/template/allow_symlink 1 |
Any objections to merging this? We're operating off of a fork right now but it would be nice to get back to the mainline. Setting |
in case someone needs a module to check symlink functionality, I found one which requires them in their install inscructions. Did not look in detail into it myself. |
The base branch was changed.
I changed based from 1.9.3.x to 1.9.4.x so all reviews are stale.. I would like to merge this pretty soon if there are no objections so please speak now or forever hold your peace. :) |
…hs and allow symlinks for inlinecss directive.
9b495d1
to
445b210
Compare
…plate paths * Support symlinks while not allowing malicious template paths. * Add protection for unauthorized file access to all fallback-based paths and allow symlinks for inlinecss directive. * Remove symlink notification.
…plate paths * Support symlinks while not allowing malicious template paths. * Add protection for unauthorized file access to all fallback-based paths and allow symlinks for inlinecss directive. * Remove symlink notification.
There is too much history to go into behind this ticket but as requested at colinmollenhour/modman#125 here is a PR that includes what I think is the best fix for the "Allow Symlinks" issue. This prevents use of ".." in the template paths and the
setScriptPath
but does not prevent use of symlinks outright. This is far more secure than enabling "Allow Symlinks" option since it still provides protection against inclusion of malicious files outside of the Magento base "design" directory. As far as I can tell it is just as secure as disabling "Allow Symlinks" option so since it doesn't suffer the downsides I don't see any need for an "option".Please test this with some of your deployments. It works for mine but I haven't tried it with a wider range of third party extensions. Also if anyone is privy to the vulnerability implementation details and can confirm that this circumvents them that would be great.