Java Security API and Web Vulnerability Protection
Tests knowledge of security API methods for preventing common web vulnerabilities including SQL injection, XSS, and CSRF attacks
Questions
What is the return type of the isAuthorizedForData() method in the security API?
- String
- boolean
- Integer
- void
What is the return type of the getCSRFToken() method?
- Integer
- Byte
- String
- BigInteger
What kind of exception does the method login(HttpServletRequest request, HttpServletResponse response) throw?
- LoginException
- EnterpriseSecurityException
- SecurityException
- IntrusionException
Which are the default scripting codecs supported by the security API
- JavaScript
- VBScript
- Both of the above
- None of the above
Which are the default codecs supported to help encode characters to be safely used on OS command shells
- Unix Codec
- Windows Codec
- Unix and Windows Codec
- Linux Codec
The security API supports codecs for SQL Strings of which of the following databases ?
- Oracle
- MySQL
- Both of the above
- Oracle, MySQL, Sybase, DB2
What is the functionality of the seal() method ?
- Creates a seal that binds a set of data and includes an expiration timestamp
- Encodes the data
- Hashes the data
- Scrambles the data
What method is provided within the security API to prevent caching by browsers and proxies?
- void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response)
- void setNoCacheHeaders(javax.servlet.http.HttpServletRequest request)
- boolean setNoCacheHeader(javax.servlet.http.HttpServletResponse response)
- void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
Which method among the below could be used as a defense against Cross Site Request Forgery?
- encryptHiddenField(java.lang.String value)
- addCSRFToken(final java.lang.String href)
- verifySecureComm(javax.servlet.http.HttpServletRequest request)
- setSafeContentType(javax.servlet.http.HttpServletResponse response)
Which set of security API methods could be used as the best defense against Cross Site Scripting?
- Input Validation and OutPut Encoding
- Authentication and Authorization
- Data Protection and Cryptography
- HTTP and Communication Security
What is the signature of the sign method in the security API?
- java.lang.String sign(java.lang.String data, java.lang.String key) throws EncryptionException
- java.lang.String sign(java.lang.String data, java.lang.String key)
- java.lang.String sign(java.lang.String data)
- java.lang.String sign(java.lang.String data) throws SecurityException
What is the signature of the seal method in the security API?
- java.lang.String seal(java.lang.String data,long timestamp) throws SecurityException
- java.lang.String seal(java.lang.String data,long timestamp) throws EncryptionException
- java.lang.String seal(java.lang.String data)
- java.lang.String seal(java.lang.String data) throws EncryptionException
"SELECT name FROM users WHERE id = " + form.getUserID()"; Using TCS SAPI what is the best way to remediate the SQL injection vulnerability in the above query to an Oracle Database?
- "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForOraSQL(validatedUserId);
- "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForSQL(validatedUserId);
- "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForSQL( new Codec(), validatedUserId);
- None of the above
What is the best methodology to remediate the SQL Injection vulnerability in a Java based web application?
- Use the com.tcs.sapi.io.ValidationUtil.encodeForOraSQL(String input) method
- Use PreparedStatement constructs and use the setXXX methods on the PreparedStatement object
- Use the Java createStatement construct to execute the query
- Concatenate your SQL string together using dynamic input and create and execute a PreparedStatement object using that query
Which among the below is the correct way to safely encode the URL "/admin/findUser.do?name=" + request.getParameter( "dangerousInput" )
- String safeURIToDisplay= "/admin/findUser.do?name=" + TCSSAPI.encoder().encodeForJavaScript(request.getParameter( "dangerousInput"));
- String safeURIToDisplay = TCSSAPI.encoder().encodeForURL( "/admin/findUser.do?name=" + request.getParameter( "dangerousInput" ) );
- String safeURIToDisplay= "/admin/findUser.do?name=" + com.tcs.sapi.io.ValidationUtil.encodeForURL(request.getParameter( "dangerousInput"));
- None of the above
Whats the use of adding the CSRF Token to the urls?
- Prevent Cross Site Scripting
- Prevent Cross Site Request Forgery
- Prevent Cross Site Tracing
- None of the above
What does isSecureRequest(HttpServletRequest request) method accomplish?
- It checks if the http request is made on an SSL channel
- It checks if the http method is a POST
- Both of the above
- None of the above
What messages does an object of EnterpriseSecurityException class contain?
- Log Message which gets logged in the log file and not safe to display to users
- User Message which is safe to display to users
- Both of the above
- None of the above
What exception is thrown by the security API when a user attempts to access a resource that they are not authorized for?
- SecurityException
- AccessException
- AuthenitcationException
- Exception
What is the most common exception thrown by the validation methods in the security API?
- Validation Exception
- SecurityException
- Encoding Exception
- Encryption Exception