Harden XSS - #5832
Harden XSS#5832multimeric wants to merge 3 commits into
Conversation
|
|
||
| # Helper that builds a Header directive to set the Content-Security-Policy for a given uri | ||
| def node_csp_header(uri) | ||
| origin = "#{@protocol}#{@servername || @proxy_server}#{uri}/%{MATCH_HOST}e/%{MATCH_PORT}e/" |
There was a problem hiding this comment.
I think proxy server should take precedence here - I wonder if there's a helper somewhere to determine the actual client facing host.
There was a problem hiding this comment.
Okay, I'll have to think about this one, the architecture of OOD complex. Is there a diagram somewhere? Do we necessarily know which server is serving up a given interactive app? If not, I could just allow both?
There was a problem hiding this comment.
If the proxy server is enabled it's in front of apache. Think about an HAProxy in front of 2 OOD instances like so
site1.edu
/
site.edu (proxy_server) <
\
site2.edu
Which is to say - that's what the browser/user would see and interact with - site.edu.
Seems like you can use @proxy_server as it'll default to the servername if it's not set.
| # Reject requests to the PUN that didn't come from within pun_uri (e.g. an | ||
| # interactive app proxied at node_uri/rnode_uri), unless it's a real page load | ||
| RewriteEngine On | ||
| RewriteCond %{HTTP:Sec-Fetch-Dest} !=document | ||
| RewriteCond %{HTTP_REFERER} !^https?://[^/]+<%= @pun_uri %>(/|$) | ||
| RewriteRule ^ - [F] |
There was a problem hiding this comment.
@treydock I think I'd like your take on this as well.
At a glance it seems OK - though I'm wondering about edge cases, though I can't think of any we need to account for. HTTP_REFERER from another site (like a link from a documentation page) will be a document so that's fine.
Do we also need Sec-Fetch-Site or is it redundant?
There was a problem hiding this comment.
Looks like Sec-Fetch-Site can at most distinguish cross-origin which isn't helpful here because both servers have the same domain so the same origin. But I still want to prevent cross communication
|
I think connect-src will block WebSockets. A https://... CSP source does not match wss://... under CSP's scheme-matching rules. Open OnDemand currently supports applications that depend on WebSocket/Websockify traffic. If I remember correctly, a same-origin interactive app can change its displayed/current URL to /pun/... with history.pushState() without causing navigation. That URL is then used as the Referer for subsequent requests. That reduces the usefulness of Referer as a check. |
Okay, I can specifically build the
Hmm why can it do this? Is there a better way to stop interactive apps from sending traffic to the dashboard then? I suppose I could also add |
Ohh I think I understand now. You're saying that a malicious script could spoof its I'm open to cutting the |
What does this PR do, and what is the related issue, if applicable?
Adds two lines of defence for XSS from untrusted apps:
connect-srcandform-action) to interactive apps that restricts their ability to make requests outside of that individual app URLSec-Fetch-Dest: document(allowing you to browse there directly), or that have aRefererheader which is the PUN itself.Fixes #5824
Testing
test helpQuestions
Documentation
Code Authorship & Understanding
and I take responsibility for its correctness.
Checklist
Anything else?
I only made two small edits. The rest of the changes are updating the fixture files which causes a lot of diff noise.