a1d7c07c50f1d895337de121680ea672b261c058 max Mon Aug 17 02:26:36 2026 -0700 escape reflected/echoed user input across several CGIs (XSS), refs #38057 Route user-, DB- and hub-derived values through htmlEncode (HTML/attribute text), cgiEncode (values composed into URLs), jsonStringEscape (values placed in a JS string literal inside an inline script) or, for hgMirror, the existing mustBeClean sanitizer. Covers hgHubConnect, hgUserSuggestion, hgLiftOver, hgBlat, hgc pubs, hgVisiGene, hgSession, hgTrackUi, hgGenome, phyloPng, hgFileSearch, hgLinkIn, hgPal, hui, hgPhyloPlace, hgMirror, hgCustom and hgSearch. diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index b2a8085c088..65d37febc54 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -472,31 +472,31 @@ } void hgHubConnectDeveloperMode() /* Put up the controls for the "Hub Development" Tab, which includes a button to run the * hubCheck utility on a hub and load a hub with the udcTimeout and measureTiming * variables turned on */ { // put out the top of our page char *hubUrl = cartOptionalString(cart, "validateHubUrl"); // the outer div for all the elements in the tab puts("
"); char *hubUrlVal = ""; if (hubUrl != NULL) - hubUrlVal = catThreeStrings(" value='", hubUrl, "'"); + hubUrlVal = catThreeStrings(" value='", htmlEncode(hubUrl), "'"); puts("
"); puts("

Create your own hub

"); puts("For information on making track hubs, see the following pages: \n " "\n" "
You may also contact us if you have any " "issues or questions on hub development."); puts("
"); // .tabSection @@ -577,40 +577,40 @@ void printSearchAndFilterBoxes(int searchEnabled, char *hubSearchTerms, char *dbFilter) /* Create the text boxes for search and database filtering along with the required * javscript */ { printf("
\n", "../cgi-bin/hgHubConnect"); if (searchEnabled) { cgiMakeHiddenVar(hgHubDoSearch, "on"); cgiMakeHiddenVar(hgHubDbFilter, ""); cartSaveSession(cart); printf("The list below can be filtered on words in the hub description pages or by assemblies.
" "Search terms: " " \n", - hubSearchTerms!=NULL?hubSearchTerms:""); + hubSearchTerms!=NULL?htmlEncode(hubSearchTerms):""); printf("\n"); } printf("Assembly: " " \n" "\n", - hgHubDbFilter, dbFilter!=NULL?dbFilter:""); + hgHubDbFilter, dbFilter!=NULL?htmlEncode(dbFilter):""); puts("
"); } void printSearchTerms(char *hubSearchTerms) /* Write out a reminder about the current search terms and a note about * how to navigate detailed search results */ { printf("Displayed list restricted by above search terms \n"); puts("\n"); jsOnEventById("click", "hubDeleteSearchButton", "document.searchHubForm.elements['hubSearchTerms'].value='';" "document.searchHubForm.elements['hubDbFilter'].value='';" @@ -1627,31 +1627,31 @@ puts("
"); jsOnEventByIdF("click", "windowX", "closeIframe()"); if (isEmpty(hubUrl)) printf("Please wait, loading and checking hub. This usually takes a minute or two but can take up to 20 minutes for big hubs."); else { puts("

"); puts("  

"); jsOnEventByIdF("click", "reloadButton", "reloadIframe()"); jsOnEventByIdF("click", "closeButton", "closeIframe()"); jsInline("document.onkeydown = function(evt) { if (evt.keyCode===27) { closeIframe() } };"); int retVal = doValidateNewHub(hubUrl); if (retVal == 0) - printf("
Finished checking %s
", hubUrl); + printf("
Finished checking %s
", htmlEncode(hubUrl)); puts("
"); puts("

More information about hub settings can be found on the " "Hub Track Database Definition page."); puts("

Our command line tool hubCheck " "can be used to obtain the same output from a Unix command line.

"); puts("

To download the hubCheck tool for Linux, run these commands" " (replace 'linux' with 'macOSX' on a x86 Mac):
" "

wget http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/hubCheck\n"
                 "chmod a+x hubCheck\n"
                 "hubCheck https://genome.ucsc.edu/goldenPath/help/examples/hubDirectory/hub.txt

"); puts("

You can use the 'Esc' key to close this window.

"); } puts("
"); // margin 10px puts("
"); // ui-dialog-titlebar puts(""); // ui-dialog