Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7800045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:30:25+00:00 2026-06-02T00:30:25+00:00

I am trying to improve my application’s security. Whenever I receive data from the

  • 0

I am trying to improve my application’s security. Whenever I receive data from the user (whether through POST or GET) that is supposed to be an integer, I validate that appropriately. But often the data is VARCHAR, and sometimes can contain HTML.

How do I protect my DB from SQL injection in that case?

Does <cfqueryparam value="#form.textInput#" cfsqltype="cf_sql_varchar"> protect the query from sending a malicious SQL statement inside a VARCHAR value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:30:27+00:00Added an answer on June 2, 2026 at 12:30 am

    The short answer to your question is ‘yes’.

    I block hacking attempts using three methods.

    1. I use cfqueryparam in all my database queries. I will use cfparam at the top of the template/cfm files for url scope variables.

    2. I have used Portcullis or variants of it. You can get it from http://portcullis.riaforge.org/. Portcullis will also defend against some cross site scripting attacks.

    3. I use Windows IIS 7.5 (Windows Server 2008 R2). I use the URL Rewrite feature to block the bulk of URL based attacks. You can do similar things with Apache and the rewrite that it supports. Here are my IIS URL Rewrite rules:

      <?xml version="1.0" encoding="UTF-8"?>
      <appcmd>
          <CONFIG CONFIG.SECTION="system.webServer/rewrite/globalRules" path="MACHINE/WEBROOT/APPHOST" overrideMode="Inherit" locked="false">
              <system.webServer-rewrite-globalRules>
                  <rule name="SQL Injection - EXEC - SCRIPT_NAME" stopProcessing="true">
                      <match url="^.*EXEC\s*[\(|%28].*$" />
                      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                      </conditions>
                      <serverVariables>
                      </serverVariables>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                  </rule>
                  <rule name="SQL Injection - EXEC - QS" stopProcessing="true">
                      <match url=".*" />
                      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                          <add input="{QUERY_STRING}" pattern="^.*EXEC\s*[\(|%28].*$" />
                      </conditions>
                      <serverVariables>
                      </serverVariables>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                  </rule>
                  <rule name="SQL Injection - CAST - SCRIPT_NAME" stopProcessing="true">
                      <match url="^.*CAST\s*[\(|%28].*$" />
                      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                      </conditions>
                      <serverVariables>
                      </serverVariables>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                  </rule>
                  <rule name="SQL Injection - CAST - QS" stopProcessing="true">
                      <match url=".*" />
                      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                          <add input="{QUERY_STRING}" pattern="^.*CAST\s*[\(|%28].*$" />
                      </conditions>
                      <serverVariables>
                      </serverVariables>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                  </rule>
                  <rule name="SQL Injection - DECLARE - SCRIPT_NAME" stopProcessing="true">
                      <match url="^.*DECLARE.*$" />
                      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                      </conditions>
                      <serverVariables>
                      </serverVariables>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                  </rule>
                  <rule name="SQL Injection - DECLARE - QS" stopProcessing="true">
                      <match url=".*" />
                      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                          <add input="{QUERY_STRING}" pattern="^.*DECLARE.*$" />
                      </conditions>
                      <serverVariables>
                      </serverVariables>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                  </rule>
                  <rule name="SQL Injection - NVARCHAR - SCRIPT_NAME" stopProcessing="true">
                      <match url="^.*CHAR\s*[\(|%28].*$" />
                      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                      </conditions>
                      <serverVariables>
                      </serverVariables>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                  </rule>
                  <rule name="SQL Injection - NVARCHAR - QS" stopProcessing="true">
                      <match url=".*" />
                      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                          <add input="{QUERY_STRING}" pattern="^.*CHAR\s*[\(|%28].*$" />
                      </conditions>
                      <serverVariables>
                      </serverVariables>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                  </rule>
                  <rule name="SQL Injection - sp_password - SCRIPT_NAME" stopProcessing="true">
                      <match url="^.*sp_password.*$" />
                      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                      </conditions>
                      <serverVariables>
                      </serverVariables>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                  </rule>
                  <rule name="SQL Injection - sp_password - QS" stopProcessing="true">
                      <match url=".*" />
                      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                          <add input="{QUERY_STRING}" pattern="^.*sp_password.*$" />
                      </conditions>
                      <serverVariables>
                      </serverVariables>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                  </rule>
                  <rule name="SQL Injection - xp - SCRIPT_NAME" stopProcessing="true">
                      <match url="^.*%20xp_.*$" />
                      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                      </conditions>
                      <serverVariables>
                      </serverVariables>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                  </rule>
                  <rule name="SQL Injection - xp - QS" stopProcessing="true">
                      <match url=".*" />
                      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                          <add input="{QUERY_STRING}" pattern="^.*%20xp_.*$" />
                      </conditions>
                      <serverVariables>
                      </serverVariables>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                  </rule>
              </system.webServer-rewrite-globalRules>
          </CONFIG>
      </appcmd>
      

    These rules are added to the C:\Windows\System32\inetsrv\config\applicationHost.config file for IIS. However I do ****NOT**** recommend that you directly edit this file. One mistake and IIS will not load. Instead copy & paste the rules above and save them as “iis-global-rewrite.xml”. Then run the following batch file to add the rules to your IIS server:

    C:\Windows\System32\inetsrv\appcmd.exe set config -in < iis-global-rewrite.xml
    

    The IIS rewrite rules should work with IIS 7.0 (Windows Server 2008) but I have not tested it.

    These rules could also be applied to a single site using the web.config file if you do not have access to the server.

    Why do I use three different methods for protection? Because none of them cover all the bases. The IIS rewrite rules only protect against URL based attacks. Hackers can also use form submission attacks that do the same thing. I prefer the IIS rules as a first line of protection because it will work with all sites on the server including PHP, ASP, etc. Portcullis is a good second line of defense for ColdFusion because it will catch form based attacks and some cross site scripting attacks. The last line of defense is the cfqueryparam/cfparam code which protects against URL/form based SQL injection attacks.

    If all three of these methods are used the server/site should be very secure. I would still advise reviewing server logs from time to time as attacks do evolve and improve.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to improve performance for my application, and I'd like to change from
From an earlier post about trying to improve my sites performance I have been
I'm trying to improve performance for an application that does a lot of bit
i'm trying to improve the excuting speed of my python program through py2exe…but i'm
I have an application that I am debugging and I'm trying to understand how
I am trying to improve the performance of my web-application so I decided to
I'm trying to improve the automated testing in my application, but am unsure of
I am trying to receive data using serial communication in Python, which I can
I am trying to improve the performance of a web application. I have metrics
I am trying to improve the performance of the threaded application with real-time deadlines.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.