Skip to content

fix: use hashed chunk names for hash map - #5144

Open
zhangyx1998 wants to merge 2 commits into
vuejs:mainfrom
zhangyx1998:feat/secure-hash
Open

fix: use hashed chunk names for hash map#5144
zhangyx1998 wants to merge 2 commits into
vuejs:mainfrom
zhangyx1998:feat/secure-hash

Conversation

@zhangyx1998

@zhangyx1998 zhangyx1998 commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Description

Major changes

This update refactors page-chunk resolution to fix both problems in issue #5143: path-name collisions and unintentional route leakage.

  • Replaced flattened filename mapping (/_) with deterministic hashed keys.
  • Switched runtime lookup to a one-way map (canonicalPath -> assetKey -> lookupKey -> hash) so clients no longer have reversible page identifiers.
  • Refactored chunk naming from [name].[hash].js to [assetKey].[hash].js.
  • Added caseSensitive: boolean config entry.
flowchart LR

Canonical("<small>Maybe Private</small><br>Canonical Path _foo/bar_"):::orange
AssetKey("<small>DERIVED</small><br>Asset Key"):::yellow

subgraph Hashmap["<small>Client Hash Map</small>"]
LookupKey("<small>PUBLIC</small><br>Lookup Key"):::green
FileHash("<small>PUBLIC</small><br>FileHash"):::green
LookupKey --> FileHash --> LookupKey
end

subgraph Server["<small>Static File Server</small>"]
    Asset[("🔒 [AssetKey].[FileHash].js")]:::orange
    Bundler([🔨 Vitepress Bundler]):::blue
    Gateway((☁️)):::node
    Gateway --> Asset
end

Canonical --> AssetKey --> LookupKey

AssetKey --> Gateway
FileHash --> Gateway

linkStyle default stroke:gray,stroke-width:2px;

classDef node fill:#0004,stroke:currentColor,color:gray;
classDef green fill:#0004,stroke:currentColor,color:#AF0;
classDef orange fill:#0004,stroke:currentColor,color:#FA0;
classDef yellow fill:#0004,stroke:currentColor,color:#FF0;
classDef blue fill:#0004,stroke:currentColor,color:#0AF;

style Hashmap fill:#0001,stroke:gray,stroke-width:1px,stroke-dasharray:6 4,color:gray,opacity:0.6;
style Server fill:#0001,stroke:gray,stroke-width:1px,stroke-dasharray:6 4,color:gray,opacity:0.6;
Loading

Tip

Asset keys are never shared with the client. To resolve an asset key and load a chunk, the client must provide the correct canonical path. Since the client doesn't know the paths for unlisted pages, it cannot easily discover their asset URLs. This aligns with the expectation that unlisted files should not be trivially exposed, though it is not a 'cryptographically secure' solution.

Linked Issues

fixes #5143

/publish

@zhangyx1998 zhangyx1998 changed the title fix: use hashed chunk names for client side hash map fix: use hashed chunk names for hash map Mar 14, 2026
@brc-dd
brc-dd force-pushed the main branch 3 times, most recently from 15a0278 to 09af6c7 Compare March 26, 2026 04:26
@github-actions github-actions Bot added the stale label Jun 27, 2026
@brc-dd brc-dd mentioned this pull request Aug 9, 2026
4 tasks
@brc-dd brc-dd linked an issue Aug 9, 2026 that may be closed by this pull request
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Name Collision & Unintentional Link Leak file name too long

2 participants