CSP: unsafe-inline needed for e.onclick
- Dominant language
- No language data
- Stars
- 7
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
### Expected Behaviour
No csp errors without adding `unsafe-inline` in CSP policy.
What is the suggestion from the dev team to get around this without adding `unsafe-inline`? We cannot add a static nonce via the extension configuration.
### Actual Behaviour
[Report Only] Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self' assets.adobedtm.com". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present.
Error root: https://assets.adobedtm.com/extensions/EP8757b503532a44a68eee17773f6f10a0/AppMeasurement.min.js
Error is coming from `a = e.onclick` in the block below:
```
t.N = function(e) {
var n, a, i = t.C(e), r = "", o = 0;
return i && (n = e.protocol,
a = e.onclick,
!e.href || "A" != i && "AREA" != i || a && n && !(0 > n.toLowerCase().indexOf("javascript")) ? a ? (r = t.replace(t.replace(t.replace(t.replace("" + a, "\r", ""), "\n", ""), "\t", ""), " ", ""),
o = 2) : "INPUT" == i || "SUBMIT" == i ? (e.value ? r = e.value : e.innerText ? r = e.innerText : e.textContent && (r = e.textContent),
o = 3) : "IMAGE" == i && e.src && (r = e.src) : r = t.Ya(e),
r) ? {
id: r.substring(0, 100),
type: o
} : 0
}
```
### Reproduce Scenario (including but not limited to)
#### Steps to Reproduce
#### Platform and Version
Version: 2.27.0
#### Sample Code that illustrates the problem
#### Logs taken while reproducing problem
Contributor guide
Research direction
Start by reviewing the reported AppMeasurement.min.js entry point, especially the t.N function and its e.onclick access, against version 2.27.0. Reproduce the CSP report with the supplied directive and determine whether this repository controls that code. Done requires a documented, verifiable way to avoid the inline-handler violation without adding unsafe-inline.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- security
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100