1a7b4e1d39c69f33d6d78d1f3ca61b783d2ded40 max Tue Aug 11 08:08:50 2026 -0700 hgLogin: escape reflected values on the older login/account form pages (XSS) The pre-social-login pages printed cart and CGI values into HTML with a plain %s. Since every CGI parameter becomes a cart variable, a crafted URL could reflect script into the page, and the login cookie is written by JavaScript (not HttpOnly), so injected script could read it. Wrap the reflected values in htmlEncode() at the point of output, matching the existing encXxx pattern in the file. Covers displayLoginPage, displayAccHelpPage, changePasswordPage, signupPage, displayMailSuccess and displayMailSuccessPwd. refs #38011 diff --git src/hg/hgLogin/hgLogin.c src/hg/hgLogin/hgLogin.c index c16fd4b7a7f..50993c7fd99 100644 --- src/hg/hgLogin/hgLogin.c +++ src/hg/hgLogin/hgLogin.c @@ -427,52 +427,52 @@ hPrintf( "
" "
" "All usernames on file (if any) for %s "
"have been sent to that address.
"
" If %s is not your registered email address, you will not receive an email."
" If you can't find the message we sent you, please contact %s for help.
An email containing password reset information has been sent to the registered email address of %s.
"
" If you do not receive an email, please contact %s for help.
If you still have questions, you can contact the Genome Browser team at " "genome-www@soe.ucsc.edu. As this is a mirror website not managed by UCSC, please " "specify the address of the mirror in your email.
"); @@ -583,32 +583,33 @@ { char subject[256]; char msg[4096]; char *remoteAddr=getenv("REMOTE_ADDR"); safef(subject, sizeof(subject),"New temporary password for your account at the %s", brwName); safef(msg, sizeof(msg), " Someone (probably you, from IP address %s) requested a new password for the %s (%s). A temporary password for user \"%s\" has been created and was set to \"%s\". If this was your intent, you will need to log in and choose a new password now. Your temporary password will expire in 7 days.\n\n If someone else made this request, or if you have remembered your password, and you no longer wish to change it, you may ignore this message and continue using your old password.\n\n%s\n%s", remoteAddr, brwName, brwAddr, username, password, signature, returnAddr); sendPwdMailOut(email, recovEmail, subject, msg, username); } void displayAccHelpPage(struct sqlConnection *conn) /* draw the account help page */ { -char *email = cartUsualString(cart, "hgLogin_email", ""); -char *username = cartUsualString(cart, "hgLogin_userName", ""); +// these go into value="" attributes further down; escape them (reflected XSS) +char *email = htmlEncode(cartUsualString(cart, "hgLogin_email", "")); +char *username = htmlEncode(cartUsualString(cart, "hgLogin_userName", "")); jsInline( "function toggle(value){\n" "if(value=='showE'){\n" " document.getElementById('usernameBox').style.display='none';\n" " document.getElementById('emailAddrBox').style.display='inline';\n" " } else {\n" " document.getElementById('usernameBox').style.display='inline';\n" " document.getElementById('emailAddrBox').style.display='none';\n" " }\n" "}\n" ); hPrintf("Do not have an account? Go to the sign up page.
" "\n", hgLoginUrl); if (errMsg && sameString(errMsg, "Your account has been activated.")) hPrintf("%s\n", errMsg ? errMsg : ""); else hPrintf("%s\n", errMsg ? errMsg : ""); hPrintf("