Expand my Community achievements bar.

XSS protecion for websites

Avatar

Level 3

Hi all,

How to prevent cross site scripting XSS attack fro websites ? I am able to inject scripts in my page which is not good !

I was under the impression overlaying the config.xml from libs to apps will work. Is there any additional configuration I need to look into ? 

P.S. I have already gone through the owasp cheat sheet but didn't find anything of use.

8 Replies

Avatar

Level 9

I guess not. However, You should also take care of XSS protection at the component level. 

amrit1993 wrote...

Hi all,

How to prevent cross site scripting XSS attack fro websites ? I am able to inject scripts in my page which is not good !

I was under the impression overlaying the config.xml from libs to apps will work. Is there any additional configuration I need to look into ? 

P.S. I have already gone through the owasp cheat sheet but didn't find anything of use.

 

Avatar

Employee

Do you have an example to share? For sure the XSS-logic needs to be done by yourself in your components.

Avatar

Level 3

<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"
%><%@include file="/apps/xyz/foundation/global.jsp"%>

<c:choose>
    <c:when test="${modelCategory.selected}">
        <a href="?selectedCategory=${modelCategory.categoryNameEncoded}" title="${modelCategory.dto.categoryName}"><b>${modelCategory.categoryText}</b></a>
    </c:when>
    <c:otherwise>
        <a href="?selectedCategory=${modelCategory.categoryNameEncoded}" title="${modelCategory.dto.categoryName}">${modelCategory.categoryText}</a>
    </c:otherwise>
</c:choose>

 

I am able to cross inject upon the href attribute.

Avatar

Level 3

Thanks for the link,

I tried to follow that, but it throwed 500 server error.

<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"
%><%@include file="/apps/xyz/foundation/global.jsp"%>
<% XSSAPI myXssAPI = xssAPI.getRequestSpecificAPI(request);%>

<c:choose>
    <c:when test="${modelCategory.selected}">
        <a href="<%= myXssAPI.getValidHref("?selectedCategory=${modelCategory.categoryNameEncoded}" title="${modelCategory.dto.categoryName}")%"><b>${modelCategory.categoryText}</b></a>
    </c:when>
    <c:otherwise>
        <a href="<%= myXssAPI.getValidHref("?selectedCategory=${modelCategory.categoryNameEncoded}" title="${modelCategory.dto.categoryName}")%">${modelCategory.categoryText}</a>
    </c:otherwise>
</c:choose>

Avatar

Employee

Here an example from :

You can just use xssAPI in your components:/apps/geometrixx-outdoors/components/page/head.jsp

    <title><%= xssAPI.encodeForHTML(title) %></title>