Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Protect a form submit cfm page

Enthusiast ,
Jan 26, 2012 Jan 26, 2012

How else to I protect a form submit cfm page to make sure the request only comes from pages in my own site?

So far I have this

<cfif Not cgi.REQUEST_METHOD eq "POST">

  <cflocation url="../index.cfm" addtoken="no">

</cfif>

TOPICS
Advanced techniques
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Jan 26, 2012 Jan 26, 2012

We do the following in our application.cfm:

<cfif isDefined("FORM.fieldNames") and len(FORM.fieldNames) and NOT reFindNoCase("^(http|https)://#CGI.HTTP_HOST#/",CGI.HTTP_REFERER)>

  <cfabort showerror="Forbidden Request - POST request denied.">

</cfif>

Translate
Guide ,
Jan 26, 2012 Jan 26, 2012

I don't believe you can. You can check the CGI.HTTP_REFERRER value, but that is easily spoofed if someone is looking to post to your page. CFCaptcha might be worth a look though. Care to elaborate on the problem?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 26, 2012 Jan 26, 2012

I basically only want people to post here if they have been authenticated users

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jan 26, 2012 Jan 26, 2012

Then in your application.cfc's onRequestStart() method, you need to check authentication. If they're not authenticated do a redirect to a failure page or return a 403 response. As long as all that happens in onRequestStart(), the page will never be processed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 26, 2012 Jan 26, 2012

We do the following in our application.cfm:

<cfif isDefined("FORM.fieldNames") and len(FORM.fieldNames) and NOT reFindNoCase("^(http|https)://#CGI.HTTP_HOST#/",CGI.HTTP_REFERER)>

  <cfabort showerror="Forbidden Request - POST request denied.">

</cfif>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 27, 2012 Jan 27, 2012
LATEST

Steve and Owains answers are great!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources