Referring to security advisory SA-CONTRIB-2014-072 - Freelinking, Freelinking Case Tracker - Access bypass:
I am working with the security team on a patch for the 7.x-3.x branch to resolve the problem.
Please test and review the patch and report the results from your tests under this issue.
In order to review the patch, you need to do the following:
Clone the HEAD of the 7.x-3.x branch of the project:
git clone --branch 7.x-3.x http://git.drupal.org/project/freelinking.git
cd freelinking
Download and save the patch attached to comment #1 below in the freelinking directory.
git apply -v freelinking-SA-CONTRIB-2014-072-2313767-9.patch
Copy the freelinking directory, including all its subdirectories, into directory where you keep contributed modules (e.g. sites/all/modules/) on your testing site, and enable the module.
Important: If you're already running freelinking, remember to run the database update (available from the Administration » Reports » Status report page).
After installing the patch, the following problems should be repaired:
- Freelinks to node subject to access control should not be enabled for users without the right to access the node.
- Freelinks to users should not be enabled for users without the right to access user profiles.
Your help with reviewing the patch will help to get the project back from Unsupported status.
Comments
Comment #1
gisleComment #2
gisleComment #3
vijaycs85Let's review it.
Comment #4
vijaycs85Not very sure all these changes necessary for the security.
Looks like most of the changes here are not related to the security update. Happy to open a followup to for cleanup
$?
Comment #5
gisle$) at the end of an regexp means: "The pattern ends here". The change to the regexp identifying plugins is to stop it pulling in backup files (automatically created by editors such as emacs, vi, etc., such asplugin.inc~, plugin.inc-, plugin.inc.BAK) as valid plugins. Without this change to the regexp, it keeps crashing after any plugin edit if you forget to delete these backups, because any backup file will be parsed along with the original, producing double definitions.I can post a new patch without these changes if they bother you, but I hope it is possible to get this reviewed without undoing this.
Comment #6
asb commentedThanks for the patch. The instructions from above are easy to follow and the patch applies cleanly.
However, the module dos not process Wikipedia-style links as documented in README.txt ("…if you do not specity a plugin name the default one configured at Freelinking Settings page will be used").
Rendered HTML looks like this with Freelinking enabled:
…manufactured by <a href="/w/index.php?title=Creation&action=edit&redlink=1" class="new" title="Creation (page does not exist)">Creation</a>.</p>The rendered HTML looks identical with 'Freelinking' disabled, so in my use case it simply does nothing.
My filter processing order at
./admin/config/content/formats/mediawiki:MediaWiki API needs to be first because it processes Wikitags, but claims not to handle links (unlike 'mediawiki_filter'). 'Freelinking' is recommended to process links (cf. #2197879: incorrect links), but it's not unlikely that the problem lies in the implementation of MediaWiki API. Bottomline is that I can not report anything useful about the patch, sorry.
Comment #7
gisle@asb, the output you show comes from MediaWiki API, not from freelinking.
Both module uses the same syntax for links (double square brackets). When the MediaWiki API filter is given a higher priority, it converts the double square brackets to the rendered output you observe, and there is nothing for freelinking to process.
Btw, the patch does not interfere with this. This incompatibility with MediaWiki API has always been there.
If you want to use freelinking to process links, you must first disable MediaWiki API.
Comment #8
asb commentedThe funny part of this is that 'MediaWiki API' requires 'Freelinking' to process links ;-)
Comment #9
gisleHere is a new version of a patch to resolve the current security issue.
The difference between this and the previous patch is that the previous version turned off caching for any text type that had the freelinking filter enabled.
The new version will allow you to enable caching, provided your site has no node access control module enabled.
Refer to the summary for instructions for how to test.
Please test and write a review in this issue queue.
Comment #10
mlhess commented@gisle What about a Drupal 6 patch? The parent issue: https://security.drupal.org/node/76508, has one on it that might be able to use.
Can you post it here after confirming it fixes the issue?
Comment #11
gisleHere is a patch for the 6.x-3.x branch.
It is based upon the patch supplied by xurizaemon in https://security.drupal.org/comment/70483#comment-70483, but I've tested it and confirmed that it resolves the access bypass issue for this branch.
It works by turning of caching for any text format that uses the freelinking filter.
Please review this patch as well.
Comment #12
mradcliffeWhy are these files removed? Is this necessary for security? Wouldn't the users who use oneinchframe or path be discouraged that these features were removed? Are there additional security issues with these features?
Debug code cruft.
Is this related to the CVE on Drupal for file_download? Should we comment that?
I would probably use the patch as is, but I'm also confused as to the additional changes. I would think a security patch to fix it would suffice, and then a follow-up when taking ownership of the module to clean up the code standards.
Comment #13
gisleCHANGELOG.txtwas obviously outdated (as is easy to see if you compare it to the history recorded by git). Since we no longer require repos to have aCHANGELOG.txtand IMHO maintaining one "by hand" doesn't make much sense when we use git, I removed it instead of trying to update it.freelinking_oneinchframe.incgenerates freelinks to http://oif.eafarris.com/wiki, which is a wiki-page in a non-existing domain. It didn't make sense to keep it.freelinking_path.inchas very obvious security problems (There is even a comment that says: "This plugin exposes page titles without regard for security."), and what it does is (IMHO) of very little use, so I removed it instead of trying to fix it. If somebody really requests it, I may try to fix it and bring it back.Agreed. Since these are all commented out, I don't think this warrants a new patch. If I get custody of this project, I'll make sure they're removed in the next release.
If you look at the code block inserted just above the diff you cite, you'll see that it uses
module_invoke_allto invokehook_file_downloadto allow modules to enforce permissions on file downloads when the private file download method is selected.The code is IMHO self-explanatory, so I am not sure if this needs a comment, but I'll add one in the next release if you think that this is too oblique.
Comment #14
klausiThe patch is too large for a security review, IMO.
Please post a patch that only deals with the security issue(s), you can perform all other changes afterwards.
Comment #15
mradcliffeHere are some slimmed down patches.
- If a file had some standards corrections, I left those changes intact from the previous patches.
- Removed file deletions from patch.
- Removed files that only contained standards corrections from patch.
- Removed dpm() from Drupal 6 patch.
Comment #16
gisleHere are new set of patches for both the D6 and D7 versions with the minimum number of changes required to fix the security issue.
Bugs are left unfixed, and code standards are ignored (as they are in the original).
Please note that the plugin named
freelinking_path.incis removed from the repo. That plugin has multiple security problems and must be discontinued.Comment #17
matt v. commented@gisle,
I tested and reviewed the new patches in comment #16 above. Both patches appeared to fix the issues, after running "drush updb".
Related to mradcliffe's question 3 in comment #12 above, it's a unclear to me how the changes to plugins/freelinking_file.inc relate to the original Access bypass issue and therefore why those changes are still included in this set of patches. Other than that, the patches look good to me.
Comment #18
gisle@Matt V.
the original Access bypass issue (https://security.drupal.org/node/76508 - restricted login) did not mention files (only links to nodes or users) or
plugins/freelinking_file.inc, but the problem with access to files was introduced later in that issue (around comment #13) IIRC.The patches to
plugins/freelinking_file.incis required to make the project secure. The problem is specific to this plugin, and not related to the CVE on Drupal for file_download.Comment #19
matt v. commented@gisle,
Okay, I see the change introduced in that comment/patch now. And I understand the need for it. I just couldn't find it referenced in the comments.
I'm going ahead and marking this RTBC.
Comment #22
mradcliffeAwesome work, gisle!
Comment #23
gisleIt must be said that the credit for fixing this should go to xurizaemon and juampy. My part has been to steer the result of their diligent work through the security team's procedure for restoring the project's supported status.
Comment #24
gisleCommitted to the repo.