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

Patch XSS in reporting #141

Merged
merged 1 commit into from Apr 19, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Patch XSS in reporting

  • Loading branch information...
isears committed Apr 18, 2017
commit 0023a659288538d2763835847d3414ecb18b931a
@@ -42,7 +42,7 @@
<div style="margin:0; padding:0; width:100%;">
<div class="metadataField">
<label class="desc" for="name"><spring:message code="reporting.name" /></label>
<input type="text" id="name" tabindex="1" name="name" value="${model.obj.name}" size="50"/>
<input type="text" id="name" tabindex="1" name="name" value="<c:out value='${model.obj.name}' />" size="50"/>
</div>
<c:if test="${!empty model.obj && model.showType != 'false'}">
<div class="metadataField">
@@ -52,7 +52,7 @@
</c:if>
<div class="metadataField">
<label class="desc" for="description"><spring:message code="reporting.description" /></label>
<textarea id="description" cols="80" rows="10" tabindex="2" name="description">${model.obj.description}</textarea>
<textarea id="description" cols="80" rows="10" tabindex="2" name="description"><c:out value='${model.obj.description}' /></textarea>
</div>
</div>
<hr style="color:blue;"/>
@@ -73,7 +73,7 @@
<rpt:displayLabel type="${reportDefinition['class'].name}"/>
</td>
<td width="5%" nowrap>
${reportDefinition.creator}
<c:out value="${reportDefinition.creator}" />
</td>
<td width="5%" nowrap>
<rpt:timespan then="${reportDefinition.dateCreated}"/>
@@ -82,7 +82,7 @@
&nbsp;
<a href="${editUrl}"><img src="<c:url value='/images/edit.gif'/>" border="0"/></a>
&nbsp;
<a href="javascript:confirmDelete('${reportDefinition.name}','${reportDefinition.uuid}');"><img src="<c:url value='/images/trash.gif'/>" border="0"/></a>
<a href="javascript:confirmDelete('<c:out value="${openmrs:getSafeJsString(reportDefinition.name)}" />','${reportDefinition.uuid}');"><img src="<c:url value='/images/trash.gif'/>" border="0"/></a>

This comment has been minimized.

Copy link
@dkayiwa

dkayiwa Apr 19, 2017

Member

Since we are using c:out, do we then need getSafeJsString?

This comment has been minimized.

Copy link
@isears

isears Apr 19, 2017

Author Member

Yes. We have inline javascript embedded into html here, so we have to make sure the input is safe for use in both languages. The problem with c:out alone is that it converts all single/double quote characters to html entities, which break the in-line javascript.

This comment has been minimized.

Copy link
@dkayiwa

dkayiwa Apr 19, 2017

Member

Oh i see! Thanks for the detailed explanation. 😊

&nbsp;
<a href="${pageContext.request.contextPath}/module/reporting/run/runReport.form?reportId=${reportDefinition.uuid}">
<img src='<c:url value="/images/play.gif"/>' align="absmiddle" border="0"/>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.