Skip to content

Conversation

@Legend-Master
Copy link
Contributor

@Legend-Master Legend-Master commented Dec 30, 2025

Also, re-use the nonce through out a single HTML file to save compute and limit collisions

Reference: #14708 (comment)

@Legend-Master Legend-Master requested a review from a team as a code owner December 30, 2025 04:14
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Dec 30, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2025

Package Changes Through bee0175

There are 7 changes which include tauri-utils with patch, tauri-build with patch, tauri-cli with patch, @tauri-apps/cli with patch, tauri-runtime-wry with patch, tauri-runtime with patch, tauri with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-utils 2.8.1 2.8.2
tauri-bundler 2.7.5 2.7.6
tauri-runtime 2.9.2 2.9.3
tauri-runtime-wry 2.9.3 2.9.4
tauri-codegen 2.5.2 2.5.3
tauri-macros 2.5.2 2.5.3
tauri-plugin 2.5.2 2.5.3
tauri-build 2.5.3 2.5.4
tauri 2.9.5 2.9.6
@tauri-apps/cli 2.9.6 2.9.7
tauri-cli 2.9.6 2.9.7

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Legend-Master Legend-Master marked this pull request as draft December 30, 2025 04:21
@Legend-Master Legend-Master marked this pull request as ready for review December 30, 2025 04:35
base64 crate is small, but I guess we don't benefit from it much either
Copy link
Contributor

@sftse sftse left a comment

Choose a reason for hiding this comment

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

Is it fine to reuse the nonce here? I'm not familiar with what this does, but "reusing nonce" usually indicates something is seriously wrong.

hashes: Vec<String>,
) {
let mut nonces = Vec::new();
let nonce = OnceCell::new();
Copy link
Contributor

@sftse sftse Dec 30, 2025

Choose a reason for hiding this comment

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

If we generate the nonce outside the callback we can replace OnceCell with a regular local, remove fn replace_with_callback entirely and use str::replace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not entirely sure about this but random number generation is usually slow, so in cases where we don't have inline scripts/styles, we don't pay the price for that

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, the semantics need to reflect it is only initialized if used, so OnceCell is a good fit. We could simplify the generic closure though and replace_with_cache(&OnceCell<String>)

@Legend-Master
Copy link
Contributor Author

Legend-Master commented Dec 30, 2025

Is it fine to reuse the nonce here? I'm not familiar with what this does, but "reusing nonce" usually indicates something is seriously wrong.

I believe this is the desired way to do this, the re-use only happens in a single request. We insert nonce to inline script and style tags in the HTML and add them to the CSP header. If we don't reuse a single nonce here, we will end up with more nonce that could be attacked and waste time generating them

For example, YouTube does this

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

Labels

None yet

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

2 participants