# RUM | CSP | Nonce or Hash, how to add to JavaScript tag (and CSP header) manually

**URL:** <https://community.dynatrace.com/t/rum-csp-nonce-or-hash-how-to-add-to-javascript-tag-and-csp-header-manually/31596>\
**Category:** Real User Monitoring\
**Tags:** real-user-monitoring-classic, javascript\
**Created:** [May 26, 2021, 9:55am UTC](https://community.dynatrace.com/t/rum-csp-nonce-or-hash-how-to-add-to-javascript-tag-and-csp-header-manually/31596 "2021-05-26T09:55:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fstekelenburg](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/fstekelenburg/32/22029_2.png) [@fstekelenburg](https://community.dynatrace.com/u/fstekelenburg)\
**Post date:** [May 26, 2021, 9:55am UTC](https://community.dynatrace.com/t/rum-csp-nonce-or-hash-how-to-add-to-javascript-tag-and-csp-header-manually/31596/1 "2021-05-26T09:55:08Z")

</div>

Due to the increasing security contraints of our customers we are looking at the impact and requirements to have RUM working with [CSP](https://www.w3.org/TR/CSP3/) applied, as also described in&nbsp;[Modify Content Security Policy for RUM | Dynatrace Documentation](https://www.dynatrace.com/support/help/how-to-use-dynatrace/real-user-monitoring/setup-and-configuration/web-applications/additional-configuration/modify-csp-for-rum/?_ga=2.264612303.1980260620.1621242650-2075144036.1620389524).

Unsafe\_inline is generally still used and set in CSP, however we have to move to make use of Nonce or Hash instead, which, according to the documentation, for Auto Injection yet not supported.

We have a case where, using Manual Injection by using JavaScript tag in a Managed environment, we need to investigate to use Nonce instead. According to&nbsp;[Modify Content Security Policy for RUM | Dynatrace Documentation](https://www.dynatrace.com/support/help/how-to-use-dynatrace/real-user-monitoring/setup-and-configuration/web-applications/additional-configuration/modify-csp-for-rum/?_ga=2.264612303.1980260620.1621242650-2075144036.1620389524),&nbsp;“_Nonce can be added manually to the script tag and the CSP header must be set up accordingly_.” However, there aren’t any further pointers how to accomplish that.  
How do we [add Nonce](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) to the JavaScript tag?

---

<div class="post-metadata">

**Author:** ![fstekelenburg](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/fstekelenburg/32/22029_2.png) [@fstekelenburg](https://community.dynatrace.com/u/fstekelenburg)\
**Post date:** [June 1, 2021, 10:12am UTC](https://community.dynatrace.com/t/rum-csp-nonce-or-hash-how-to-add-to-javascript-tag-and-csp-header-manually/31596/2 "2021-06-01T10:12:32Z")

</div>

Any pointers on how to correctly define the CSP for Agentless RUM manual insertion of Managed are highly appreciated. Taking in account that the URL of the Cluster ActiveGates behind a LB+WAF are within the customer’s own domain.

A “Content-Security-Policy: default-src ‘self’ [trusted.com](http://trusted.com) \*.trusted.com” is thinkable, if the CAGs reside at [cag.trusted.com](http://cag.trusted.com)? What if the use of hash or nonce is demanded?

Nobody encountered the contraint yet, to [prevent the use of unsafe-inline](https://barryvanveen.nl/blog/47-how-to-prevent-the-use-of-unsafe-inline-in-csp)&nbsp;in CSP, if that is applicable at all ?

---

<div class="post-metadata">

**Author:** ![peteh](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@peteh](https://community.dynatrace.com/u/peteh)\
**Post date:** [October 17, 2025, 1:43am UTC](https://community.dynatrace.com/t/rum-csp-nonce-or-hash-how-to-add-to-javascript-tag-and-csp-header-manually/31596/3 "2025-10-17T01:43:19Z")

</div>

This is also a limitation we are facing - that our software developed in house, has requirement from our customers to protect against \<script\> injections, by using a nonce token and strict-dynamic Content-Security-Policy

Automatic injection from OneAgent lacks the nonce token, requiring us to explore other injection avenues for ruxitagent

---

<div class="post-metadata">

**Author:** ![AntonioSousa](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antoniosousa/32/50_2.png) [@AntonioSousa](https://community.dynatrace.com/u/AntonioSousa)\
**Post date:** [October 29, 2025, 8:44pm UTC](https://community.dynatrace.com/t/rum-csp-nonce-or-hash-how-to-add-to-javascript-tag-and-csp-header-manually/31596/4 "2025-10-29T20:44:22Z")

</div>

Yes, we are in 2025, with still not a solution yet.

Not to say that it is not that easy to address, but Dynatrace doesn’t have a response for this.

In the past, I had one case where I had to dump RUM because of this issue. At the moment I have a special case where I’m going to try something: get the hash, insert it into CSP, and configure Dynatrace so RUM version does not get updated…

---

<div class="post-metadata">

**Author:** ![Henk-Jan](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@Henk-Jan](https://community.dynatrace.com/u/Henk-Jan)\
**Post date:** [September 28, 2026, 5:28pm UTC](https://community.dynatrace.com/t/rum-csp-nonce-or-hash-how-to-add-to-javascript-tag-and-csp-header-manually/31596/5 "2026-09-28T17:28:15Z")

</div>

We fixed this by adding the Dynatrace javascript tag to the application developers and they added the tag to their codebase, which adds the so badly needed nonce..&nbsp;  
Source code now looks like this..

![Nonce.jpg](https://global.discourse-cdn.com/dynatrace/optimized/3X/8/b/8bfdc436d62122692eb2fdbb0825d0684508434b_2_690x41.jpeg)

A small drawback is that the domain name and the applicationId need to be hardcoded, but hey! We have RuM!
