Skip to content

Subresource Integrity #125

@codingjoe

Description

@codingjoe

Code of Conduct

  • I agree to follow Django's Code of Conduct

Feature Description

Now, with DSP taken care of, should we tackle subresource integrity next?

The header is supported by all browsers and might serve as a great addition to Django excellent security suite.

Problem

With supply chain attacks climbing to 3rd place on the OWASP ranking, I believe it might be a commendable effort.

Approving CDNs and vendors is a start, but I’d love SHA512 hashes, just in case 😉

Request or proposal

proposal

Additional Details

https://developer.mozilla.org/en-US/docs/Web/Security/Defenses/Subresource_Integrity

Implementation Suggestions

@RealOrangeOne has been maintaining django-sri for a good while now.

However, his approach was limited by Django's storage system.

I would propose to:

  1. The actual header implementation is mostly a copy-paste job of the CSP middleware.
  2. Add a integrity() function to the BaseStorage as well as a sample implementation for the FileSystemStorage.
  3. Optionally, add an integrity template tag to static, which doesn't call url but the new integrity function.
  4. Finally, we can safely wrap string paths in media assets in the Script and CSS objects, which render integrity values into the template.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Idea

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions