Hi,
I have installed and configured WebFM and it works perfectly, thanks. Now however I am having problems trying to configure Apache/Drupal/WebFM to prevent unauthorised access to files.
I have Googled around and found some relevant discussions, but unless one has good web development skills it is not easy to join all the dots and get one's own particular setup working. Here are a few of the webages I have read:
http://drupal.org/node/145652
http://drupal.org/node/372322
http://drupal.org/node/415332
I will try to explain my understanding of WebFM file access controls with the helps of a simple use case:
A user that is authorised to access (read) a node can access WebFM files that are linked to the node. Otherwise the files are only accessible by users with "access webfm" permission.
I can use two different ways to link files to a node using WebFM: either inline as a hyperlink or as a WebFM attachment. To create a hyperlink I use FCKEditor which is configured to allow me to browse WebFM for a file. WebFM in turn provides the context menu option "Send to rich text editor" which returns a direct link of the form "/sites/default/files/webfm/a/b/c.txt" The other option to link a file is to enable "WebFM Attachments". This provides the context menu option "Attach to Node" which attachs the file to the node with a streaming link "http://www.acme.com/webfm_send/20". Both are useful methods to have enabled.
From a security point of view, neither method fulfils the use case requirements. For a start the direct link is always accessible whether or not you are logged in. This I assume is because I use the default "Public" files setting in Drupal (admin/settings/file-system) which is also recommended in the WebFM README.txt. The other method, webfm_send, prevents at least access to the file by anonymous users but since only the file uid is provided to webfm_send it cannot provide fine-grained controls such as access only to files that are attached to nodes the user can access.
A common security approach is to deny all and then allow specific users access to specific files. In this regard I think it would help to clarify what security model WebFM supports. Is it an all-in-one solution or does it require integration with Apache (htacess/htpasswd) and Drupal (file settings)? Or put another way, what combination of File System/Apache/Drupal/WebFM security controls are required to "lock down" the installation initially? Once that is sorted, one could proceed with describing how to implement different use cases.
Some other questions:
2) Why are inline links direct and attachments use webfm_send?
3) How do I prevent anonymous access to direct links with Drupal "Public" file access set?
4) What is the purpose of the permission "view webfm attachments"? It only hides the attachments, it does not prevent access to the files.
5) What are the prerequisites for the WebFM "Public download" file permission to work properly? Does it require the use of webfm_send?
Your insights are much appreciated.
Best regards,
Kevin
Comments
Comment #1
kevin.mcnamee@mailbox.org commentedI have tested some more and installed RC5. I think I can now answer all of my above questions. I humbly submit my experiences so that they might be of help others. Caveat emptor!
The goal of this guide is to lockdown a WebFM installation. It is based on version 6.2-rc5 using a LAMP setup.
Users familiar with Drupal (or not) and new to WebFM should be aware of the following behaviours in WebFM.
WebFM defines a file access security model that is implemented in a module in Drupal. In other words it sits on the underlying security models of the Linux file system, Apache and Drupal. This requires that they be properly configured if the WebFM security controls are going to work properly.
Locking down the WebFM installation means preventing access to files in WebFM by unauthorised users. The strategy is to first deny all access and then to selectively enable access for authorised users.
This denies all access to the files using direct links for both authorised and unauthorised users. Even better if this can be placed in the Apache config without enabling the AllowOverride directive.
http://httpd.apache.org/docs/2.0/howto/htaccess.html#when
The Default File Permissions in the WebFM settings are important. Check 'Role View Access', 'Role Attach Access' and optionally 'Role Full Access' depending on how much trust there is between role users.
In is worth noting that because webfm_send uses the file uid, links to files are not affected when a file is moved or renamed in the File Manager.
Now WebFM can be configured to allow access to files. But first we need a use case. For demo purposes the following actors have been identified:
To implement the use case (focusing on the WebFM settings):
Assign the webmaster role to the appropriate user. The WebFM configuration (/admin/settings/webfm) will ask for a root directory for the webmaster role which can be set to 'webmaster' (for example). The webmaster can then manage their own separate filespace.
This fulfills the use case requirements while maintaining proper file access controls. The only weakness is the difficulty in managing files with the "Public download" setting enabled.
Feedback and corrections appreciated.
Best regards,
Kevin
Comment #2
kevin.mcnamee@mailbox.org commentedComment #3
robmilne commentedI don't have time at the moment for a detailed response except for these two points:
#1 at the top is incorrect. The uid of any file can be reassigned by an admin via the metadata popup. A limitation of this method that I haven't addressed is the possible assigning of a file to an invalid uid (making this feature more usable is on to my todo list). Another way to reassign ownership is to simply remove the file from the database and then re-insert it. This changes ownership to the administrator taking those actions, however the metadata is trashed. An important feature of the system that you haven't mentioned is the option of not having a file in the database at all which essentially makes it hidden except to admins. I use this feature to keep old versions of releases of commercial software that I develop on the server.
Your criticism re: "public download " is a good one that I haven't put a lot of thought to. I developed the module according to my own preferences and this kind of feedback is invaluable to my understanding of how others put it to use.
Comment #4
kevin.mcnamee@mailbox.org commentedThanks for the feedback.
I was looking for issues regarding anonymous file access and I came across
http://drupal.org/node/475294#comment-1745206
Of course! The "anonymous user" role can also have the "access webfm" permission to download files that are inline links without the files also having to be attached to the node.
This means that #3 and #4 at the bottom of comment #1 are also incorrect. Using sub-directories to create subsets of files, the following root directory hierarchy can be used (following the above example):
This is a much more elegant solution since users that can browse files in the File Manager can clearly see which files are available to which roles. It is also an easy matter to change the security level of file by simply dragging-and-dropping a file into one of these directories.
So the question is, is the "Public download" file permission necessary since Anonymous users can have their own well-defined download area?
Comment #5
kevin.mcnamee@mailbox.org commentedGiving the "anonymous user" role the permission "access webfm" so that anonymous users can view files that are hyoerlinks in nodes requires some extra thought.
Unfortunately, this permission will also allow anonymous users to browse files in the File Manager and so files in this root directory must have their permissions reduced to "Role View/Download" to prevent arbitrary changes to the files. (The "Role Attach" permission has no effect unless anonymous users can also create content).
But now the other roles in the hierarchy (power users and webmaster) that are supposed to manage and update these files can no longer do so because the files lack the "Role Full Access" permission.
Conclusion? Since the role permissions are at the file level, it is not possible to allow full access to one role and read-only access to another. The root directory hierarchy simply provides all-or-nothing file access for a role.
As a result, my original suggestion in Comment #1 still applies: to use a hyperlink to a file in the File Manager, the file must also be attached to the node - not a very elegant solution.
This analysis also highlights a security risk. If one is using a root directory hierarchy, the Default file permissions for uploaded files should not include "Role Full Access". Alternatively, users must be made to understand that a file uploaded to a sub-root directory confers full access to the file for that subordinate role.
A more conservative approach is to not have "Role Full Access" per default but to force users to enable it on a file by file basis.
Finally, it would be nice to be able to see which files have full access and which files are view/download or Public access. Lacking any bulk manipulation or filtering tools, a simple solutioin could be to use extra columns in the File Manager showing which permissions are enabled on each file.
Comment #6
paranormals commentedkmcnamee - really useful documentation, thank you!
Comment #7
nhck commentedThis should somehow go into our docs.