Package fr.paris.lutece.util.http
Class SecurityUtil
java.lang.Object
fr.paris.lutece.util.http.SecurityUtil
Security utils
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsCleanParameters(javax.servlet.http.HttpServletRequest request) Scan request parameters to see if there no malicious code.static booleancontainsCleanParameters(javax.servlet.http.HttpServletRequest request, String strXssCharacters) Scan request parameters to see if there no malicious code.static booleancontainsPathManipulationChars(javax.servlet.http.HttpServletRequest request, String strValue) Check if the value contains characters used for Path Manipulationstatic booleanCheck if the value contains terms used for XML External Entity Injectionstatic booleancontainsXssCharacters(javax.servlet.http.HttpServletRequest request, String strString) Checks if a String contains characters that could be used for a cross-site scripting attack.static booleancontainsXssCharacters(javax.servlet.http.HttpServletRequest request, String strValue, String strXssCharacters) Checks if a String contains characters that could be used for a cross-site scripting attack.static StringdumpRequest(javax.servlet.http.HttpServletRequest request) Dump all request infostatic StringgetRealIp(javax.servlet.http.HttpServletRequest request) Get the IP of the user from a request.static booleanisInternalRedirectUrlSafe(String strUrl, javax.servlet.http.HttpServletRequest request) Validate a forward URL to avoid open redirect with url safe patterns found in propertiesstatic booleanisInternalRedirectUrlSafe(String strUrl, javax.servlet.http.HttpServletRequest request, String strAntPathMatcherPatterns) Validate an internal redirect URL to avoid internal open redirect.static StringlogForgingProtect(String strUserInputData) Identify user data saved in log files to prevent Log Forging attacks
-
Field Details
-
PROPERTY_REDIRECT_URL_SAFE_PATTERNS
- See Also:
-
PROPERTY_REDIRECT_URL_BLOCKED_SCHEMES
- See Also:
-
PROPERTY_REDIRECT_URL_BLOCKED_CHARACTERS_PATTERNS
- See Also:
-
_log
public static final org.apache.logging.log4j.Logger _log
-
-
Method Details
-
containsCleanParameters
public static boolean containsCleanParameters(javax.servlet.http.HttpServletRequest request) Scan request parameters to see if there no malicious code.- Parameters:
request- The HTTP request- Returns:
- true if all parameters don't contains any special characters
-
containsCleanParameters
public static boolean containsCleanParameters(javax.servlet.http.HttpServletRequest request, String strXssCharacters) Scan request parameters to see if there no malicious code.- Parameters:
request- The HTTP requeststrXssCharacters- a String wich contain a list of Xss characters to check in strValue- Returns:
- true if all parameters don't contains any special characters
-
containsXssCharacters
public static boolean containsXssCharacters(javax.servlet.http.HttpServletRequest request, String strString) Checks if a String contains characters that could be used for a cross-site scripting attack.- Parameters:
request- The HTTP requeststrString- a character String- Returns:
- true if the String contains illegal characters
-
containsXssCharacters
public static boolean containsXssCharacters(javax.servlet.http.HttpServletRequest request, String strValue, String strXssCharacters) Checks if a String contains characters that could be used for a cross-site scripting attack.- Parameters:
request- The HTTP requeststrValue- a character StringstrXssCharacters- a String wich contain a list of Xss characters to check in strValue- Returns:
- true if the String contains illegal characters
-
containsXmlExternalEntityInjectionTerms
Check if the value contains terms used for XML External Entity Injection- Parameters:
strValue- The value- Returns:
- true if
-
containsPathManipulationChars
public static boolean containsPathManipulationChars(javax.servlet.http.HttpServletRequest request, String strValue) Check if the value contains characters used for Path Manipulation- Parameters:
request- The Http requeststrValue- The value- Returns:
- true if
-
dumpRequest
Dump all request info- Parameters:
request- The HTTP request- Returns:
- A report containing all request info
-
getRealIp
Get the IP of the user from a request. If the user is behind an apache server, return the ip of the user instead of the ip of the server.- Parameters:
request- The request- Returns:
- The IP of the user that made the request
-
isInternalRedirectUrlSafe
public static boolean isInternalRedirectUrlSafe(String strUrl, javax.servlet.http.HttpServletRequest request) Validate a forward URL to avoid open redirect with url safe patterns found in properties- Parameters:
strUrl-request-- Returns:
- true if valid
- See Also:
-
isInternalRedirectUrlSafe
public static boolean isInternalRedirectUrlSafe(String strUrl, javax.servlet.http.HttpServletRequest request, String strAntPathMatcherPatterns) Validate an internal redirect URL to avoid internal open redirect. (Use this function only if the use of internal url redirect keys is not possible. For external url redirection control, use the plugin plugin-verifybackurl) the url should : - not be blank (null or empty string or spaces) - not start with "http://" or "https://" or "//" OR match the base URL or any URL in the pattern list example with a base url "https://lutece.fr/ : - valid : myapp/jsp/site/Portal.jsp , Another.jsp , https://lutece.fr/myapp/jsp/site/Portal.jsp - invalid : http://anothersite.com , https://anothersite.com , //anothersite.com , file://my.txt , ...- Parameters:
strUrl- the Url to validaterequest- the current request (containing the baseUrl)strAntPathMatcherPatterns- a comma separated list of AntPathMatcher patterns, as "http://**.lutece.com,https://**.lutece.com"- Returns:
- true if valid
-
logForgingProtect
Identify user data saved in log files to prevent Log Forging attacks- Parameters:
strUserInputData- User Input Data- Returns:
- The User Data to log
-