Tag: security

Questions Related to security

Choose the correct answer: ... Statement stmt = conn.createStatement (); ResultSet rs = stmt.executeQuery (); stmt.close (); conn.close(); ...

  1. Code is vulnerable as Resource is not released in the “finally” block

  2. Code is vulnerable as Resource is not released at all

  3. Code has no vulnerability

  4. Option 1 AND Option 2


Correct Option: A

Choose the correct answer: a. HTTP PUT & DELETE method can be disabled in web.xml from the below code: Disallowed Location /* PUT DELETE b. HTTP PUT & DELETE methods are disabled by default on many web server c. HTTP PUT & DELETE methods should not be disabled d. HTTP PUT & DELETE methods cannot be disabled

  1. a

  2. b

  3. c

  4. d

  5. Option 1 AND Option 2


Correct Option: E

Fnction below is used to read file from a directory on the filesystem. This code runs with read only OS level privilege on this directory. fileName is parameter from user directly passed to this function. public void dummyFunction(String fileName){ FileInputStream fis = new FileInputStream(fileName); // code to read file content only, no write modify or delete } Identify correct answer

  1. Security is handled at OS level by giving only read level privilege so no need to put an extra check here

  2. Only problem here is that fileName may not be syntactically incorrect so it should be validated before using it in the function

  3. This code can lead to information disclosure attack

  4. Java provides enough security by default for IO operations so this code is not vulnerable.


Correct Option: C

Please select which of the following statements are NOT true regarding the AccessController class? a. Can be used to mark code as being "privileged", thus affecting subsequent access determinations b. Can be to decide whether an access to a critical system resource is to be allowed or denied, based on the security policy currently in effect c. Can be used to obtain a "snapshot" of the current calling context d. Can be used to compute a cryptographically secure hash

  1. a

  2. b

  3. c

  4. d


Correct Option: D
  1. Subject.doAs()

  2. AccessController.checkPermission()

  3. SecurityManager.checkAccess()

  4. None of the above


Correct Option: A

Please select which of the following statements regarding Java 2 Security is TRUE?

  1. The type safety mechanism in the Java language prevents the execution of malicious code

  2. Two classes with the same fully qualified name but which are defined by different instances of a class loader are NOT of the same type

  3. All signed classes are implicitly trusted and granted full access

  4. The principal role of a TrustManager is to determine if presented authentication credentials should be trusted

  5. Option 1 AND Option 4

  6. Option 2 AND Option 4


Correct Option: F