Skip to content

Commit

Permalink
REPORT-492: Multiple stored XSS via Dimension Name and Descriptions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
isaaclin-artist authored Dec 3, 2021
1 parent a47a714 commit 2f2492f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.openmrs.module.reporting.evaluation.parameter.Parameterizable;
import org.openmrs.module.reporting.evaluation.parameter.ParameterizableUtil;
import org.openmrs.web.WebConstants;
import org.openmrs.web.WebUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.StringUtils;
Expand Down Expand Up @@ -55,6 +56,11 @@ public String saveParameter(ModelMap model, HttpServletRequest request,
@RequestParam(required=false, value="widgetConfiguration") String widgetConfiguration,
@RequestParam(required=false, value="shortcut") String shortcut
) {

currentName = WebUtil.escapeHTML(currentName);
newName = WebUtil.escapeHTML(newName);
label = WebUtil.escapeHTML(label);
widgetConfiguration = WebUtil.escapeHTML(widgetConfiguration);

if (shortcut != null) {
if (shortcut.equals("date")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.openmrs.module.reporting.evaluation.parameter.Parameterizable;
import org.openmrs.module.reporting.evaluation.parameter.ParameterizableUtil;
import org.openmrs.web.WebConstants;
import org.openmrs.web.WebUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down Expand Up @@ -62,8 +63,8 @@ public String saveBaseParameterizable(ModelMap model, HttpServletRequest request
throw new IllegalArgumentException("Cannot instantiate a new " + type, e);
}
}
p.setName(name);
p.setDescription(description);
p.setName(WebUtil.escapeHTML(name));
p.setDescription(WebUtil.escapeHTML(description));
p = ParameterizableUtil.saveParameterizable(p);

if (StringUtils.isNotEmpty(successUrl)) {
Expand Down
6 changes: 4 additions & 2 deletions omod/src/main/webapp/indicators/manageDimensions.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@
<tr>
<td width="20%" nowrap="">
<a href="${editUrl}">
${dimension.name}
<c:out value="${dimension.name}" />
</a>
</td>
<td width="20%">
<span class="small">${dimension.description}</span>
<span class="small">
<c:out value="${dimension.description}" />
</span>
</td>
<td width="10%">
<c:forEach var="opt" items="${dimension.optionKeys}" varStatus="optStatus">
Expand Down
12 changes: 8 additions & 4 deletions omod/src/main/webapp/portlets/parameter.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,19 @@
</tr>
<c:forEach items="${model.obj.parameters}" var="p" varStatus="paramStatus">
<tr>
<td nowrap>${p.name}</td>
<td width="100%">${p.label}</td>
<td nowrap>
<c:out value="${p.name}" />
</td>
<td width="100%">
<c:out value="${p.label}" />
</td>
<td nowrap>
<c:choose>
<c:when test="${p.collectionType != null}">
${p.collectionType.simpleName}&lt;${p.type.simpleName}&gt;
<c:out value="${p.collectionType.simpleName}" /> < <c:out value="${p.type.simpleName}" /> >;
</c:when>
<c:otherwise>
${p.type.simpleName}
<c:out value="${p.type.simpleName}" />
</c:otherwise>
</c:choose>
</td>
Expand Down

0 comments on commit 2f2492f

Please sign in to comment.