-
Notifications
You must be signed in to change notification settings - Fork 1.8k
JS: Functionality from untrusted sources query (CWE-830) #8014
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
JS: Functionality from untrusted sources query (CWE-830) #8014
Conversation
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
(For completeness: even the use of HTTPS is problematic without an integrity check. A compromised JavaScript CDN that is accessed through HTTPS can easily respond with malicious content.) |
Yes, that is true; but in practice, the integrity check is almost never used — it would create a lot of noise to demand that. |
Hmm. Is there a significant difference in the result quality from the two queries that prevents us from having a single unified query? |
No, but the queries are completely different — one is a taint tracking query, and the other is working on the level of HTML elements. That was the reason I built two independent queries. |
I have now:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments from me.
Another point is that it would be nice to be consistent in how we format the words http
, https
and url
.
My suggestion would be:
http:
andhttps:
. In the alert message, surround with single quotes, in qhelp surround with<code>
.URL
. No other formatting.
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
I went through the experiment results with @esbena — they look good (except some failures that seem to be caused by DCA or github actions). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the general structure of the query, I think this can be a good query.
I got a lot of minor comments, mostly about the documentation.
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.qhelp
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.qhelp
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
Thank you, @erik-krogh, for the thorough review! I went through your comments and hope to have fixed them all. Are you happy with the fixes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more comments before I call it a day.
Your changes look good 👍
There are still two comments from my previous round that you haven't addressed.
Also, the autoformatter is failing.
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.qhelp
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.qhelp
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
Looks good, lets get a doc review on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a few editorial comments.
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.qhelp
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.qhelp
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.qhelp
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.qhelp
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.qhelp
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.qhelp
Outdated
Show resolved
Hide resolved
javascript/ql/src/Security/CWE-830/FunctionalityFromUntrustedSource.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/change-notes/2022-02-14-functionality-from-untrusted-source.md
Outdated
Show resolved
Hide resolved
Thank you, @hubwriter! I've added a new commit. |
This adds a query that finds HTML
<script src="http://somepage.com/foo.js"></script>
elements where thesrc
is only a http URL (not https) and there's no integrity checking. It also finds<iframe>
s where the src is a http URL.