Wrong way around: only allow http:// and https:// (and generally filtering out anything thats not letters, numbers, slash or dot is probably a good idea. Remove any sequences of more than one slash or dot.
If your code accepts URIs as input, filter out “file://”
11–20 of 161 posts
Re: If your code accepts URIs as input, filter out “file://”
#12Re: If your code accepts URIs as input, filter out “file://”
#13This is the confused deputy problem. The most general solution to this class of vulnerabilities, SELinux, has been largely ignored. Does SELinux need more work to "bring it to market", or is it just too complicated and needs to be simplified?
Re: If your code accepts URIs as input, filter out “file://”
#14This is the confused deputy problem. The most general solution to this class of vulnerabilities, SELinux, has been largely ignored. Does SELinux need more work to "bring it to market", or is it just too complicated and needs to be simplified?
configuring SELinux is way too complicated for the average user.
Re: If your code accepts URIs as input, filter out “file://”
#15I usually only do this, if I'm putting a user-submitted URL into file_get_contents: if(substr($_GET['url'], 0, 4) != 'http') { exit; }
If thats the only validation on calls to file_get_contents, that could very easily be bypassed. Entering something like just "/etc/passwd" for example.
Re: If your code accepts URIs as input, filter out “file://”
#16This is the confused deputy problem. The most general solution to this class of vulnerabilities, SELinux, has been largely ignored. Does SELinux need more work to "bring it to market", or is it just too complicated and needs to be simplified?
However, if you have a single image that you are going to make millions of copies of then the effort vs reward might slant in SELinux's favour, e.g. Android does use SELinux.
Re: If your code accepts URIs as input, filter out “file://”
#17These were recently released to help people deal with these issues since the details can be finicky: http://blog.includesecurity.com/2016/08/safeurl-server-side-...
Re: If your code accepts URIs as input, filter out “file://”
#18I tried Python requests and Common Lisp drakma, and neither of them can handle "file://" URL schema. Which HTTP client libraries are actually vulnerable to this?
Re: If your code accepts URIs as input, filter out “file://”
#19Not stripped, but replaced by spaces. Also, the linked image looks like /etc/passwd, not /etc/hosts.
> Weird.
Not weird. That's how whitespace in HTML works.
Re: If your code accepts URIs as input, filter out “file://”
#20Wrong way around: only allow http:// and https:// (and generally filtering out anything thats not letters, numbers, slash or dot is probably a good idea. Remove any sequences of more than one slash or dot.
Exactly. Whitelist only trusted schemes, do not wait to blacklist untrusted. I wrote the Go HTML sanitizer: https://github.com/microcosm-cc/bluemonday and have a rule for user generated (untrusted) content that basically does whitelist just the things that one can trust: https://github.com/microcosm-cc/bluemonday/blob/master/helpe... That states that URIs must be: 1. Parseable 2. Relative 3. Or one of: mailto http ht…