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/hgLinkIn/hgLinkIn.c src/hg/hgLinkIn/hgLinkIn.c index 9d58e3c98e1..e45b8ef544a 100644 --- src/hg/hgLinkIn/hgLinkIn.c +++ src/hg/hgLinkIn/hgLinkIn.c @@ -23,33 +23,33 @@ /* Global Variables */ struct cart *cart; /* CGI and other variables */ struct hash *oldVars = NULL; void displayLinkInResults(char *linkInId, char *linkInResource, struct linkInResult *results) /* Take the list of results and display them. Here, that generally means redirecting to * hgTracks with a db and position. */ { /* If only one result, jump to it. Otherwise, for now, jump to the first */ int hitCount = slCount(results); if (hitCount == 0) { - printf ("Error: No results found for ID %s", linkInId); + printf ("Error: No results found for ID %s", htmlEncode(linkInId)); // user input, escape (XSS) if (linkInResource != NULL) - printf (" in database %s\n", linkInResource); + printf (" in database %s\n", htmlEncode(linkInResource)); } else if (hitCount == 1) { char url[2048]; safef(url, sizeof(url), "../cgi-bin/hgTracks?db=%s&position=%s&%s=pack", results->db, results->position, results->trackToView); char redirect[4096]; safef(redirect, sizeof(redirect), "window.location='%s';", url); jsInline(redirect); printf("Redirecting to <a href='%s'>%s</a>.", url, url); } else { // Multiple hits char url[2048];