Skip to content

Commit b5ce118

Browse files
committed
SOLR-111 : Validate JSONP callback function name to avoid XSS
1 parent bbf16fb commit b5ce118

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/java/fr/paris/lutece/plugins/search/solr/web/SolrSuggestServlet.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public class SolrSuggestServlet extends HttpServlet
5959
{
6060
private static final long serialVersionUID = -3273825949482572338L;
6161

62+
private static final String CALLBACK_FUNCTION_NAME_ERROR_MESSAGE = "Callback function name must match [_\\-A-Za-z0-9]+" ;
63+
6264
public void init( )
6365
{
6466
}
@@ -76,6 +78,13 @@ public String getSuggest( HttpServletRequest request )
7678

7779
SolrSearchEngine engine = SolrSearchEngine.getInstance( );
7880
StringBuffer result = new StringBuffer( );
81+
82+
// XSS control
83+
if (callback == null || !callback.matches( "[_\\-A-Za-z0-9]+" ))
84+
{
85+
return CALLBACK_FUNCTION_NAME_ERROR_MESSAGE;
86+
}
87+
7988
result.append( callback );
8089

8190
result.append( "({\"response\":{\"docs\":[" );

0 commit comments

Comments
 (0)