Skip to content

Commit dabcd04

Browse files
author
Sam Martin
committed
ensuring we dont execute code in attributes
1 parent 626a27e commit dabcd04

File tree

10 files changed

+33
-16
lines changed

10 files changed

+33
-16
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "0.8.46",
5+
"version": "0.8.47",
66
"npmClient": "yarn"
77
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "clarity",
33
"private": true,
4-
"version": "0.8.46",
4+
"version": "0.8.47",
55
"repository": "https://github.com/microsoft/clarity.git",
66
"author": "Sarvesh Nagpal <[email protected]>",
77
"license": "MIT",

packages/clarity-decode/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "clarity-decode",
3-
"version": "0.8.46",
3+
"version": "0.8.47",
44
"description": "An analytics library that uses web page interactions to generate aggregated insights",
55
"author": "Microsoft Corp.",
66
"license": "MIT",
@@ -26,7 +26,7 @@
2626
"url": "https://github.com/Microsoft/clarity/issues"
2727
},
2828
"dependencies": {
29-
"clarity-js": "^0.8.46"
29+
"clarity-js": "^0.8.47"
3030
},
3131
"devDependencies": {
3232
"@rollup/plugin-commonjs": "^24.0.0",

packages/clarity-devtools/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "clarity-devtools",
3-
"version": "0.8.46",
3+
"version": "0.8.47",
44
"private": true,
55
"description": "Adds Clarity debugging support to browser devtools",
66
"author": "Microsoft Corp.",
@@ -24,9 +24,9 @@
2424
"url": "https://github.com/Microsoft/clarity/issues"
2525
},
2626
"dependencies": {
27-
"clarity-decode": "^0.8.46",
28-
"clarity-js": "^0.8.46",
29-
"clarity-visualize": "^0.8.46"
27+
"clarity-decode": "^0.8.47",
28+
"clarity-js": "^0.8.47",
29+
"clarity-visualize": "^0.8.47"
3030
},
3131
"devDependencies": {
3232
"@rollup/plugin-node-resolve": "^15.0.0",

packages/clarity-devtools/static/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"manifest_version": 2,
33
"name": "Microsoft Clarity Developer Tools",
44
"description": "Clarity helps you understand how users are interacting with your website.",
5-
"version": "0.8.46",
6-
"version_name": "0.8.46",
5+
"version": "0.8.47",
6+
"version_name": "0.8.47",
77
"minimum_chrome_version": "50",
88
"devtools_page": "devtools.html",
99
"icons": {

packages/clarity-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "clarity-js",
3-
"version": "0.8.46",
3+
"version": "0.8.47",
44
"description": "An analytics library that uses web page interactions to generate aggregated insights",
55
"author": "Microsoft Corp.",
66
"license": "MIT",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
let version = "0.8.46";
1+
let version = "0.8.47";
22
export default version;

packages/clarity-visualize/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "clarity-visualize",
3-
"version": "0.8.46",
3+
"version": "0.8.47",
44
"description": "An analytics library that uses web page interactions to generate aggregated insights",
55
"author": "Microsoft Corp.",
66
"license": "MIT",
@@ -27,7 +27,7 @@
2727
"url": "https://github.com/Microsoft/clarity/issues"
2828
},
2929
"dependencies": {
30-
"clarity-decode": "^0.8.46"
30+
"clarity-decode": "^0.8.47"
3131
},
3232
"devDependencies": {
3333
"@rollup/plugin-commonjs": "^24.0.0",

packages/clarity-visualize/src/layout.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ export class LayoutHelper {
641641
node.setAttribute(Constant.Hide, size);
642642
}
643643
} else {
644-
node.setAttribute(attribute, v);
644+
node.setAttribute(attribute, this.isSuspiciousAttribute(attribute, v) ? Constant.Empty : v);
645645
}
646646
} catch (ex) {
647647
console.warn("Node: " + node + " | " + JSON.stringify(attributes));
@@ -670,6 +670,23 @@ export class LayoutHelper {
670670
}
671671
}
672672

673+
private isSuspiciousAttribute(name: string, value: string): boolean {
674+
// Block event handlers entirely
675+
if (name.startsWith('on')) {
676+
return true;
677+
}
678+
679+
// Check for JavaScript protocols and dangerous patterns
680+
const dangerous = [
681+
/^\s*javascript:/i,
682+
/^\s*data:text\/html/i,
683+
/^\s*vbscript:/i
684+
];
685+
686+
return dangerous.some(pattern => pattern.test(value));
687+
}
688+
689+
673690
private getMobileCustomStyle = (): string => {
674691
if(this.isMobile){
675692
return `*{scrollbar-width: none; scrollbar-gutter: unset;};`

packages/clarity-visualize/types/visualize.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export const enum Constant {
199199
NewPassword = "new-password",
200200
StyleSheet = "stylesheet",
201201
OriginalBackgroundColor = "data-clarity-background-color",
202-
OriginalOpacity = "data-clarity-opacity"
202+
OriginalOpacity = "data-clarity-opacity",
203203
}
204204

205205
export const enum Setting {

0 commit comments

Comments
 (0)