From 905e0c8d62c67e964b9b47b5727472de6b55f477 Mon Sep 17 00:00:00 2001 From: ost-ptk Date: Tue, 28 Jul 2026 12:10:57 +0300 Subject: [PATCH] build: emit the CSP nonce only for Chrome production builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The nonce was generated per build and injected via DefinePlugin for every browser target, although only the Chrome-production CSP arm pins style-src to it. Both readers are browser-agnostic, so every Firefox and Safari bundle carried a fresh random base64 literal that nothing used — and AMO source review rebuilds the submitted source and compares the artifact byte for byte, which a per-build random literal makes impossible. The DefinePlugin key stays defined for all targets on purpose: nothing else defines `process` in these bundles, so dropping the key would leave process.env.CSP_NONCE unreplaced and throw ReferenceError at runtime. Only the value becomes null off the Chrome-production path, and both readers now skip the attribute entirely rather than stamping nonce="null". Deriving the nonce from the commit hash was considered and rejected: a publicly computable nonce adds nothing over a static one, while gating removes the value from the non-Chrome bundles altogether. Verified: two consecutive build:firefox runs are byte-identical after this change and differed before it; build/chrome still carries a real nonce in its manifest CSP. --- src/libs/ui/style-sheet-manager.tsx | 2 +- src/set-webpack-nonce.ts | 17 +++++++++++------ webpack.config.js | 14 +++++++++----- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/libs/ui/style-sheet-manager.tsx b/src/libs/ui/style-sheet-manager.tsx index fdb94d4f6..2899aaa2d 100644 --- a/src/libs/ui/style-sheet-manager.tsx +++ b/src/libs/ui/style-sheet-manager.tsx @@ -11,7 +11,7 @@ export const CspStyleSheetManager = ({ children }: PropsWithChildren) => ( // styled-components stamps this nonce on its injected