A financial services company is developing a Java application that processes international payments and must handle user data containing various Unicode characters. To prevent Cross-Site Scripting (XSS), a developer implements a filter using `String.replace()` to remove occurrences of ` ` and ` ` from all input fields. Which of the following statements best describes the primary security flaw in this approach?
Q2Multiple answers
A security team is integrating a Static Application Security Testing (SAST) tool into the CI/CD pipeline for a large Java microservices project. The initial scans produce a high volume of findings, many of which are deemed false positives by the development team, causing friction and delays. Which TWO of the following actions represent the most effective strategies for managing SAST results and improving the DevSecOps workflow? (Select TWO)
Q3
A developer is building a secure file upload feature for a Java web application. The application needs to store user-uploaded files on a server filesystem. To prevent directory traversal attacks (e.g., `../../etc/passwd`), the developer uses the `getCanonicalPath()` method to resolve the final path before writing the file. Is this approach, by itself, sufficient to prevent directory traversal attacks?
Q4
A DevOps engineer is tasked with securing a containerized Java application deployed on a Kubernetes cluster. The application uses a `log4j2.xml` configuration file to manage logging. The engineer wants to prevent sensitive information, such as API keys and database credentials stored in environment variables, from being accidentally written to the application logs. Which Log4j2 feature should be used to accomplish this? `________ {env:API_KEY}`
Q5
**Case Study** A retail company, StyleSphere, is modernizing its e-commerce platform. The new architecture is based on Java microservices running in Docker containers and managed by Kubernetes. A central 'Auth Service' is responsible for user authentication and issues JSON Web Tokens (JWTs). Other microservices, such as 'Product Service' and 'Order Service', validate these JWTs to authorize user requests. The security architect has outlined the following requirements for the JWT implementation: 1. Tokens must be protected against tampering. 2. The identity of the token issuer (the Auth Service) must be verifiable. 3. Tokens must have a limited lifespan to reduce the impact of a compromised token. 4. The system must be able to handle a high volume of authentication requests without overloading the Auth Service with validation calls. During a design review, a debate arises about the best way to sign the JWTs. The team is considering two options: HMAC with a shared secret (HS256) and RSA with a public/private key pair (RS256). Given the microservices architecture and requirements, which signing algorithm is the most appropriate choice and why?
Q6
A Java application uses the Java Cryptography Architecture (JCA) to encrypt sensitive data using AES. The development team wants to ensure the application can support strong encryption algorithms that may not be included in the default JDK distribution, and they want to do this without modifying the `java.security` file in the JDK installation. What is the standard mechanism in Java to achieve this?
Q7Multiple answers
During a security assessment of a Java application, you discover that session identifiers are being passed in the URL. Which of the following vulnerabilities does this practice directly introduce? (Select THREE) ```mermaid sequenceDiagram participant User participant Browser participant Server User->>Browser: Login with credentials Browser->>Server: POST /login Server-->>Browser: Redirect to /dashboard?jsessionid=xyz123 Browser->>Server: GET /dashboard?jsessionid=xyz123 Note over Browser: jsessionid is now in URL User->>Browser: Copies and pastes URL to a colleague Note right of User: Session Hijacking Occurs ```
Q8
A developer is implementing a feature that deserializes user-provided data into a Java object using `ObjectInputStream`. The lead security engineer has warned about the risks of insecure deserialization. Which of the following is the most effective mitigation strategy against this vulnerability?
Q9
A security analyst is performing a DAST scan on a new Java REST API. The scan reports a potential vulnerability: 'Verbose Error Messages - Stack Trace Disclosure'. The analyst investigates and finds that when an unhandled `NullPointerException` occurs, the API returns a 500 Internal Server Error response containing the full Java stack trace. Which is the most appropriate way to remediate this vulnerability in a Spring Boot application?
Q10
A software architect is designing a secure deployment strategy for a fleet of Java-based IoT devices. The devices have limited resources and occasionally intermittent network connectivity. The architect needs to ensure that the application JAR file deployed to the devices has not been tampered with and originates from the company's build server. Which Java utility is best suited for this purpose?