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

Validate and Sanitize backToUrl in self-registration-username-request.jsp #7250

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.AuthenticationEndpointUtil" %>
<%@ page import="static org.wso2.carbon.identity.application.authentication.endpoint.util.Constants.STATUS" %>
<%@ page import="static org.wso2.carbon.identity.application.authentication.endpoint.util.Constants.STATUS_MSG" %>
<%@ page import="org.wso2.carbon.identity.recovery.IdentityRecoveryConstants" %>
<%@ page import="org.wso2.carbon.identity.recovery.util.Utils" %>
<%@ page import="org.wso2.carbon.identity.base.IdentityRuntimeException" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.Constants" %>
<%@ page import="org.wso2.carbon.identity.captcha.util.CaptchaUtil" %>
<%@ page import="org.wso2.carbon.identity.core.URLBuilderException" %>
Expand Down Expand Up @@ -737,13 +740,28 @@

<div class="ui divider hidden"></div>
<%
try {
if (StringUtils.isNotBlank(backToUrl) && !Utils.validateCallbackURL(backToUrl, tenantDomain,
IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_CALLBACK_REGEX)) {
request.setAttribute("error", true);
request.setAttribute("errorMsg", IdentityManagementEndpointUtil.i18n(recoveryResourceBundle,
"Callback.url.format.invalid"));
request.getRequestDispatcher("error.jsp").forward(request, response);
return;
}
} catch (IdentityRuntimeException e) {
request.setAttribute("error", true);
request.setAttribute("errorMsg", e.getMessage());
request.getRequestDispatcher("error.jsp").forward(request, response);
return;
}
if (!StringUtils.equalsIgnoreCase(backToUrl,"null") && !StringUtils.isBlank(backToUrl)) {
%>
<div class="buttons mt-2">
<div class="field external-link-container text-small">
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle,
"Already.have.an.account")%>
<a href="<%=backToUrl%>">
<a href="<%= StringEscapeUtils.escapeHtml4(backToUrl) %>">
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "Sign.in")%>
</a>
</div>
Expand Down
Loading