Web security threats
19 questions in 7 subtopics.
CSRF
What is a CSRF attack, how does Spring Security's CSRF protection work by default, and when is it reasonable to disable it?After upgrading to Spring Security 6, a single-page app usingCookieCsrfTokenRepository.withHttpOnlyFalse() gets 403 on every POST, although it copies the XSRF-TOKEN cookie into the X-XSRF-TOKEN header. Why, and how do you fix it?Your company has browser apps, mobile apps and partner integrations calling the same backend. Define a CSRF and cookie policy that is secure and simple for teams to follow.CORS
A React app on https://app.example.com calls a Spring Boot API on https://api.example.com and the browser reports a CORS error on preflight. The controller has@CrossOrigin and it still fails when Spring Security is enabled. Why?A team set allowedOriginPatterns("*") with allowCredentials(true) on all endpoints to make CORS errors go away. Explain the risk and propose a correct setup.Security headers
Which HTTP security headers does Spring Security add by default, and which important header must you configure yourself?You must add a Content-Security-Policy to a large server-rendered application with inline scripts and third-party widgets, without breaking it. How do you proceed?Fifty web applications in your company have inconsistent security headers and few have a Content-Security-Policy. Define a header standard and how you would roll it out.XSS
How do stored, reflected and DOM-based XSS differ, and how do Thymeleaf's th:text and th:utext relate to XSS?Users can write rich-text comments with bold, links and lists in your Spring application. Design how you store and render them safely.SQL and JPQL injection
Find the vulnerability in this repository method and fix it:List<Order> find(String name, String sortField) {
return em.createQuery("select o from Order o where o.customer = '" + name + "' order by o." + sortField, Order.class).getResultList();
}
Deserialization attacks
Why is Java native deserialization of untrusted data dangerous, and what protections does the JDK offer? How do similar risks appear with Jackson and YAML?A new deserialization vulnerability is announced in a library used by many of your services. As the owner of the platform, how do you respond in the first 48 hours?Java native serialization has been the root of many critical vulnerabilities. Your estate still uses it in caches, RMI-style integrations and session storage. Would you run a programme to remove it, and how?OWASP Top 10 for Java
Which Spring Boot Actuator settings can create security problems if left open in production, and how should actuator endpoints be secured?Pick five categories from the OWASP Top 10 (for example the 2021 edition; check for the latest) and give a concrete example of each in a Spring Boot service, with the control you would use.How would you build an application security programme for 500 Java developers so that OWASP-style vulnerabilities decline year over year?No question matches these choices.