Skip to content

KEP index loads jQuery and DataTables from third-party CDNs; the DataTables stylesheet has no SRI #851

Description

@TineoC

What happens

Loading https://www.kubernetes.dev/resources/keps/ pulls runtime assets from origins outside the project:

Request Origin SRI
jquery-3.6.0.min.js code.jquery.com yes
1.12.1/js/jquery.dataTables.js cdn.datatables.net yes
1.12.1/css/jquery.dataTables.css cdn.datatables.net no

Captured from the network log on a plain page load today.

Problems

  • The stylesheet has no integrity attribute, so it is the one asset here with nothing pinning its contents.
  • DataTables is pinned to 1.12.1, a 2022 release, with nothing in the repo tracking it.
  • If the CDN is blocked or unavailable, body-end.html returns early at if (typeof $ === 'undefined' || !$.fn || !$.fn.DataTable) return; and the page renders every KEP as one unpaginated table (see add discourse shortcode #6 below — currently 640 rows).
  • Visitors' requests reach two third-party hosts to view a Kubernetes project page.

Where

layouts/partials/hooks/body-end.html for the DataTables script; the jQuery and DataTables CSS tags come from the site's head config.

Suggested fix

Vendor the assets and let Hugo fingerprint them:

{{ $dt := resources.Get "js/jquery.dataTables.js" | fingerprint }}
<script src="{{ $dt.RelPermalink }}" integrity="{{ $dt.Data.Integrity }}"></script>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions