
- Add the
spring-boot-starter-securitydependency. - Create a
WebSecurityConfigclass to disable CSRF (since we’re only using security for headers).
1. Update pom.xml
Add Spring Security Starter (version managed by your parent POM):<dependencies> block might resemble:
Spring Security automatically adds many secure headers, including
X-Content-Type-Options: nosniff.2. Create WebSecurityConfig
In your IDE, right-click the package undersrc/main/java and select New → Class:

WebSecurityConfig and add the following:

3. Dependency-Check Failure (CVSS ≥ 8)
During the Maven dependency scan, the build fails due to high-severity issues in Spring Security:

Raising the CVSS threshold should only be temporary. Revert once a fixed release is available.
4. Adjust failBuildOnCVSS
In your pom.xml, configure the OWASP Dependency-Check plugin:
5. Build Passes with CVSS 10
With the threshold raised, the dependency scan now succeeds, and Jenkins shows:

6. OWASP ZAP DAST
The ZAP stage now completes, reporting only one warning:7. Verify Response Headers
Refresh your application endpoint in the browser. You should now see:- Before: No
X-Content-Type-Optionsheader - After:
X-Content-Type-Options: nosniff
Links and References
- OWASP ZAP Official Site
- Spring Boot Security Reference
- OWASP Dependency-Check Maven Plugin
- National Vulnerability Database (NVD)