Skip to content
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

Fixing XSS bug in manageAppointments.gsp #32

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kfb19
Copy link
Contributor

@kfb19 kfb19 commented Jul 23, 2021

How to find the XSS bug:

  1. Log in to openmrs with admin account
  2. Register a patient, if one doesn't already exist
  3. Click "Appointment Scheduling"
  4. Click "Manage Appointments"
  5. Search for a patient
  6. Click on the patient
  7. On the resulting page, modify the breadcrumbOverride url parameter to </script><script>alert(1)</script>
  8. Click enter -- a javascript alert should show

My fix:
I located the line to fix in manageAppointments.gsp using inspect element, then used the ui.encodeJavaScript() function on the correct breadcrumbOverride parameter which escaped special characters to stop the XSS attack.

@isears

@@ -338,7 +338,7 @@
</repository>
<repository>
<id>rubygems-releases</id>
<url>http://rubygems-proxy.torquebox.org/releases</url>
<url>https://rubygems-proxy.torquebox.org/releases/url</url>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change was part of your other pull request. Try git pull --rebase master on your PR branch and then force push with git push -f so that we can keep this PR focused on the XSS fix only.

@@ -7,7 +7,7 @@
<script type="text/javascript">
<% if (breadcrumbOverride) { %>
var breadcrumbs = _.flatten([
${ breadcrumbOverride },
${ ui.encodeJavaScript(breadcrumbOverride) },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I test this locally, the manageAppointment page loses most of the functionality it had before the patch. Are you getting similar behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants