Skip to content

Conversation

ArneTR
Copy link
Member

@ArneTR ArneTR commented Sep 6, 2025

This PR removes the html escaping in the API and adds escaping to the frontend.

The initial design decision at the time was that we wanted a "clean DB", meaning that we clean everything before it gets in, as we control insert locations easier than read locations.

However over time and many developrs this became quite garbled and inconsistent having multiple escapings "just to be sure".

This PR removes all escaping on the server side and only adds escaping when we output to HTML (aka the Dashboard).

This means:

  • DB can contain XSS
  • API can return XSS
  • Anybody displaying stuff in HTML / JS frontend must escape

This solution is much cleaner and caters more for the diverse use cases of the GMT Suite as it is now:

  • Data being used in may tools that interface with API, but have not actual HTML / JS output
  • Data often looked at in CLI and then looks garbled

TODO

@davidkopp This PR is so far largely untested.

  • Please review the PR manually and then also test it.
  • Please create test cases where you inject XSS through the frontend and then validate through a Playwright test that the XSS is not triggered. Happy to talk about how extensive we want to be here once the first test prototype is set up

davidkopp and others added 2 commits September 12, 2025 22:10
* Fix XSS vulnerabilities and enhance security testing across frontend

- Add comprehensive XSS protection test covering runs, watchlist, and compare pages
- Fix XSS vulnerability in compare.js by escaping comparison_identifiers
- Improve replaceRepoIcon function with proper error handling and escaping

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix some js linting errors

* Fix display of repo name + remove unnecessary escaping

* Add stats page to xss test + fix compare test

* Add usage scenario to XSS test

* Add logs to XSS test

* Add flow name to XSS test

* Add xss test case for notes

* Add escaping of notes - not needed, but to be consistent

* Add xss test and fixes for eco-ci pages

* Refactor setup of db data for frontend tests

* Use consistent xss detection approach

* Cleanup xss tests

* Add usage scenario variables xss test and fixes

* Fix URL encoding in frontend JavaScript

Replace escapeString with encodeURIComponent for URL query parameters to ensure proper URL encoding instead of HTML entity encoding.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix also commented out lines

* Fix XSS vulnerabilities in URL contexts and improve URL encoding

- Fix XSS vulnerabilities in URI href attributes by validating http/https protocols only
- Add createExternalIconLink helper for consistent and safe external link creation
- Fix malformed URL in timeline badge src attribute
- Add encodeURIComponent to buildQueryParams function for proper URL parameter encoding
- Remove unnecessary encoding from commit hashes (inherently URL-safe)
- Improve URI display logic with better variable naming and security comments

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove tests for HTML escaping in backend - is now done in frontend [skip ci]

* Add comment about headless config

* Add timeline page to xss test + improve URI encoding

* Cleanup reset_db()

* Update comment about removal of page error handler

---------

Co-authored-by: Claude <noreply@anthropic.com>
@ArneTR ArneTR merged commit 15bfdec into main Sep 13, 2025
@ArneTR ArneTR deleted the remove-html-escape branch September 13, 2025 05:16
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.

2 participants