Skip to content

Conversation

@papphelix
Copy link
Contributor

This pull request is to fix the file param in URL which is creating security issue by sending arbitrary data in query param which can put cms under risk of different attacks like

  • random load which is read
  • xss attack if pdf.js is not handling properly while reading file param

Issue Screenshots:
image

image

Fixes done:

  • Removed File param from iframe src
  • Added postmessage based communication to pass on file path for loading the PDF on the pdf.js
  • When the url of iframe is opened it will always show chapters first pdf by default.
pdf-file-param-removal.mov

Copy link
Contributor

@feanil feanil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@papphelix I'm not super familiar with the JS for this page, can you add more comments and explainations for this code and why it's needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a vendored file so we don't want to make changes to it to ease transition to newer versions of the vendored library.

entry['url'] = remap_static_url(entry['url'], course)
# Security: Validate chapter URL doesn't contain dangerous schemes
if entry['url'].lower().startswith(('javascript:', 'data:', 'vbscript:', 'file:')):
entry['url'] = '' # Sanitize dangerous URLs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to atleast log a message in the case where the URL might be malicious so that operators can notice and potentially react to the issue. The message probably needs to contain the malicious URL and the course it's in in order to respond to the issue.

PDFJS.cMapUrl = "${static.url('css/vendor/pdfjs/cmaps/') | n, js_escaped_string}";
PDF_URL = '${current_url | n, js_escaped_string}';

var PDF_URL = '${current_url | n, js_escaped_string}';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what the goal of this function is? It looks like previously we were just letting the pdf.js library load the PDF from the PDF_URL, what is the pupose of all this exctar loading logic?

</div>
<div class="progress-actions">
<input type="button" value="Cancel" class="mozPrintCallback-cancel">
<div id="mozPrintCallback-shim" hidden>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it's a formatting cleanup independent of this change, can you make this change in a separate PR to make the delta smaller and easier to review?

tabindex="-1"
seamless></iframe>
</div>
<iframe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting change seems unnecessary to this PR and can also be in a separate PR if you feel strongly about making it.

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

Successfully merging this pull request may close these issues.

3 participants