Web Application Security API Programming

Quiz covering security API methods for preventing web vulnerabilities including SQL injection, CSRF, XSS, and input validation techniques

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What is the return type of the getCSRFToken() method?

  1. Integer
  2. Byte
  3. String
  4. BigInteger
Question 2 Multiple Choice (Single Answer)

What kind of exception does the method login(HttpServletRequest request, HttpServletResponse response) throw?

  1. LoginException
  2. EnterpriseSecurityException
  3. SecurityException
  4. IntrusionException
Question 3 Multiple Choice (Single Answer)

Which are the default scripting codecs supported by the security API

  1. JavaScript
  2. VBScript
  3. Both of the above
  4. None of the above
Question 4 Multiple Choice (Single Answer)

Which are the default codecs supported to help encode characters to be safely used on OS command shells

  1. Unix Codec
  2. Windows Codec
  3. Unix and Windows Codec
  4. Linux Codec
Question 5 Multiple Choice (Single Answer)

The security API supports codecs for SQL Strings of which of the following databases ?

  1. Oracle
  2. MySQL
  3. Both of the above
  4. Oracle, MySQL, Sybase, DB2
Question 6 Multiple Choice (Single Answer)

What is the functionality of the seal() method ?

  1. Creates a seal that binds a set of data and includes an expiration timestamp
  2. Encodes the data
  3. Hashes the data
  4. Scrambles the data
Question 7 Multiple Choice (Single Answer)

What method is provided within the security API to prevent caching by browsers and proxies?

  1. void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response)
  2. void setNoCacheHeaders(javax.servlet.http.HttpServletRequest request)
  3. boolean setNoCacheHeader(javax.servlet.http.HttpServletResponse response)
  4. void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
Question 8 Multiple Choice (Single Answer)

Which method among the below could be used as a defense against Cross Site Request Forgery?

  1. encryptHiddenField(java.lang.String value)
  2. addCSRFToken(final java.lang.String href)
  3. verifySecureComm(javax.servlet.http.HttpServletRequest request)
  4. setSafeContentType(javax.servlet.http.HttpServletResponse response)
Question 9 Multiple Choice (Single Answer)

Which set of security API methods could be used as the best defense against Cross Site Scripting?

  1. Input Validation and OutPut Encoding
  2. Authentication and Authorization
  3. Data Protection and Cryptography
  4. HTTP and Communication Security
Question 10 Multiple Choice (Single Answer)

What is the signature of the sign method in the security API?

  1. java.lang.String sign(java.lang.String data, java.lang.String key) throws EncryptionException
  2. java.lang.String sign(java.lang.String data, java.lang.String key)
  3. java.lang.String sign(java.lang.String data)
  4. java.lang.String sign(java.lang.String data) throws SecurityException
Question 11 Multiple Choice (Single Answer)

What is the signature of the seal method in the security API?

  1. java.lang.String seal(java.lang.String data,long timestamp) throws SecurityException
  2. java.lang.String seal(java.lang.String data,long timestamp) throws EncryptionException
  3. java.lang.String seal(java.lang.String data)
  4. java.lang.String seal(java.lang.String data) throws EncryptionException
Question 12 Multiple Choice (Single Answer)

"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?

  1. "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForOraSQL(validatedUserId);
  2. "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForSQL(validatedUserId);
  3. "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForSQL( new Codec(), validatedUserId);
  4. None of the above
Question 13 Multiple Choice (Single Answer)

What is the best methodology to remediate the SQL Injection vulnerability in a Java based web application?

  1. Use the com.tcs.sapi.io.ValidationUtil.encodeForOraSQL(String input) method
  2. Use PreparedStatement constructs and use the setXXX methods on the PreparedStatement object
  3. Use the Java createStatement construct to execute the query
  4. Concatenate your SQL string together using dynamic input and create and execute a PreparedStatement object using that query
Question 14 Multiple Choice (Single Answer)

Which among the below is the correct way to safely encode the URL "/admin/findUser.do?name=" + request.getParameter( "dangerousInput" )

  1. String safeURIToDisplay= "/admin/findUser.do?name=" + TCSSAPI.encoder().encodeForJavaScript(request.getParameter( "dangerousInput"));
  2. String safeURIToDisplay = TCSSAPI.encoder().encodeForURL( "/admin/findUser.do?name=" + request.getParameter( "dangerousInput" ) );
  3. String safeURIToDisplay= "/admin/findUser.do?name=" + com.tcs.sapi.io.ValidationUtil.encodeForURL(request.getParameter( "dangerousInput"));
  4. None of the above
Question 15 Multiple Choice (Single Answer)

Whats the use of adding the CSRF Token to the urls?

  1. Prevent Cross Site Scripting
  2. Prevent Cross Site Request Forgery
  3. Prevent Cross Site Tracing
  4. None of the above
Question 16 Multiple Choice (Single Answer)

What does isSecureRequest(HttpServletRequest request) method accomplish?

  1. It checks if the http request is made on an SSL channel
  2. It checks if the http method is a POST
  3. Both of the above
  4. None of the above
Question 17 Multiple Choice (Single Answer)

What messages does an object of EnterpriseSecurityException class contain?

  1. Log Message which gets logged in the log file and not safe to display to users
  2. User Message which is safe to display to users
  3. Both of the above
  4. None of the above
Question 18 Multiple Choice (Single Answer)

What exception is thrown by the security API when a user attempts to access a resource that they are not authorized for?

  1. SecurityException
  2. AccessException
  3. AuthenitcationException
  4. Exception
Question 19 Multiple Choice (Single Answer)

What is the most common exception thrown by the validation methods in the security API?

  1. Validation Exception
  2. SecurityException
  3. Encoding Exception
  4. Encryption Exception
Question 20 Multiple Choice (Single Answer)

The usage of setRememberToken is

  1. Generally recommended
  2. Generally not recommended
  3. Should always be used
  4. Should not be used at all