Skip to content

workaround pyLTI1.3 to remove unsafe-inline from CSP #1662

@jaydonkrooss

Description

@jaydonkrooss

MyLA currently enables unsafe-inline for CSP Style and Script sources, which is not a safe security policy for production, especially since we have a nonce ready for use. This has been in place to call on the PyLTI library in lti_new.py, since this library redirects to a page with styles and scripts without the option to pass in a nonce.

Since we can't use nonce with this library, investigate two options: 1. replace the PyLTI redirect with our own in-house solution, or 2. find a way to calculate a hash value (SHA) to add to the header. I briefly looked into this found the relevant line of code in lti_new.py:

return oidc_login.enable_check_cookies().redirect(target_link_uri)

The PyLTI1.3 library loads HTML from CookiesAllowedCheckPage, which includes various inline scripts and styles. We can't add a nonce here, instead a calculated SHA may be possible, but there are some dynamically generated parameters we'd have to figure out.

I'll create an issue, but it seems to me that making CSP stricter is a challenge with this library: we should check how essential the use of this enable_check_cookies method is. If it is needed, we can either do the SHA or replace this redirect entirely with our own written functionality using a nonce.

Originally posted by @jaydonkrooss in #1649

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions