Skip to content

Commit 3a3d6d8

Browse files
authored
Merge pull request wso2#8534 from savindi7/improve-input-validations
Improve input validations
2 parents e2ecfb6 + dc793a7 commit 3a3d6d8

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

.changeset/red-moose-jam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@wso2is/identity-apps-core": patch
3+
---
4+
5+
Improve input validations.

identity-apps-core/apps/authentication-portal/src/main/webapp/duoError.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
<%
103103
if ("true".equals(authenticationFailed)) {
104104
%>
105-
<div class="ui negative message" id="failed-msg"><%=errorMessage%></div>
105+
<div class="ui negative message" id="failed-msg"><%= Encode.forHtml(errorMessage) %></div>
106106
<% } %>
107107
</div>
108108
</layout:component>

identity-apps-core/apps/recovery-portal/src/main/webapp/password-recovery.jsp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@
7878
if (SMSOTP.equalsIgnoreCase(request.getParameter("selectedOption"))) {
7979
selectedOption = SMSOTP;
8080
}
81-
String sp = Encode.forJava(request.getParameter("sp"));
82-
String spId = Encode.forJava(request.getParameter("spId"));
81+
String sp = request.getParameter("sp");
82+
String spId = request.getParameter("spId");
83+
84+
String rawQueryString = request.getQueryString();
85+
String urlQuery = Encode.forHtmlAttribute(rawQueryString == null ? "" : rawQueryString);
8386
8487
if (StringUtils.isBlank(tenantDomain)) {
8588
tenantDomain = IdentityManagementEndpointConstants.SUPER_TENANT;
@@ -101,7 +104,7 @@
101104
try {
102105
ApplicationDataRetrievalClient applicationDataRetrievalClient = new ApplicationDataRetrievalClient();
103106
applicationAccessURLWithoutEncoding = applicationDataRetrievalClient.getApplicationAccessURL(tenantDomain,
104-
sp);
107+
Encode.forJava(sp));
105108
applicationAccessURLWithoutEncoding = IdentityManagementEndpointUtil.replaceUserTenantHintPlaceholder(
106109
applicationAccessURLWithoutEncoding, userTenantDomain);
107110
} catch (ApplicationDataRetrievalClientException e) {
@@ -406,9 +409,13 @@
406409

407410
<input type="hidden" name="recoveryStage" value="INITIATE"/>
408411
<input type="hidden" name="channel" value=""/>
409-
<input type="hidden" name="sp" value="<%=sp %>"/>
410-
<input type="hidden" name="spId" value="<%=spId %>"/>
411-
<input type="hidden" name="urlQuery" value="<%=request.getQueryString() %>"/>
412+
<% if (StringUtils.isNotBlank(sp)) { %>
413+
<input type="hidden" name="sp" value="<%=Encode.forHtmlAttribute(sp) %>"/>
414+
<% } %>
415+
<% if (StringUtils.isNotBlank(spId)) { %>
416+
<input type="hidden" name="spId" value="<%=Encode.forHtmlAttribute(spId) %>"/>
417+
<% } %>
418+
<input type="hidden" name="urlQuery" value="<%=urlQuery %>"/>
412419
<input type="hidden" name="isMultiRecoveryOptionsAvailable"
413420
value="<%=multipleRecoveryOptionsAvailable %>"/>
414421
<input type="hidden" name="isEmailOtpBasedPasswordRecoveryEnabledByTenant"

identity-apps-core/apps/recovery-portal/src/main/webapp/password-reset.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
<%
155155
if (StringUtils.isNotBlank(spId)) {
156156
%>
157-
<input id="spId" name="spId" type="hidden" value="<%=spId%>"/>
157+
<input id="spId" name="spId" type="hidden" value="<%=Encode.forHtmlAttribute(spId)%>"/>
158158
<%
159159
}
160160
%>

identity-apps-core/apps/recovery-portal/src/main/webapp/self-registration-complete.jsp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@
309309
String url = "";
310310
if (StringUtils.isNotBlank(confirm)) { %>
311311
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "your.account.with.username")%>
312-
<b><%=resendUsername%></b>
312+
<b><%=Encode.forHtml(resendUsername)%></b>
313313
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "has.been.verified.successfully")%>
314314
<%
315315
if (!StringUtils.isBlank(sp) && sp.equals("My Account")) {
@@ -338,7 +338,11 @@
338338
%>
339339
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "check.your.inbox.at")%>
340340
<b><span id="maskedEmail"></span></b> <%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "for.instructions.to.activate.your.account")%>
341-
<script>maskEmail('<%= emailValue %>');</script>
341+
<script>
342+
<% if (StringUtils.isNotBlank(emailValue)) { %>
343+
maskEmail('<%= Encode.forJavaScript(emailValue) %>');
344+
<% } %>
345+
</script>
342346
</br></br>
343347
<%
344348
if (showBackButton && StringUtils.isNotBlank(applicationAccessURLWithoutEncoding)) {

0 commit comments

Comments
 (0)