Skip to content
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

Prevent accidental file:// usage #8

Open
nyurik opened this issue Mar 11, 2016 · 4 comments
Open

Prevent accidental file:// usage #8

nyurik opened this issue Mar 11, 2016 · 4 comments

Comments

@nyurik
Copy link
Contributor

nyurik commented Mar 11, 2016

In some cases when this module is used with unsanitized data (possibly by accident), the ability to access "file://" is a major security issue. Please add a flag to explicitly permit file:// access, which IMO should be false by default. Also, please provide for an easy way to inject my own URL sanitization function right before that URL is being used. Thanks!

@nyurik
Copy link
Contributor Author

nyurik commented Mar 11, 2016

I added this code right after the case 'file://':, but i'm not sure this is the way to do it.

        if (!Image.enableFileProtocol) {
            console.error('file:// protocol is not enabled');
            return;
        }

@jieter
Copy link
Owner

jieter commented Mar 11, 2016

@nyurik can you open a PR adding these functionality?

@nyurik
Copy link
Contributor Author

nyurik commented Mar 11, 2016

@jieter, I don't think mine is the right approach - my code implies that the user will have to do something like this:

var L = require('leaflet-headless');
GLOBAL.Image.enableFlieProtocol = true;

whereas I think users should be able to do this:

var L = require('leaflet-headless');
L.enableFileProtocol = true;
// or
L.imageUrlSanitizer = function(url) {
  url = sanitizeUrl(url);
  return url;  // could be "falsey", string URL, or a buffer (in case I have the data locally available)
};

@jieter
Copy link
Owner

jieter commented Dec 17, 2016

@nyurik any interest in adding something to fix this? I've no personal need for it, so cannot invest the time implementing it. PR's still welcome of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants