Quick revision
The short answer
The baseline is HSTS, X-Content-Type-Options: nosniff, frame protection through CSP frame-ancestors or X-Frame-Options, a Referrer-Policy and a Content-Security-Policy. It is delivered by default through the platform starter or the gateway, CSP starts in report-only mode with reports collected centrally, exceptions are documented per application with an owner, and regular scans detect missing or weakened headers so the standard does not drift.
What to remember
In this answer, we defined a header baseline of HSTS, nosniff, frame protection, Referrer-Policy and CSP, with a reason for each. The platform starter and the gateway deliver it by default, CSP goes out in report-only mode with central reports and is enforced application by application, exceptions are documented with owners and review dates, and regular scans and CI checks keep fifty applications from drifting.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The baseline is HSTS, X-Content-Type-Options: nosniff, frame protection through CSP frame-ancestors or X-Frame-Options, a Referrer-Policy and a Content-Security-Policy. It is delivered by default through the platform starter or the gateway, CSP starts in report-only mode with reports collected centrally, exceptions are documented per application with an owner, and regular scans detect missing or weakened headers so the standard does not drift.
Why this question is asked
Fifty applications with inconsistent headers is a normal result of many teams copying configuration over the years. Each gap is small, but attackers look for the weakest application on the domain, and auditors look at all of them. The hard part is not choosing the headers, which is well understood; it is getting fifty teams to the same place without breaking their applications, especially for CSP. Interviewers ask this design question to see whether we can set a standard that is strict, achievable and self-maintaining. In this answer, we will define the baseline and the reason for each header, decide where the headers are added, plan the CSP rollout, handle exceptions, and keep everything checked.
1The Baseline and Why Each Header Is in It
Strict-Transport-Security makes browsers use HTTPS for our domains for a long period, closing the window for downgrade and interception on the first plain request. The standard sets max-age to at least one year with includeSubDomains, once every subdomain serves HTTPS; preload is a separate decision because it is hard to undo.
X-Content-Type-Options: nosniff makes browsers trust the declared content type, so an uploaded file cannot be interpreted as script. Frame protection stops clickjacking: CSP frame-ancestors 'none' (or 'self') for modern browsers, with X-Frame-Options DENY or SAMEORIGIN kept consistent for older ones. Referrer-Policy: strict-origin-when-cross-origin prevents full URLs, which may contain ids or tokens, from being sent to other sites.
Content-Security-Policy is the most valuable and the hardest. The baseline requires a policy that at minimum sets object-src 'none', base-uri 'self' and frame-ancestors, and a script-src without 'unsafe-inline', reached over time. Cache-Control: no-store for authenticated responses rounds out the list.
| Header | Standard value | Notes |
|---|---|---|
| Strict-Transport-Security | max-age=31536000; includeSubDomains | Preload by separate decision |
| X-Content-Type-Options | nosniff | All responses |
| Frame protection | frame-ancestors 'none' + X-Frame-Options DENY | 'self' / SAMEORIGIN if needed |
| Referrer-Policy | strict-origin-when-cross-origin | Stricter allowed |
| Content-Security-Policy | object-src 'none'; base-uri 'self'; script-src nonces | Report-only first |
| Cache-Control (authenticated) | no-store | Spring Security default |
2Where the Headers Are Added
There are two places to deliver them by default. For Spring applications, the platform security starter configures Spring Security's header writers: most defaults are already there, and the starter adds Referrer-Policy, frame-ancestors and a baseline CSP. That keeps headers close to the application, which matters for CSP, whose nonces must be generated per response by the application.
For applications we do not control well, such as vendor products or non-Spring stacks, the API gateway or reverse proxy adds the static headers, HSTS, nosniff, frame protection and Referrer-Policy, if they are missing. Using both layers is fine as long as one is authoritative for each header, so we do not end up with two conflicting CSP headers, which browsers would both apply.
3Rolling Out CSP Without Breaking Applications
CSP goes out in report-only mode first, for every application, with reports sent to one central collector. That gives the platform team a single view of all fifty applications: which are already clean, which have a few inline scripts, and which load scripts from many third parties. Applications are then grouped into waves by how close they are, with the cleanest switched to enforcing first so the process is proven on easy cases.
Teams get help, not just a deadline: a guide for moving inline scripts into files, a shared nonce filter for Thymeleaf, and a report view filtered to their application. Each application moves to enforcement when its reports show only noise for a few weeks, and keeps a report-only header for the next tightening.
- Adopt starter or gateway headersStatic headers enforced at once
- CSP in report-onlyReports to central collector
- Fix violationsInline scripts, widget origins
- Clean for a few weeks?Only noise in reportsYesEnforce CSPNoKeep fixing; agree a date
- Scan and monitorAlert on missing or weakened headers
5 steps in order. Play them, or step through them one at a time.
4Documented Exceptions with Owners
Some applications have real reasons to deviate. A dashboard designed to be embedded by partners needs frame-ancestors listing those partners. A vendor tool may need 'unsafe-eval' until the vendor updates it. The standard allows exceptions, but each one is written down with the header, the deviation, the reason, an owner and a review date, and is kept in the application's configuration where the starter can see it. An exception without an owner or past its review date shows up in the scan as a finding.
This keeps the standard honest. Without a sanctioned way to deviate, teams copy workarounds or turn headers off silently; with one, we know exactly where the weak points are.
5Scanning So the Standard Holds
Headers drift: a framework upgrade, a new proxy or a quick fix can remove or weaken them. So a scheduled scan requests the main pages of every application, records the headers and compares them with the baseline and the documented exceptions. Results go to a dashboard per application and team, and new gaps raise tickets automatically. The same check runs in each application's CI as an integration test that reads response headers.
The scan also gives leadership a simple measure: how many of the fifty applications meet the baseline, and how many enforce CSP. Watching that number move each month is what keeps the rollout funded and on track.
6Follow-up questions
Why not put everything at the gateway and skip the starter?
Static headers work well at the gateway, but a strong CSP uses per-response nonces that the application generates, and the application knows which inline scripts it has. So CSP belongs in the application, and the gateway is a safety net for the static headers.
Should HSTS preload be part of the baseline?
Not by default. Preload puts the domain into browsers' built-in lists, and removing it takes months. It makes sense once every subdomain is reliably HTTPS, as a separate decision.
How do you get teams to prioritise CSP fixes?
Show their reports and their position in the scan, make the fixes easy with shared tools, and agree a date per wave with their managers. Teams move faster when the work is visible and small.
7Conclusion
In this answer, we defined a header baseline of HSTS, nosniff, frame protection, Referrer-Policy and CSP, with a reason for each. The platform starter and the gateway deliver it by default, CSP goes out in report-only mode with central reports and is enforced application by application, exceptions are documented with owners and review dates, and regular scans and CI checks keep fifty applications from drifting.
Open with
I would define a short baseline and explain why each header is there. HSTS for at least a year with includeSubDomains, so browsers always use HTTPS. X-Content-Type-Options nosniff, so uploads cannot be run as script.
Then, if they want more
Frame protection with CSP frame-ancestors and a matching X-Frame-Options, against clickjacking. Referrer-Policy strict-origin-when-cross-origin, so full URLs do not leak to other sites. And a Content-Security-Policy, at minimum object-src none and base-uri self, working towards a nonce-based script-src without unsafe-inline. Then delivery: for Spring applications the platform security starter configures all of this, so adding the dependency gives the baseline.
For vendor or non-Spring applications the gateway adds the static headers. CSP stays in the application because nonces are generated per response. For CSP, I would roll out in report-only mode everywhere, with reports going to one central collector, fix inline scripts and widget origins with shared tooling, and switch applications to enforcing in waves once their reports are clean.
Exceptions are allowed, but each is documented with an owner, a reason and a review date. Finally I would run a scheduled scan of all fifty applications that compares their headers with the baseline and the exceptions, plus a header test in CI, and report the number of compliant applications monthly so the rollout keeps moving.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- OWASP Top Ten
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Fifty web applications in your company have inconsistent security headers and few have a...": https://scrivio-interview-library.netlify.app/spring-boot/web-security-threats/acd150d72f/