Shibboleth の SingleSingOut(SSO) を使用して認証を行います。Shibboleth は、私たちのプロジェクトに統合されたオープンソース プロジェクトです。ユーザーが認証されていない場合、Shibboleth は login.jsp ページにリダイレクトします。したがって、フォーム actionUrl は、認証を実行するために Shibboleth IDP (ID プロバイダー) によって送信される必要があります。以下は、Shibboleth が提供したサンプル コードです。
<% if(request.getAttribute("actionUrl") != null){ %>
<form id="login" action="<%=request.getAttribute("actionUrl")%>" method="post">
<% }else{ %>
<form id="login" action="j_security_check" method="post">
<% } %>
<% if ("true".equals(request.getAttribute("loginFailed"))) { %>
<section>
<p class="form-element form-error">Login has failed. Double-check your username and password.</p>
</section>
<% } %>
<legend>
Log in to <idpui:serviceName/>
</legend>
<section>
<label for="username">Username</label>
<input class="form-element form-field" name="j_username" type="text" value="">
</section>
<section>
<label for="password">Password</label>
<input class="form-element form-field" name="j_password" type="password" value="">
</section>
<section>
<button class="form-element form-button" type="submit">Login</button>
</section>
</form>
ここで、OWASP ZAP ツールを使用してセキュリティ攻撃を確認しました。以下のコードで高リスクを発生させました
<form id="login" action="<%=request.getAttribute("actionUrl")%>" method="post">
XSS (クロスサイト スクリプティング) 攻撃の可能性があるとのことで、上記のコードをエンコードするように求められました。
フォーム アクション URL の XSS (クロス サイト スクリプティング) を防ぐにはどうすればよいですか。信頼できないデータであるため、URL をエンコードする方法はありません。いくつかの調査の結果、ESAPI.encoder().encodeForURL('url'); を使用する方が良いことがわかりました。方法。私の疑問は、フォームアクション URL に ESAPI.encoder().encodeForURL('url') を使用する正しい方法ですか?
Cross_Site_Scripting Prevention Cheat sheetから
実際のフォーム アクション URL:
<form name="loginForm" id="login" method="POST" action="<%=request.getParameter("actionUrl")%>">
エンコードされたフォーム アクション URL:
<form name="loginForm" id="login" method="POST" action="<%=ESAPI.encoder().encodeForURL(request.getParameter("actionUrl"))%>">
任意の提案をいただければ幸いです。