Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The CSP nonce remains in the DOM after being read by Angular #55359

Open
Guerric-P opened this issue Apr 16, 2024 · 1 comment
Open

The CSP nonce remains in the DOM after being read by Angular #55359

Guerric-P opened this issue Apr 16, 2024 · 1 comment
Labels
area: security Issues related to built-in security features, such as HTML sanitation cross-cutting: CSP
Milestone

Comments

@Guerric-P
Copy link

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

When I use the ngCspNonce attribute in order to inject a nonce that is used by the framework to meet the browser's criteria for script and style tags, I expect it to disappear from the DOM after the framework has retrieved it.

As an attacker, its very easy for me to detect if an application is built with Angular, and retrieve the nonce in the DOM. It would be much harder for me if the nonce was encapsulated into JavaScript closures with no global reference to it.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 16.2.9
Node: 20.9.0 (Unsupported)
Package Manager: npm 10.1.0
OS: win32 x64

Angular: 16.2.12
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.1602.9
@angular-devkit/build-angular      16.2.9
@angular-devkit/core               16.2.9
@angular-devkit/schematics         16.2.9
@angular/cdk                       16.2.11
@angular/cli                       16.2.9
@angular/material                  16.2.11
@angular/material-moment-adapter   16.2.11
@schematics/angular                16.2.9
rxjs                               7.8.1
typescript                         5.1.6
zone.js                            0.13.3

Anything else?

No response

@JoostK
Copy link
Member

JoostK commented Apr 16, 2024

The idea of the CSP nonce is that it cannot be guessed, not that it's private. How would an attacker perform the detection in an automated way to extract the CSP nonce for any user?

@pkozlowski-opensource pkozlowski-opensource added area: security Issues related to built-in security features, such as HTML sanitation cross-cutting: CSP labels Apr 16, 2024
@ngbot ngbot bot added this to the needsTriage milestone Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: security Issues related to built-in security features, such as HTML sanitation cross-cutting: CSP
Projects
None yet
Development

No branches or pull requests

3 participants