Content security policy reports first and does not block, deciding to really block after seeing what happens

📅 2026-10-11 👁️ 8

Use the report-only mode of Content Security Policy first, and decide to block after seeing what information. This is the most stable order when launching this rule. The document speaks directly: The report-only approach is used for the testing phase, reports violations without blocking code execution. Its value does not lie in 'being gentle first', but in giving you a list of violations generated under real access conditions, from which you can decide which ones to block and which ones to modify the page first.

What problem does the only report mode solve?

The most common incident when directly enabling interception is the failure of page functionality: styles are blocked, third-party components cannot be loaded, and interactions report errors after inline scripts are disabled. These are often not fully visible in the test environment because real access is mixed with browser extensions, proxy injection, and different versions of clients.

The reporting mode separates judgment and execution: rules are evaluated as usual, violations are recorded as usual, and the page is rendered as usual. This allows you to collect data for one to two weeks without affecting visitors, distinguishing between 'sources that must be allowed' and 'injections that must be blocked'. This step is especially important for content-centric sites, as inline styles and embedded content in rich text are most likely to be mistakenly damaged.

Why do we need to write the report target twice

There are two ways to write the reporting address: the old address type and the new endpoint type. The document indicates that the new writing style is designed to replace the old one, and in browsers that support the new style, the old instructions will be ignored. This means that writing only one place will result in two bad situations - only write the old style, and the new browser will not report; only write the new style, and the old client will not report.

The practice during the compatibility period is to provide both: old addresses and new endpoint names in the same strategy, and also to declare the actual receiving address of the endpoint. The receiving end should do deduplication because the same violation may be reported twice in different formats. The report address itself should use an in-site path or a same-domain endpoint, and additional handling is required for cross-domain reporting, which is also the reason why many sites do not receive reports.

During the gray release period, what types of information should be looked at?

The first category is the most frequent source of violations, usually consisting of three types: embedded content, statistical scripts, and browser extension injection. The first two should be explicitly stated in the strategy, and the third should be excluded from the records—their domain names are varied, but none of them are under your controlled code. Mistaking them for targets to be intercepted will make the rules increasingly broad.

The second category is inline scripts and inline styles. Rich text on content sites often includes inline attributes, and directly banning them will distort the layout. For this category, either modify the template to extract the styles out, or accept a broader exception, based on the actual proportion in the violation records.

The third category is resources redirected to elsewhere. The strategy matches the source based on the final address, and resources with redirects are often judged to be违规. These should be changed to direct addresses at the source, rather than making exceptions for redirects.

Fallback when enabling interception

Switch by segment: intercept a few paths first, confirm there are no violations, and then expand to the entire site. Keep a fallback method, so that you can immediately revert to only reporting in case of functional failures, rather than temporarily adding exceptions to the strategy—temporary exceptions often do not come back.

When modifying the template, this layer needs to be checked together. The visual template editing capability within the site will affect both style references and script references at the same time. When modifying the public header and footer, the allowed writing styles of the strategy should be checked together; otherwise, the page will become blank after the template is modified, and the problem will be reported in the strategy.

Common questions

How long does it take to report only?Cover a complete content and event cycle, usually counted for one to two weeks, festival sites should include peak periods; a short period of time will miss the rare embedded forms.

How to troubleshoot if reports are not received?Please confirm that the report address is accessible, whether it is blocked by the same-origin restriction, whether both writing methods have been given, and whether the receiving end has discarded duplicate records.

Can we turn off the interceptor and only keep the report?Yes, if we only report long-term, it is equivalent to no protection, just treat it as a transition; after confirming that the violations are controllable, we should switch off the interceptor.

What is the reason for the sudden increase in the number of violations?Most of them come from third-party scripts changing domain names or template changes, first compare the source of violations with the time of the last template and dependency changes, rather than rush to add exceptions.

Related articles

The large attachment upload is blocked at 413, why is it not understandable in the browser?

When uploading a large attachment, it is blocked by the gateway and returns 413. Browsers often cannot display the reason because the limit is set before the request enters the application, and the program does not have time to take over. The default limit for this type of nginx is about one megabyte, which can be set by segment according to the site and location. This article explains which segment the limit controls, why the error is difficult to read, and how to check the three types of entry points for attachment upload, batch import, and interface upload.

2026-10-11

What codes should be returned for deleted articles and hidden columns, and what consequences will there be if they are all compressed into 404?

When deleting content or hiding columns, if the status code is unified to 404, the still existing paths will be read as expired. This article gives the landing points for the four types of semantics: delete, hide, reject, and exception, and explains how the recycling station, draft, and pending publication status within the site correspond to the front-end return, and attaches a list of standards for reference

2026-10-11

How will the front-end sorting and push be chaotic when the scheduled publication time zone difference is taken into account

Schedule publishing so that content transitions from pending to official at the specified time. Time zone differences can cause the overall launch time to shift, which may affect the sorting of content by release time on the front end and the timing of link promotions. First, clarify the visibility scope of the three states: pending, official, and recycling bin. Then, unify the time zone standards and verify the release time together during backup and recovery.

2026-10-11

Why are all the client addresses logged in the log all proxy addresses when a proxy is hung in front of the website?

After the reverse proxy, only the proxy address remains in the log because the connection indeed comes from the proxy. The real source needs to be obtained from the forwarding header, but this header can be forged, and only the section appended by the trusted proxy should be believed when retrieving the value. This article explains the alignment of the order, trust boundaries, and the three steps on the deployment side.

2026-10-11

Add integrity verification to external scripts, why do you still need to explicitly write cross-domain attributes in the tag?

When adding integrity check to external scripts, the cross-domain attribute must be explicitly written in the tag, because resources with integrity check must go through cross-domain requests, otherwise the browser will not consider the check result as available. The check value consists of an algorithm prefix plus an encoded hash, and multiple summary alternatives can be provided at the same time. This article explains where the check occurs, the format and alternatives, as well as how to batch verify reference points after template changes.

2026-10-11

How many addresses can a single sitemap file hold, and how should it be split if it exceeds the limit?

The single sitemap file has two concurrent limits: the number of addresses should not exceed 50,000, the uncompressed volume should not exceed 50MB, and any that reach the top must be split into multiple fragment files, and then a index file is used to list the fragments one by one. This article explains how to calculate the limit according to the original protocol, how to name the fragment directory stably, the division of labor between the index file and the sub-maps, as well as the pseudo-static rules and configuration to check when the background automatically generates the sitemap, to avoid bypassing the limit by trimming the number of addresses in an erroneous manner.

2026-10-12

How to fill in the last modified time in the sitemap so that it is easy to be accepted.

The last modified time in the sitemap should be filled in according to the actual change: the protocol requires the use of W3C Datetime format, which can only be written as a date; changefreq and priority are defined as hints rather than instructions, and full-site refresh will only make the crawler treat this field as noise. This article explains the protocol meaning of this field, the four common ways it is filled incorrectly, how to obtain the real change time from the content status, and the time scope to be noted when配合 with timed publishing.

2026-10-12

Forms and comments are flooded by robots, besides the captcha, what else can be done to add several layers?

Form and comment anti-robot spambot prevention, CAPTCHA only blocks the automatic submission layer, and cannot block scripts that have bypassed verification and low-cost manual submissions. The layered叠加 can be: submission verification (reCAPTCHA CAPTCHA, timestamp and honeytrap fields), content filtering (sensitive word filtering, keyword replacement, content review), publishing strategy (review before posting, pending publication status, frequency limit and login threshold). This article explains the limitations of each layer, as well as what to adjust when all three layers cannot block it.

2026-10-12