Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 299773

Harden drupalSettings selector against XSS

$
0
0

Follow-up to #2510104: Convert drupalSettings from JavaScript to JSON, to allow for CSP in the future

Problem/Motivation

The current selector for the drupalSettings is:

var settingsElement = document.querySelector('script[type="application/json"][data-drupal-selector="drupal-settings-json"]');

This means that when someone manages to place some drupalSettings on the page by exploiting XSS they could manipulate settings, which could potentially lead to a real XSS exploit.

Proposed resolution

Use a selector as true child of head or body instead:

var settingsElement = document.querySelector('head > script[type="application/json"][data-drupal-selector="drupal-settings-json"], body > script[type="application/json"][data-drupal-selector="drupal-settings-json"]');

Remaining tasks

- Create patch
- Commit

User interface changes

- None

API changes

- None


Viewing all articles
Browse latest Browse all 299773

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>