Work / CS-06

Content Security Policy: from report-only to blocking without breaking the site

Year
2025
Where
High Speed Training
Themes
Security
Stack
ASP.NET Core, OrchardCore, CSP nonces

Result, up front

  • Report-only → blockingwith no customer-visible breakage
  • 4apps with CSRF protection fixed
  • Allin-scope pen-test findings closed

Situation

A penetration test flagged the website’s script protections. A Content Security Policy (CSP, a browser rule saying which scripts may run) is the fix, but a strict CSP turned on in one go breaks every third-party tool on a marketing site.

How I framed it

Turn it on safely: observe first, then fix, then enforce.

What I did

  • Added a nonce-based CSP (each page load gets a random token that approved scripts must carry) in report-only mode.
  • Removed inline event handlers and catalogued every violation across the site and checkout.
  • Fixed the breakages in analytics, chat, video, heat-mapping and tag-manager integrations.
  • Switched to blocking mode, then extended the same approach to other apps.
  • In the same pen-test round, fixed CSRF protection across four apps and an open redirect on a contact form.

Result

The site moved to an enforced CSP with no customer-visible breakage. All the pen-test findings in scope were closed.

→ Contact

Have a problem worth measuring?

I'm a Senior Software Engineer in the UK. The quickest way to reach me is email.