Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for areBracesValid UDF for ColdFusion/CFML
James Moberg
James Moberg

Posted on

areBracesValid UDF for ColdFusion/CFML

Useful to determine if braces are correctly matched before processing. Helps reduce SQLi.

I was using a version ofsmartSearch fromCFLib.org that I had updated with some simple regex detection forSQLi strings, but it wasn't catching everything. I considered disabling thebracket matching feature and rejecting any query search terms that attempted to use( or), but then considered that I should validate so that the feature could still be used since it is beneficial when not being exploited.

I couldn't find any UDFs on CFLib or other ColdFusion/CFML snippets to validate brackets in a string.(If there's existing code, let me know. I wasn't able to find it.) I read a couple recommendations on StackOverflow indicating that it shouldn't be validated using regex, so I wrote a UDF that reduces & validates braces in a string and returns a Boolean response. This allows us to determine whether we can safely use the string when generating a SQL search string (or use1=0 as a fallback).

Source Code

https://gist.github.com/JamoCA/a35ffaabc00e0339a9996e27825159a7

Top comments(3)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
bennadel profile image
Ben Nadel
  • Location
    Rhinebeck, NY
  • Joined

I was about to ask if you were usingcfqueryparam for your search; but, I just looked at the Smart Search UDF, and it looks like it uses some SQL generation, which somewhat rules-out the parameterization.

CollapseExpand
 
gamesover profile image
James Moberg
I’m a ColdFusion/CFML web application developer at SunStar Media located in Monterey, CA. I am a fan of technology, music and web development.
  • Location
    Monterey, CA
  • Work
    Web Applications Developer
  • Joined

I use an internally updated version of SmartSearch. I've added logic to identify SQLi and return1=0 if any is detected. (I'm planning on sharing my UDF updates, but will be releasing it on a new CFML resource website that I'm building.)

CollapseExpand
 
bennadel profile image
Ben Nadel
  • Location
    Rhinebeck, NY
  • Joined

Sounds exciting! Looking forward to seeing what you've got in store.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I’m a ColdFusion/CFML web application developer at SunStar Media located in Monterey, CA. I am a fan of technology, music and web development.
  • Location
    Monterey, CA
  • Work
    Web Applications Developer
  • Joined

More fromJames Moberg

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp