Scrivio Interview library

Web security threats

19 questions in 7 subtopics.

CSRF

ConceptFoundations7 min read
What is a CSRF attack, how does Spring Security's CSRF protection work by default, and when is it reasonable to disable it?
DebuggingIntermediate6 min read
After upgrading to Spring Security 6, a single-page app using CookieCsrfTokenRepository.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?
DesignAdvanced6 min read
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

DebuggingFoundations6 min read
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?
ScenarioIntermediate6 min read
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

ConceptFoundations6 min read
Which HTTP security headers does Spring Security add by default, and which important header must you configure yourself?
ScenarioIntermediate7 min read
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?
DesignAdvanced6 min read
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

ConceptFoundations6 min read
How do stored, reflected and DOM-based XSS differ, and how do Thymeleaf's th:text and th:utext relate to XSS?
DesignIntermediate6 min read
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

DebuggingFoundations6 min read
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();
}
ScenarioIntermediate6 min read
A static analysis tool reports 400 possible SQL injection findings in a ten-year-old codebase with JDBC, JPA and MyBatis. How do you triage and fix them efficiently?
LeadershipPrincipal8 min read
Code volume is growing fast, including code produced with AI assistants, and security reviews cannot keep up. How would you keep injection and similar vulnerability classes out of your Java codebase over the coming years?

Deserialization attacks

ConceptIntermediate7 min read
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?
ScenarioAdvanced7 min read
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?
LeadershipPrincipal7 min read
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

ConceptFoundations6 min read
Which Spring Boot Actuator settings can create security problems if left open in production, and how should actuator endpoints be secured?
ConceptIntermediate6 min read
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.
LeadershipPrincipal6 min read
How would you build an application security programme for 500 Java developers so that OWASP-style vulnerabilities decline year over year?