-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RA-1875: EMPT97 Fixed XSS Vulnerability in returnUrl parameter of HTML Form #46
base: master
Are you sure you want to change the base?
Conversation
@@ -71,7 +72,8 @@ public void get(UiSessionContext sessionContext, @RequestParam("patientId") Pati | |||
throw new IllegalArgumentException("Couldn't find a form"); | |||
} | |||
|
|||
returnUrl = HtmlFormUtil.determineReturnUrl(returnUrl, returnProvider, returnPage, currentPatient, visit, ui); | |||
returnUrl = HtmlFormUtil.determineReturnUrl(StringEscapeUtils.escapeHtml(returnUrl), returnProvider, returnPage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! cc @isears
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@The-Lady this will break page links when returnUrl
contains legitimate HTML characters. Is it possible to patch in the .gsp
? Specifically at enterHtmlFormWithSimpleUi.gsp
@isears I tried encoding returnUrl at lines 16, 65, 66 and 78 of the enterHtmlFormWithSimpleUi.gsp, but none of them worked. |
If escapeJs is working to prevent the XSS, go for it. EscapeHtml will only work if the variable is injected into HTML sections of the page when the .gsp is compiled. If the variable is injected into a javascript section, we need to use escapeJs.
You are correct, no part of the returnUrl should be executed as javascript |
@isears Thank you for clearing up. I have made the desired changes. |
@The-Lady when I test this locally it looks like the "Exit Form" button breaks due to the escapeJs filtering applied to the returnUrl. It looks like this issue is more complicated than I initially realized. I think any html- or js- encoding we do on the returnUrl parameter will break the "Exit Form" button, but of course, if we don't apply any filtering to the returnUrl parameter, it remains vulnerable to injection and reflected XSS. Ultimately I think we're going to have to fundamentally change the way the "Exit Form" button works to resolve this. Remind me to bring this issue up at our next security sync meeting I think it merits discussion. |
Description of What I Changed
I added encoding to returnUrl parameter of HTML form.
Issue I Worked On
A script could be injected in the returnUrl parameter of Html forms. I encoded the parameter to prevent any XSS attacks.
Steps to reproduce the vulnerability:
></script><script>alert(123)</script><script>
and press enter.Output: A dialog box pops up with '123' written on it.
Link to ticket
RA-1875
@isears