# Inline javascript event handles interfere with CSP

**URL:** <https://community.gravityforms.com/t/inline-javascript-event-handles-interfere-with-csp/15283>\
**Category:** Get Help\
**Tags:** custom, javascript, csp, unsafe-inline\
**Created:** [June 6, 2023, 1:57pm UTC](https://community.gravityforms.com/t/inline-javascript-event-handles-interfere-with-csp/15283 "2023-06-06T13:57:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![crawford](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@crawford](https://community.gravityforms.com/u/crawford)\
**Post date:** [June 6, 2023, 1:57pm UTC](https://community.gravityforms.com/t/inline-javascript-event-handles-interfere-with-csp/15283/1 "2023-06-06T13:57:29Z")

</div>

Gravity Forms seem to always have inline event handlers - is there anyway to make these not inline? Otherwise we need to add “unsafe-inline” to our CSP or create hashes for every bit of inline js that GF creates…

This has been asked before without any answer but I would assume will become more of an issue with more security awareness and stricter CSPs…

TIA

---

<div class="post-metadata">

**Author:** ![AeroStar](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/aerostar/32/15243_2.png) [@AeroStar](https://community.gravityforms.com/u/AeroStar)\
**Post date:** [June 14, 2023, 1:29pm UTC](https://community.gravityforms.com/t/inline-javascript-event-handles-interfere-with-csp/15283/2 "2023-06-14T13:29:13Z")

</div>

Hey @crawford ,

Good point. We are using the following htaccess rule with no issues:

```auto
Header set Content-Security-Policy "img-src * 'self' data: https:; base-uri 'self' data: https:; object-src 'none'; upgrade-insecure-requests"

```

Also, we have found [this particular site header checker](https://securityheaders.com/) useful in identifying security header issues.

Last, we are using the plugin [Perfmatters](https://perfmatters.io/) (MU Mode), to remove assets (inline JS and CSS files) from pages that do not contain a Gravity Form.

Not sure this is what you’re looking for, but hopefully, will help you a bit.

Cheers!

---

<div class="post-metadata">

**Author:** ![smeedijzer](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@smeedijzer](https://community.gravityforms.com/u/smeedijzer)\
**Post date:** [June 15, 2023, 12:04pm UTC](https://community.gravityforms.com/t/inline-javascript-event-handles-interfere-with-csp/15283/3 "2023-06-15T12:04:17Z")

</div>

@crawford

In short: no there’s no way (without using other plugins/code that filter inline JS).

I asked the same question to support a while ago and submitted it to the roadmap page (but **not** added to the list by GF). It seems this security issue has no priority at all…

Here the conversation:

Me:

> Gravity Forms adds inline scripts to e.g. the submit button (see below). This makes it impossible to set a Content Security Policy without ‘unsafe-inline’. What can I do to use GF with a CSP without using ‘unsafe-inline’? And are there plans to move inline Javascript to files?
> 
> `<input type="submit" id="gform_submit_button_135" class="gform_button button gfcom-btn gfcom-btn--dark" value="Submit" onclick="if(window["gf_submitting_135"]){return false;} if( !jQuery("#gform_135")[0].checkValidity || jQuery("#gform_135")[0].checkValidity()){window["gf_submitting_135"]=true;} " onkeypress="if( event.keyCode == 13 ){ if(window["gf_submitting_135"]){return false;} if( !jQuery("#gform_135")[0].checkValidity || jQuery("#gform_135")[0].checkValidity()){window["gf_submitting_135"]=true;} jQuery("#gform_135").trigger("submit",[true]); }">`

Support:

> You can suggest adding CSP support directly to our product management team for consideration when planning future releases on our roadmap page at [https://www.gravityforms.com/gravity-forms-roadmap/?c=submit-idea](https://www.gravityforms.com/gravity-forms-roadmap/?c=submit-idea)

Me:

> So right now it’s not possible to use GF with a CSP without using ‘unsafe-inline’? And what about [https://docs.gravityforms.com/security/#h-content-security-policy](https://docs.gravityforms.com/security/#h-content-security-policy)?

Support:

> The filter mentioned in that article only applies tags output in the page header. CSP is not supported for the form specific inline scripts.

---

<div class="post-metadata">

**Author:** ![crawford](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@crawford](https://community.gravityforms.com/u/crawford)\
**Post date:** [June 15, 2023, 12:38pm UTC](https://community.gravityforms.com/t/inline-javascript-event-handles-interfere-with-csp/15283/4 "2023-06-15T12:38:27Z")

</div>

@smeedijzer Thanks for the reply!

it’s a real issue - I see more clients looking to tighten up their CSPs and in this case it’s going to mean we have to move away from GF as there is no solution…

---

<div class="post-metadata">

**Author:** ![robbertrosario](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@robbertrosario](https://community.gravityforms.com/u/robbertrosario)\
**Post date:** [June 19, 2023, 7:45am UTC](https://community.gravityforms.com/t/inline-javascript-event-handles-interfere-with-csp/15283/5 "2023-06-19T07:45:09Z")

</div>

We face the same problem…

I contacted them with this issue before and submitted a roadmap idea, but so far it hasn’t even moved to the roadmap. I don’t think they get how important this is, because we will have to discontinue using Gravity Forms for a couple of (big) clients as well, if there is no solution soon.

Maybe losing some subscribers doesn’t make a dent overall but if it were up to me I would want to keep those big customers who’s priority it is to abide to CSP because they are your showpiece.

---

<div class="post-metadata">

**Author:** ![robbertrosario](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@robbertrosario](https://community.gravityforms.com/u/robbertrosario)\
**Post date:** [June 26, 2023, 8:15am UTC](https://community.gravityforms.com/t/inline-javascript-event-handles-interfere-with-csp/15283/6 "2023-06-26T08:15:40Z")

</div>

Maybe someone from the Gravity Forms team can shed some light on this? I know the recommended way is to file a roadmap idea, but since there is no feedback on this and apparently multiple parties are asking, I am wondering if this even has a chance of being applied.

Is the demand not high enough?

---

<div class="post-metadata">

**Author:** ![smeedijzer](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@smeedijzer](https://community.gravityforms.com/u/smeedijzer)\
**Post date:** [July 9, 2023, 11:42am UTC](https://community.gravityforms.com/t/inline-javascript-event-handles-interfere-with-csp/15283/7 "2023-07-09T11:42:57Z")

</div>

I really don’t understand why security isn’t priority number 1 at Gravity Forms. It feels like they are ignoring the issue by not responding to this thread…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [August 8, 2023, 11:43am UTC](https://community.gravityforms.com/t/inline-javascript-event-handles-interfere-with-csp/15283/8 "2023-08-08T11:43:32Z")

</div>

Closed on August 8, 2023, 11:43am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
