![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
(This one is for the programmers out there, and especially for security geeks.)
As I was doing some updates yesterday, it occurred to me that Querki now allows you to name your Things pretty much anything you want. Including "javascript:...do something malicious...". Since we generate relative URLs to pages (and therefore, the URL is basically this name), this is Bad.
I've fixed the obvious hack by the simple expedient of screening out any URLs that begin "javascript:", but I'm guessing that that isn't enough -- that there are other ways to be malicious with a URL.
So I'm looking for suggestions. Take it for granted that Querki allows you to specify URLs, and that those URLs can be *fairly* arbitrary relative URLs, so I can't just whitelist a simple legal syntax -- I probably need to think in terms of blacklisting the badness. Do you know a good comprehensive list of the possible syntaxes that could be used for Javascript injection when placed inside an href? (Better yet, do you know an existing regex pattern to detect them?)
As I was doing some updates yesterday, it occurred to me that Querki now allows you to name your Things pretty much anything you want. Including "javascript:...do something malicious...". Since we generate relative URLs to pages (and therefore, the URL is basically this name), this is Bad.
I've fixed the obvious hack by the simple expedient of screening out any URLs that begin "javascript:", but I'm guessing that that isn't enough -- that there are other ways to be malicious with a URL.
So I'm looking for suggestions. Take it for granted that Querki allows you to specify URLs, and that those URLs can be *fairly* arbitrary relative URLs, so I can't just whitelist a simple legal syntax -- I probably need to think in terms of blacklisting the badness. Do you know a good comprehensive list of the possible syntaxes that could be used for Javascript injection when placed inside an href? (Better yet, do you know an existing regex pattern to detect them?)
(no subject)
Date: 2013-12-18 05:47 pm (UTC)You may want to look at one of my favorite books on the topic - although it is somewhat aging now (perhaps there is a more-recent version): How To Break Web Software by Mike Andrews and James A. Whittaker. My copy is Copyright 2006.
http://books.google.com/books/about/How_to_Break_Web_Software.html?id=zEWvS-sTiNUC
http://www.qualitytesting.info/forum/topics/pdf-downloadhow-to-break-web
James A Whittaker has a much more recent book which I do not have, called "How Google Tests Software". That might have some interesting information.
And, for fun: http://xkcd.com/327/
(no subject)
Date: 2013-12-18 06:37 pm (UTC)Well, I'm not going to spend much time vetting the links -- that's way out of scope. My concern is primarily with closing down any vectors for injecting Javascript into a Querki page. I've closed some already, and know of a few more that need to be dealt with, but I'm not an expert on the subject.
You may want to look at one of my favorite books on the topic
Useful-looking reference -- thanks! I may well Kindle it for the holidays.
(Bobby Tables was part of the design from the outset -- while I'm not a security specialist per se, any architect worth his salt needs to know basics like that. Suffice it to say, all SQL commands are done with prepared statements; so far, they appear to be safe.)
(no subject)
Date: 2013-12-18 05:59 pm (UTC)(no subject)
Date: 2013-12-18 06:42 pm (UTC)These sorts of URI nuances aren't an area of expertise for me, hence the question. It sounds like the rule about the syntax of schemes is probably the key for me to incorporate -- thanks!
(no subject)
Date: 2013-12-18 07:05 pm (UTC)(no subject)
Date: 2013-12-20 04:27 am (UTC)(no subject)
Date: 2013-12-20 01:04 pm (UTC)The one thing that this *does* raise as a potential problem, though, is that having a dot at the beginning of the name is the signifier of an OID. So I may have to disallow that anyway, to avoid ambiguity...
(no subject)
Date: 2013-12-18 07:24 pm (UTC)The OWASP ESAPI might be of use to you:
https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API
(no subject)
Date: 2013-12-18 07:29 pm (UTC)(no subject)
Date: 2013-12-18 07:51 pm (UTC)http://www1.contrastsecurity.com/
(no subject)
Date: 2013-12-18 07:54 pm (UTC)(no subject)
Date: 2013-12-19 04:37 pm (UTC)(no subject)
Date: 2013-12-19 05:12 pm (UTC)(no subject)
Date: 2013-12-20 11:58 pm (UTC)So javascript:whatever isn't an issue as long as when it's included in a link, it's actually href="html:relative_url", not href="relative_url_or_anything", and properly html encoded so it can't break out of the quote jail.
Similarly, it's not an issue in normal text (like the page title) as long as is encoded to the point that that's what appears on the page.
Obviously, you also may want to prohibit a -few- things (specifically, ../ due to the dual meaning), but that's still basically an enclosure issue, not putting something ambiguous into the uri.