Skip to content

Security: Unescaped User Input in CSS Selector (getIdFromUrl)#858

Merged
dmarcos merged 1 commit into
aframevr:masterfrom
tomaioo:fix/security/unescaped-user-input-in-css-selector-get
Jul 2, 2026
Merged

Security: Unescaped User Input in CSS Selector (getIdFromUrl)#858
dmarcos merged 1 commit into
aframevr:masterfrom
tomaioo:fix/security/unescaped-user-input-in-css-selector-get

Conversation

@tomaioo

@tomaioo tomaioo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Security: Unescaped User Input in CSS Selector (getIdFromUrl)

Problem

Severity: Medium | File: src/lib/assetsUtils.js:L10

In assetsUtils.js, the getIdFromUrl function constructs a CSS selector using user-provided URL input with only single-quote escaping. This is vulnerable to CSS injection attacks. An attacker could craft a URL containing CSS metacharacters to break out of the attribute selector context, potentially leading to DOM-based XSS or information disclosure via CSS selectors.

Solution

Properly escape all CSS special characters in the URL before inserting into the selector, or better yet, avoid constructing selectors from user input. Use document.querySelectorAll and filter by attribute value in JavaScript instead.

Changes

  • src/lib/assetsUtils.js (modified)

In assetsUtils.js, the `getIdFromUrl` function constructs a CSS selector using user-provided URL input with only single-quote escaping. This is vulnerable to CSS injection attacks. An attacker could craft a URL containing CSS metacharacters to break out of the attribute selector context, potentially leading to DOM-based XSS or information disclosure via CSS selectors.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@vincentfretin

Copy link
Copy Markdown
Contributor

I indeed modified in #853 the getIdFromUrl function to avoid the SyntaxError exception with single quote. Your changes also work and prevent all attacks. Good to merge.

@dmarcos
dmarcos merged commit 11a6ee8 into aframevr:master Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants