Subresource Integrity
- Dominant language
- No language data
- Stars
- 188
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
### Code of Conduct
- [x] I agree to follow Django's Code of Conduct
### Feature Description
Now, with DSP taken care of, should we tackle [subresource integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Defenses/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](https://owasp.org/Top10/2025/), I believe it might be a commendable effort.
Approving CDNs and vendors is a start, but I’d love SHA512 hashes, just in case :wink:
### 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](https://github.com/realOrangeOne/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](https://docs.djangoproject.com/en/5.2/topics/forms/media/#form-media-asset-objects) and `CSS` objects, which render integrity values into the template.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.