Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#61126] protect against injections via data-hover-card-url

Tobias Dillmann2ac6a5f6cb12
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index ff646551e1a..d00670eaf14 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -25,6 +25,7 @@
"@appsignal/javascript": "^1.3.28",
"@appsignal/plugin-breadcrumbs-console": "^1.1.29",
"@appsignal/plugin-breadcrumbs-network": "^1.1.22",
+ "@braintree/sanitize-url": "^7.1.1",
"@datorama/akita": "^8.0.1",
"@floating-ui/dom": "^1.2.1",
"@fullcalendar/angular": "^6.1.10",
@@ -2810,6 +2811,12 @@
"node": ">=6.9.0"
}
},
+ "node_modules/@braintree/sanitize-url": {
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-7.1.1.tgz",
+ "integrity": "sha512-i1L7noDNxtFyL5DmZafWy1wRVhGehQmzZaz1HiN5e7iylJMSZR7ekOV7NsIqa5qBldlLrsKv4HbgFUVlQrz8Mw==",
+ "license": "MIT"
+ },
"node_modules/@cnakazawa/watch": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@cnakazawa/watch/-/watch-1.0.4.tgz",
@@ -24149,6 +24156,11 @@
"to-fast-properties": "^2.0.0"
}
},
+ "@braintree/sanitize-url": {
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-7.1.1.tgz",
+ "integrity": "sha512-i1L7noDNxtFyL5DmZafWy1wRVhGehQmzZaz1HiN5e7iylJMSZR7ekOV7NsIqa5qBldlLrsKv4HbgFUVlQrz8Mw=="
+ },
"@cnakazawa/watch": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@cnakazawa/watch/-/watch-1.0.4.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 51180d3dbc1..78e8d63c2f0 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -77,6 +77,7 @@
"@appsignal/javascript": "^1.3.28",
"@appsignal/plugin-breadcrumbs-console": "^1.1.29",
"@appsignal/plugin-breadcrumbs-network": "^1.1.22",
+ "@braintree/sanitize-url": "^7.1.1",
"@datorama/akita": "^8.0.1",
"@floating-ui/dom": "^1.2.1",
"@fullcalendar/angular": "^6.1.10",
diff --git a/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts b/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts
index e5f9d67e909..b8f34505b8f 100644
--- a/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts
+++ b/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts
@@ -28,6 +28,7 @@
import { Injectable, Injector, NgZone } from '@angular/core';
import { computePosition, flip, limitShift, shift } from '@floating-ui/dom';
+import { sanitizeUrl } from '@braintree/sanitize-url';
@Injectable({ providedIn: 'root' })
export class HoverCardTriggerService {
@@ -185,8 +186,19 @@ export class HoverCardTriggerService {
return newOverlay;
}
+ /*
+ * Will fetch the URL from the element's data attribute and sanitize it.
+ * When there is no URL or if the URL is invalid, will return an empty string.
+ */
private parseHoverCardUrl(el:HTMLElement) {
- return el.getAttribute('data-hover-card-url');
+ let url = el.getAttribute('data-hover-card-url');
+ if (!url) { return ''; }
+
+ url = sanitizeUrl(url);
+
+ // `sanitizeUrl` will return 'about:blank' for invalid URLs. We will return an empty-string instead since
+ // there's no reason to show an empty hover card.
+ return url === 'about:blank' ? '' : url;
}
private async reposition(element:HTMLElement, target:HTMLElement) {