Comments (11)
Hi,
the IFM was intentionally designed to operate only in the directory where it is located (including subdirectories) for security reasons. Meanwhile I softened this policy by adding a config option ("root_dir") where you can define a custom root dir. When you try to follow a symlink, the IFM checks if the link target lies under the root_dir. If not, you cannot follow the symlink.
I could add a config flag which allows to turn the security checks off completely, if that helps. Then symlinks should work correctly. I add this to my todo list ;)
Cheers,
Marco
from ifm.
Nifty. A bit nervous when hearing, "turn off all security"... is it an all or nothing gig, or would it be easy enough to allow symlink follows? I could also just clean up my fs...
from ifm.
Well, "turn off security checks" sounds more dangerous than it really is. The only "security check" is that the script restricts any operation above the configured $root_dir. Turning this off just means that you can do everything what the PHP user is allowed to do (according to unix permissions and the php config).
But I guess cleaning your fs isn't a bad idea either
from ifm.
I just thought a bit more about this. Adding a switch to disable the directory checks would be a big break in paradigm, so I'm a bit doubtful. Following symlinks pointing to a directory within the $root_dir should work. If you want to access a directory outside the $root_dir, I suggest not using a symlink, but a bind-mount:
# instead of
ln -s /your/path linkname
# just use
mkdir linkname
mount -o bind /your/path linkname
I just tested this and it works fine with the current version. I close this issue, but if you have any notes, please let me know!
from ifm.
H'm, not sure what you mean by paradigm shift. I don't see it being such a deep change?
I do a a lot with symlinks in terms of organizing my fs and partitions into a sensible structure which is easily manageable. For instance, I have all of my backup data in /mnt/backups
which has the folders local
and remote
, each with their own structure for various uses. It becomes desirable to link to either local
or remote
in different locations, such as /home/USER/Backup
for the local stuff, or /opt/project/data/backup
where I may want to drop ifm in at /opt/project
and be able to easily access the backup data. In a situation like this symlinks are the superior option because they are easily executed with a single, quick command which is accessible via right click as well. With triviality of creation and deletion, they present a flexible solution to my storage and organization problems that mount -o bind
doesn't meet, especially when working with different projects that may not have a very long shelf life.
Another use case is for my own simple remote access to stored files. I like to drop something like ifm into /home/USER/Public
and just quick link folders and large files that I need to access on the fly. This is, frankly, the single most indispensable case that I use. I was relying on Encode Explorer for this, but your script is truly improved over something like that in several ways, notably, folder and multi-select, zip, and the permission changing tools that are included.
Regardless, I like that mount -o bind
can be set to read only for the view it provides.
from ifm.
I don't see it being such a deep change?
Well, I use realpath() for checking if the target directory lies within $root_dir or deeper. Unfortunately realpath() resolves symlinks. I could disable this check, but then anyone could walk through the filesytem (or at least these parts, which are accessible to the PHP user), by moving to e.g. "../../../../etc". As realpath() is the safest method to prevent this, I don't really want to disable that. I just checked, if there is an alternative to realpath() which leaves symlinks unresolved, but didn't find anything helpful. Let me know, if you can think of another solution!
from ifm.
That makes sense. I will give it some time on the drawing board, maybe alongside the auth script I suddenly want to write :)
from ifm.
Let me know if you find a nice solution. I close this, for now.
from ifm.
What about stripping path traversal characters from the request with something like this
$_SERVER['REQUEST_URI'] = preg_replace('/^((\.*)(\/*))*/', '', $_SERVER['REQUEST_URI']);
from ifm.
There are a few solutions from here and plenty here for normalizing a path to prevent traversal. Passing a requested file path through a function such as one of these would allow for symlinks, and could merely return an error on the event that the file not exist.
Thought?
from ifm.
Hi,
sorry for the late reply. I take a look at the code again and check if this would be a sufficient solution ;) I hope to find time this week, but can't promise...
Cheers,
Marco
from ifm.
Related Issues (20)
- Right click to download not functioning HOT 1
- Drop-down menu empty HOT 1
- Double menus on small screen HOT 3
- Filenames with "#" are not handled correctly HOT 13
- Nothing displayed if "auth" => 1 HOT 19
- Content-Security-Policy incompatibilities HOT 5
- Overwrite warning even when file doesn't exist HOT 1
- Some files cannot be edited HOT 8
- Picture previews wonβt close HOT 5
- File creation w/ exists filename HOT 1
- RemoteUpload & AjaxRequest HOT 2
- Feature request: custom colours HOT 2
- Doesn't work on raspberry pi HOT 2
- chdir(): No such file or directory (errno 2) in /app/public/files/index.php on line 5926" HOT 2
- Folder upload doesn't work HOT 1
- How to use a non-user owner:group to delete files in a folder HOT 3
- Discussion: Current state HOT 3
- Outdated release (Oct 2020) HOT 1
- Hint on where the configuration is contained HOT 2
- ZipArchive Class Not Found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ifm.