Java Security — Concept Check
Questions on Java Security. Java security covers input validation, cryptographic APIs, secure coding practices, and common vulnerability prevention (OWASP Top 10).
Questions in this quiz
8 questions on Java Security — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A Java application reads user input for file access. What should be done to prevent path traversal attacks?
- AStore file paths in plain text
- BUse java.util.Random for generating file paths
- CUse Files.readString() directly with the user input
- DNormalize and validate the file path
2.A developer uses `java.util.Random` to generate session tokens. What is the risk?
- ATokens will be cryptographically secure
- BTokens will be unique
- CTokens may be predictable
- DTokens will be too long
3.Which cryptographic function is suitable for password storage in Java?
- AMD5
- BAES
- CSHA-256
- DPBKDF2
4.A developer configures an XML parser without disabling external entities. What vulnerability might occur?
- ACross-Site Scripting (XSS)
- BPath Traversal
- CXML External Entity (XXE)
- DSQL Injection
5.What is the primary reason for using PreparedStatement in SQL queries?
- ATo simplify query syntax
- BTo prevent SQL Injection
- CTo automatically close connections
- DTo improve query performance
6.A developer uses SHA-256 for password hashing. What's the problem with this approach?
- ASHA-256 is too slow
- BSHA-256 requires too much memory
- CSHA-256 is not secure
- DSHA-256 is not suitable for passwords
7.What should be avoided when configuring TLS for a Java application?
- AUsing TLSv1.2
- BUsing SecureRandom
- CUsing HttpClient
- DUsing SSLv3
8.A Java application uses ObjectInputStream without filters. What risk does this pose?
- ADeserialization vulnerability
- BSlower performance
- CIncreased memory usage
- DIncreased CPU usage