Skip to content

web: Fix unsafe HTTP script loading in Web GUI - #11183

Open
jorge-ferreira-pii wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:fix-WebGUI-local-assets-squashed
Open

web: Fix unsafe HTTP script loading in Web GUI#11183
jorge-ferreira-pii wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:fix-WebGUI-local-assets-squashed

Conversation

@jorge-ferreira-pii

Copy link
Copy Markdown
Contributor

Fixes #11065

The viewer and the saved report loaded leaflet, golden-layout, three, elkjs
and netlistsvg from CDNs, one of them over plain http (issue The-OpenROAD-Project#11065).  They
are vendored under src/web/third-party, embedded in the binary and served by
web_server, so nothing is downloaded at build time or at run time.

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request vendors several third-party browser libraries (leaflet, golden-layout, three, elkjs, netlistsvg) to ensure the web viewer and saved reports can run completely offline without fetching code from CDNs. It introduces an asset-locking script, updates both Bazel and CMake build systems to embed these assets, and implements C++ logic to inline stylesheets and images as data URIs into saved reports. The review feedback highlights two important improvements: first, using generic_string() instead of string() in resolveAssetPath to prevent path resolution failures on Windows due to backslash separators; second, using the noexcept overload of std::filesystem::remove with std::error_code to avoid potential crashes from thrown exceptions.

Comment thread src/web/src/web.cpp Outdated
Comment on lines +1063 to +1065
return (std::filesystem::path(base_dir) / std::filesystem::path(reference))
.lexically_normal()
.string();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

On Windows, std::filesystem::path::string() uses backslashes (\) as path separators. Since the embedded asset lookup table uses forward slashes (/) as keys, resolving paths with string() will cause lookups to fail on Windows. Using generic_string() ensures forward slashes are used on all platforms.

Suggested change
return (std::filesystem::path(base_dir) / std::filesystem::path(reference))
.lexically_normal()
.string();
return (std::filesystem::path(base_dir) / std::filesystem::path(reference))
.lexically_normal()
.generic_string();

Comment thread src/web/src/web.cpp Outdated

if (assets.missing()) {
// The warnings above name what was missed; no one is told this was saved.
std::filesystem::remove(filename);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using the throwing overload of std::filesystem::remove can cause the application to crash if an exception is thrown (e.g., due to permission issues or file locks). It is safer to use the noexcept overload that takes a std::error_code reference.

    std::error_code ec;
    std::filesystem::remove(filename, ec);

The lookup key is built with generic_string(), since the asset table is
'/'-separated whatever the host uses, and removing a report that could not be
assembled no longer throws over the error that has to be reported.

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
@jorge-ferreira-pii
jorge-ferreira-pii marked this pull request as ready for review August 19, 2026 19:59
@jorge-ferreira-pii
jorge-ferreira-pii requested a review from a team as a code owner August 19, 2026 19:59
@jorge-ferreira-pii jorge-ferreira-pii changed the title web: serve the browser libraries from the binary instead of CDNs web: Fix unsafe HTTP script loading in Web GUI Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web: Attempt to load scripts over unsafe http

1 participant