No unsafe-inline
Content Security Policy (CSP) is a computer security standard introduced to prevent cross-site scripting (XSS), clickjacking and other code injection attacks resulting from execution of malicious content in the trusted web page context. Cross-site scripting (XSS) is a type of security vulnerability that can be found in some web applications. XSS attacks enable attackers to inject client-side scripts into web pages viewed by other users. A cross-site scripting vulnerability may be used by attackers to bypass access controls like the same-origin policy. Looking at National Vulnerability Database run by US NIST, more than 1100 (November 2025) vulnerabilities are reported as XSS for WordPress’ plugins and themes. Keeping your site up-to-date with the latest versions of plugins and themes is the first line of defense to ensure your site’s security. The second thing to do, is to deploy a strict Content Security Policy. The main problem The main problem with Content Security Policies implemented in the real world is that they are too weak to really protect your site and that many of them can be trivially bypassed by an attacker. The proposed solution Google researchers recommend, instead of whole host whitelisting, to activate individual scripts via a CSP nonces approach. In addition, in order to facilitate the adoption of nonce-based CSP, they proposed the ’strict-dynamic’ keyword. The problem(s) with CSP in WordPress Manual creation of a policy Usually, a WordPress project is a mix of code written by different authors who contributed to the Core and or wrote plugins and themes. If it is possible to whitelist every external script loaded from a , the real truth is that in a WordPress project you can have dozens of those scripts included with your plugins and calculate a cryptographic hash for each of them to be included in your CSP header can be a frustrating job. However, there are many browser extensions and WordPress’ plugins that can help you in this job. Inline scripts WordPress core, and plugins, use inline scripts. For these scripts, you can compute hashes to be inserted manually into your policy, only if these scripts do not change at any page load. Unfortunately, this is not very common, as it is frequent to include variable values calculated server side in inline scripts. And it means that your inline scripts change too frequently to manually add their hashes to your policy. This commonly happens when scripts are “localized”. WordPress has no API to implement nonces for CSP Even if it is easy to generate a nonce for each page view, this nonce has to be inserted in every script tag used to embed inline scripts in your page as doWhatever(); and in your script-src directive: script-src 'nonce-rAnd0m'; And, of course, a nonce must be unique for each HTTP response. Unsafe hashes / Inline styles Sometimes, HTML elements as images or buttons use HTML Event Attributes (onclick, onsubmit…) to let events trigger actions in a browser. You cannot use hashes or nonces for script included in event attributes and, adopting a strict CSP, requires refactoring those patterns into safer alternatives or to use ‘unsafe-hashes’. You got a similar problem when inline styles are used in HTML tags: This is a heading This is a paragraph. CSP Level 2 browsers may be ok with just putting the hash in your style-src directive. However, to allow hashes in the style attribute on inline CSS on browsers that support CSP Level 3, you may get an error like this Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' 'sha256-nMxMqdZhkHxz5vAuW/PAoLvECzzsmeAxD/BNwG15HuA='". Either the 'unsafe-inline' keyword, a hash ('sha256-nMxMqdZhkHxz5vAuW/PAoLvECzzsmeAxD/BNwG15HuA='), or a nonce ('nonce-...') is required to enable inline execution. To allow inline styles you need to use ‘unsafe-hashes’ in your style-src directive (that is, in facts, unsafe). ^ This plugin approach This plugin affords those problems in this way: During a capture phase, it detects the scripts, styles and other embedded content present in the pages of your site and stores them in the database. Then you have to whitelist these contents from plugin admin. The plugin uses machine learning to cluster inline scripts trying to aggregate scripts generated by the same server side (PHP) code. So, you can authorize one script example to authorize all scripts that the classifier predicts to label as whitelisted clusters. You can choose to use hashes to authorize external scripts (and the plugin will allow you to include Subresource Integrity in your and ) You can use hashes or nonces to authorize inline scripts. You can ask the plugin to refactor your page to not use event attributes (converted in a inline script) and inline styles (converted in an internal CSS). You can set one or more violations’ report endpoints. The plugin supports multisite installations and has (too) many options documented in inline help. Creating a Content Security Policy After plugin activation, go to Settings menu and search for CSP Settings submenu. The steps you are supposed to do are the following. From the Tools tab, activate the capture of the tags and use your site by visiting all the pages or having your users visit them for a long time long period based on the use of your site (hours or days). From the Tools tab, perform the data clustering in the database (it can use many server resources). Go to the Base rules tab and include in the CSP directives the desired values (help you with the table at the bottom of the page). Go to the external scripts tab, inline scripts tab and scripts invoked by event handlers tab and authorize the execution of all the legitimate scripts present on the pages of your site. Leaving the tag capture active, activate the policy test (at this stage the plugin will generate some violations of the temporary policy used to record additional values to be included in the directives of your “content security policy”). After visiting again your site pages, disable the capture of the tags and repeat the previous steps 2, 3 and 4. Enable site protection. N.B. When you update plugins or themes, if something doesn’t work properly on your site pages, temporarily deactivate the protection and repeat steps 1 to 7. Plugin hooks Filters nunil_output_csp_headers_header_csp nunil_output_csp_headers_header_csp is available since version 1.2.3 and can be used to modify the Content-Security-Policy header before it is sent to browser no_unsafe_inline_not_sri_sources no_unsafe_inline_not_sri_sources can be used to modify the list of external resources that do not support SRI (Subresource Integrity) no_unsafe_inline_final_output no_unsafe_inline_final_output is an internal filter used to manipulate the output of the WordPress process just before the output is sent to the browser. no_unsafe_inline_meta_injector no_unsafe_inline_meta_injector is an internal filter hook used to inject meta http-equiv=”Content-Security-Policy” if variable is set Actions nunil_upgrade Functions hooked on nunil_upgrade will run when the plugin is upgraded nunil_output_csp_headers Functions hooked to nunil_output_csp_headers will run when the plugin output the CSP HTTP response header Code and libraries This version of the plugin uses: * to parse HTML: * ivopetkov/HTML5DOMDocument on PHP 2.13.09 * \Dom\HTMLDocument: The new ext-dom features with HTML5 support on PHP>8.4 * RubixML for machine learning from version 1.1.0 – PHP-ML was used in versions 1.0.x; * opctim/php-nilsimsa to calculate and compare Nilsimsa digests. The log functions have been taken from * perfectyorg/perfecty-push-wp, something you should really try if you want to implement web Push notifications in your site. The complete list of dependencies used in this plugin can be seen in dependency graph on GitHub. Contributions, Issues, Bugs Plugin code is hosted on a public repository on GitHub. Reach me over there to help and suggest.
Top keywords
- inline23×1.74%
- scripts21×1.59%
- csp18×1.36%
- policy11×0.83%
- site11×0.83%
- output9×0.68%
- security9×0.68%
- content8×0.61%
- inline scripts8×0.61%
- unsafe8×0.61%
- wordpress8×0.61%
- hashes7×0.53%
WPForms – AI Form Builder for WordPress – Contact Forms, Payment Forms, Survey Form, Quiz & More
WordPress Contact Form Builder Plugin WPForms is an AI drag & drop WordPress form builder that’s EASY and POWERFUL. Create contact forms, feedback forms, subscription forms, payment forms (including Stripe, Square & PayPal), and other types of forms for your site in minutes with just a few clicks! At WPForms, user experience is our #1 priority. Our pre-built form templates and workflows make WPForms the most beginner-friendly contact form plugin on the market. You don’t have to hire a developer. Create a form in less than 5 minutes with our drag & drop form builder, using a template or just asking AI to get a head start. WPForms Pro This plugin is the Lite version of WPForms Pro, which comes with email subscription forms, multi-page contact forms, file uploads, conditional logic, and extra payment integrations. Click here to purchase the best premium WordPress contact form plugin now! AI-Powered Drag & Drop Contact Form Builder Create custom contact forms in minutes with our easy-to-use drag and drop online form builder or just ask AI to build it for you. But don’t just take our word for it. See what WordPress experts are saying: WPForms is by far the easiest form plugin to use. My clients love WPForms and it’s one of the few plugins they can use without any training. As a developer I appreciate how fast, modern, clean and extensible it is. Bill Erickson – Expert WordPress Consultant Pre-built Form Templates WPForms comes with 2100+ pre-built form templates. Whether you’re looking to create a simple contact form, marketing form, request a quote form, donation form, payment order form, registration form, survey form, quiz form, Stripe payment form, or a subscription form, we have a form template already prepared and ready to use. Mobile Ready, SEO Friendly, and Optimized for Speed WPForms contact forms are 100% responsive and mobile-friendly. We optimized every query on the frontend and the backend to ensure that it’s one of the fastest WordPress contact form plugins. You can embed your contact form on any page with an optimized title and description, so WPForms is one of the most SEO friendly contact form plugins too. Fields & Features You Need to Succeed With star ratings, file uploads, repeater fields, survey fields, and multi-page contact forms, you can easily build the right custom form for your site’s needs. Plus, integrate your contact forms with an email marketing service in just a few steps and collect payments with Stripe, PayPal, and Square for bookings and orders without the need for a dedicated eCommerce plugin. See what one business owner has to say about their WPForms contact form: As a business owner, time is my most valuable asset. WPForms allows me to create smart contact forms with just a few clicks. With their pre-built form templates and the drag & drop builder, I can create a new form that works in less than 2 minutes without writing a single line of code. Well worth the investment. David Henzel – Co-founder of MaxCDN Surveys & Polls Create custom survey forms like Survey Monkey. Our WordPress survey plugin addon comes with smart survey fields including Likert scale, star ratings, and NPS. Embed your surveys and polls anywhere in WordPress. Use our survey reporting tools to customize graphs, export them for presentations, and display aggregate results. You can also share poll results instantly when collecting votes. Default WordPress Forms Aside from building simple contact forms, WPForms also helps you create better default WordPress forms, like custom WordPress login forms and custom WordPress user registration forms. Create a password-protected contact form or even a members-only contact form. Bloggers and publishers can use our WordPress post submission forms to accept guest posts, testimonials, and more. Payment Forms, Donation Forms, Booking Forms, and More While WPForms started out as a contact form plugin, it has evolved into a powerful custom forms solution for any type of payment or booking form. WPForms integrates with PayPal, Stripe, Square Payments, Authorize.Net, and Mercado Pago so you can easily accept credit card payments or take payments via PayPal. Bonus: you can also take signatures. We’re proud to be a Stripe Verified Partner. This partnership allows us to build the best Stripe integration with early access to features. You can use our Stripe integration to accept both one-time payments as well as recurring payments while syncing all form data to your Stripe account. Custom Calculator Forms Using the WPForms Calculations addon, you can build custom formulas and display results on the frontend. Create simple arithmetic calculations or build complex conditional calculations with rounded values, averages, time ranges, and more! It’s the best calculator plugin for WordPress. Forms Optimized for Conversions With our Form Pages addon, you can create distraction-free custom form landing pages to increase conversions. To improve form completion rates, we created Conversational Forms which helps you make your feedback forms feel more human by adding an interactive layout. (See Conversational Forms Demo). Easy to Customize and Extend You can easily customize your contact forms with our section dividers, HTML blocks, and CSS. Embedding forms in Elementor and Divi has never been easier thanks to our native integrations. We also know that our developer friends may want more control, so we added tons of hooks and filters. Full WPForms Feature List Online form builder – powerful drag & drop contact form builder. Create WordPress contact forms, payment forms, and other online forms without writing any code. 100% mobile responsive. GDPR friendly. Payment Forms – Take payments, donations, down payments, recurring payments, service payments with our Stripe (FREE) integration. Form templates pre-built and ready to import. Form styling for fields, labels, and buttons. Spam protection built in, plus integrations with hCaptcha, Google reCAPTCHA, and Cloudflare Turnstile. AI Forms to automatically create and refine forms through natural conversation. Instant form notifications via email. Custom form confirmations with success messages or thank you pages. Smart phone field that adapts to your visitor’s location. AI Choices to automatically populate Multiple Choice, Checkboxes, and Dropdown field options. Coupons for free shipping and sale discounts. Calculator forms for payment, shipping, billing, and more. File upload fields for user submissions. Multi-page forms with progress bars. Smart conditional logic to show or hide fields. Repeater field that enables the person filling out the form to easily add another field or group of fields to fill out. Perfect for group registration forms, custom order forms, and more. Signatures for agreements or payment forms. User registration forms and custom login forms. Post submission forms to collect user-generated content. Geolocation to collect location data along with submissions. Surveys and Polls with interactive reports. Quizzes with graded tests, personality quizzes, and scored assessments, plus AI-generated questions. Form abandonment detection to collect partial form submissions. Form locker to control access using passwords, dates, and more. Offline forms to collect submissions without an internet connection. Form landing pages to boost conversions. Conversational forms to boost overall completion rates. Lead forms to get more submissions with multi-step layouts. Webhooks to send data without third party connectors. User Journey reports so you know which content is driving form conversions. Save and Resume to let visitors save and come back later. Entry Automation to export and delete form entries on a daily, weekly, or monthly basis. Integrations Google Sheets Zapier PayPal Commerce Stripe – We’re a Stripe Verified Partner for Payments. Square Authorize.Net Mercado Pago Mailchimp AWeber Campaign Monitor GetResponse Constant Contact Airtable Notion Drip ActiveCampaign HubSpot Brevo MailerLite MailPoet ConvertKit Klaviyo SendGrid Salesforce Slack Dropbox Google Calendar Google Drive Twilio Pipedrive Make Zoho CRM You can see why WPForms is the best WordPress contact form plugin on the market! Want to unlock these features? Upgrade to our Pro version. Credits This plugin is created by Syed Balkhi. Branding Guidelines WPForms® is a registered trademark of WPForms LLC. When writing about the contact form plugin by WPForms, please make sure to uppercase the initial 3 letters. WPForms (correct) WP Forms (incorrect) wpforms (incorrect) wpform (incorrect) Notes WPForms is absolutely, positively the most beginner-friendly WordPress contact form plugin on the market. It is both easy and powerful. We took the pain out of creating online forms and made it easy. Check out all WPForms features. Also, I’m the founder of WPBeginner, the largest WordPress resource site for beginners. It was a huge priority for me to make a WordPress contact form plugin that beginners can use without any training. I feel that we have done that here. I hope you enjoy using WPForms. Thank you, Syed Balkhi