Loading
Sanitize all hub-supplied fields before Project Browser renders them (XSS) and document external service
Problem
Project Browser prints body.summary and body.value with {@html} (Svelte UI). In ProxyManager::translateProjectItem() the hub's summary was copied into body.summary without filtering, while only the description body went through Xss::filterAdmin(). A hub (default hub, custom hub or local JSON file) could inject markup or script into /admin/modules/browse. Found while reviewing the module for the security advisory coverage application (projectapplications#3610097).
Changes
ProxyManager::mergeTranslation()(new): merges the translated fields and sanitises each value: title as plain text, summary withXss::filter(), description withXss::filterAdmin(). Non-string values are ignored. The generated German fallback excerpt is filtered too.- Unit tests: 7 new tests covering script tags, event handlers,
javascript:URLs, plain-string body and non-string input. - README: new "Privacy and external services" and "Third-party assets" sections (which hub, when it is contacted, what is sent, how to switch it off, where translations come from; versions, licenses and sources of flag-icons and highlight.js). Flag badge description corrected.
Checks run locally (Drupal 11.4, PHP 8.5, project_browser 2.1)
phpcs --standard=Drupal,DrupalPractice: no errors or warningsphpstanwith the gitlab_templates configuration, level 0: no errorsphpunit tests/src/Unit: 28 tests, 60 assertions, all pass- Not run: functional/browser tests, Drupal 10, project_browser 2.0.x
AI disclosure
This change was prepared with the help of an AI assistant (Claude by Anthropic): the refactoring, the tests and the README text. Per the Drupal AI policy this is disclosed here.