MYTHOSAI

Web application defence labs / GUIDED EXERCISE

Design a content security policy report-only rollout

A company website loads its own JavaScript plus one analytics provider and is considering a tighter CSP.

Before you start

No paid tools required. Use this guide with sample data, paper, or an explicitly authorised test environment. Keep a copy of any original configuration and obtain approval before changes.

A scenario worth testing

A company website loads its own JavaScript plus one analytics provider and is considering a tighter CSP. This scenario is an invented teaching example, not a description of an actual breach or test of a named organisation.

OWASP Top 10:2025 lists Broken Access Control as A01 and treats software security as a combination of design, implementation and operational risk. In this guide, the purpose is to evaluate a specific decision and its evidence. It does not follow that the scenario is likely in every environment, or that any untested product is vulnerable.

Red team perspective: define the risk

Question to test. Could an overly broad policy allow unwanted script sources, while a rushed strict policy breaks legitimate functionality?

Blue team perspective: define the boundary

Defensive decision. Inventory script origins and use report-only observations before enforcement.

Safe experiment: make the question measurable

Scope: synthetic records or an explicitly authorised, disposable test environment only. No customer records, live exploit payloads or third-party probing.

  1. State the decision. Describe the asset, who should be authorised, and which fact would refute the initial hypothesis.
  2. Create a safe fixture. Construct the example. On paper, compare three fictional scripts against two CSP source lists; predict which would be blocked.
  3. Evaluate three cases. Use the fictional cases below; identify the permitted case, an adverse case and a plausible exception. Record what evidence distinguishes them.
  4. Write an outcome. Decide whether to allow, deny, escalate or ask for more information. Record the policy owner and one measurable follow-up. Never equate a planned test with a completed live test.

Worked example and expected observations

Illustrative result, not a measured finding: A decision table covering required origins, optional scripts and policy violations.

Three synthetic cases to classify — examples, not observed incidents
CaseFictional inputDecision to justify
Expected activityExpected first-party scripts produce no unexplained report-only eventsExplain the precise reason it is permitted or expected.
Boundary challengeNew third-party script would violate proposed script-src policyIdentify the policy, detection or approval that should respond.
Lookalike or exceptionBrowser extension creates report-only noise not originating in site codeIdentify the missing context before making an accusation.

Interpret this example

Start with the expected case: expected first-party scripts produce no unexplained report-only events. Compare the relevant boundary with the adverse case: new third-party script would violate proposed script-src policy. The distinction depends on Directive, blocked URI, source page and false-positive triage, not the alarming appearance of an isolated event.

The third case deliberately resists a snap conclusion: browser extension creates report-only noise not originating in site code. Record which additional fact would change the decision. Make the server-side decision independent of the user interface. Client-side validation can improve usability but cannot substitute for authoritative enforcement.

Download the three-case CSV exercise (illustrative inputs, not collected production evidence).

Evaluate evidence and failure modes

False confidence to avoid: A report-only violation is not proof of an attack; browser extensions also inject scripts. A mock application is useful for a regression test but cannot prove security in a complete production system.

Authentication, authorisation, input validation and monitoring solve different problems; one successful test cannot substitute for the others. When a log source is missing or a sample is ambiguous, mark the conclusion unverified rather than estimating a success rate from fictional data.

Decide what to improve

Recommended next action: Promote a tested nonce/hash strategy for authored scripts and review exceptions carefully. Use intentionally local mock data and negative tests, including cases the application must reject.

  • Which exact asset and named owner does this decision concern?
  • Would your evidence include Directive, blocked URI, source page and false-positive triage?
  • Does the adverse case need blocking, investigation or both?
  • What one controlled follow-up would distinguish the lookalike case from abuse?

Official references and limitations

Primary references explain the underlying control or framework; they do not validate the fictional cases above.

Try the related offline practice workbook, with runnable Python standard-library examples and marked limitations.