Opened 2 months ago

Last modified 2 months ago

#29490 new New feature

Subresource integrity for form assets

Reported by: Meiyer Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

SRI gives the web site author some guarantees that an external resource (typically, a script), included within the web page, has not been altered. For example, various external libraries are loaded from a CDN or another third-party repository, implicitly trusting that repositories’ security, but these libraries can be modified or tampered with to include malicious code, with the web site author not aware that this malicious code is now running on their web site in the context of their own web application. SRI prevents the loading of such resources if they were modified.

SRI is implemented by the means of the “integrity” attribute on the <LINK> and <SCRIPT> HTML elements. It is relevant to Django, because the form assets (“Media”) may point to resources on external repositories. But Django does not allow any way to specify the “integrity“ attribute (and the “crossorigin” attribute) for the assets of the forms.

I suggest modifying the Media class definitions such that the assets are not a simple list but a dict (with keys such as src, integrity, crossorigin), resulting in corresponding HTML elements being rendered appropriately. There can be a fallback to the simpler case when a list or tuple is provided, for backwards-compatibility.

Change History (2)

comment:1 Changed 2 months ago by Claude Paroz

Triage Stage: UnreviewedAccepted

comment:2 Changed 2 months ago by Tim Graham

I'd say maybe. There's also some thought in #22298 to deprecate the Media class.

Note: See TracTickets for help on using tickets.
Back to Top