Skip to content

fix: add Subresource Integrity hashes for CDN-loaded Leaflet plugins - #606

Open
pipe0919 wants to merge 92 commits into
liodali:masterfrom
pipe0919:fix/add-sri-hashes-cdn-scripts
Open

fix: add Subresource Integrity hashes for CDN-loaded Leaflet plugins#606
pipe0919 wants to merge 92 commits into
liodali:masterfrom
pipe0919:fix/add-sri-hashes-cdn-scripts

Conversation

@pipe0919

Copy link
Copy Markdown

Summary

  • Adds SHA-384 integrity and crossorigin attributes to two CDN-loaded Leaflet plugin scripts in flutter_osm_web/lib/src/asset/map.html

Problem

The map.html WebView loads four external scripts. The two Leaflet core files from unpkg.com already include SRI integrity hashes:

<!-- Already has integrity ✓ -->
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
  integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>

However, the two plugin scripts from cdn.jsdelivr.net do not:

<!-- Missing integrity ✗ -->
<script src="https://cdn.jsdelivr.net/npm/leaflet-rotatedmarker@0.2.0/leaflet.rotatedMarker.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/leaflet-hotline@0.4.0/dist/leaflet.hotline.min.js"></script>

Without Subresource Integrity (SRI) hashes, a CDN-side compromise or substitution would execute unvalidated JavaScript in the map WebView context.

Changes

Added integrity="sha384-..." and crossorigin="" attributes to both plugin script tags, matching the pattern used by the existing Leaflet core includes.

References:

Test plan

  • Verify the map WebView loads correctly with the SRI hashes
  • Verify rotated markers still render (leaflet-rotatedmarker)
  • Verify hotline/polyline rendering still works (leaflet-hotline)
  • Verify no console errors related to integrity check failures

liodali and others added 29 commits June 25, 2025 19:44
Add script to automate publishing process for flutter_osm_interface and flutter_osm_web packages
- Remove redundant async/await in simple getter methods
- Improve code readability by reducing line length
- Upgrade com.android.application plugin to 8.12.0
- Update gradle wrapper to 8.13
- Bump Java compatibility to version 17
- Adjust minSdk to 30 and targetSdk to BAKLAVA
- Update Android Gradle plugin to 8.12.1
- Bump compileSdk to 36
- Upgrade Retrofit to 3.0.0
- Update Kotlin coroutines to 1.10.2
- Enable minification and resource shrinking for release builds
- Set JVM target to version 17
Add Cross-Origin-Embedder-Policy and Cross-Origin-Opener-Policy meta tags to enhance security and prevent potential cross-origin issues
Change COEP and COOP headers to improve security and compatibility
Ensure proper cross-origin resource sharing by including the missing CORP meta tag
add package_info_plus and dio dependencies to fetch map assets from GitHub CDN
modify WebOsmController to accept HTML content as parameter
update Cross-Origin-Embedder-Policy to credentialless
Clean up commented out code and unused imports related to package info and CDN version handling that are no longer needed
Enable web support by adding required flutter_web_plugins dependency and configuring URL strategy
The map.html WebView loads two Leaflet plugin scripts from
cdn.jsdelivr.net without integrity attributes:
- leaflet-rotatedmarker@0.2.0
- leaflet-hotline@0.4.0

The two Leaflet core files from unpkg.com already include correct SRI
hashes. This commit adds SHA-384 integrity hashes and crossorigin
attributes to the two plugin script tags, matching the pattern already
used by the Leaflet core includes.

Without SRI, a CDN compromise or man-in-the-middle substitution would
execute unvalidated JavaScript in the map WebView context.

References:
- CWE-353: Missing Support for Integrity Check
- https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
@liodali

liodali commented Apr 1, 2026

Copy link
Copy Markdown
Owner

your pr contain other staff can you make new one with just cdn fixes

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants