Last active
August 29, 2015 14:16
-
-
Save JamoCA/4387922b49181c01bcb7 to your computer and use it in GitHub Desktop.
Sample ColdFusion 9+ script to prevent Fallback Scope Injection. URL & Form variables are universally accessible in the scope & used as fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- Sample ColdFusion 9+ script to prevent Fallback Scope Injection. URL & Form variables are universally accessible in the scope & used as fallback. | |
Based on insights provided by Peter Freitag's blog post http://www.petefreitag.com/item/834.cfm ---> | |
<cfscript> | |
Scopes = "arguments,local,thread,variables,cgi,cookie,client,request,application,session,server,caller,thistag,this"; | |
for (thisField in Form) { | |
if (ListLen(thisField,".") GT 1 AND ListFindNocase(Scopes, trim(ListFirst(ThisField,".")))){ | |
StructDelete(Form, thisField); | |
if (ListFindnocase(Form.Fieldnames, ThisField)){ | |
Form.Fieldnames = ListDeleteAt(Form.Fieldnames, ListFindnocase(Form.Fieldnames, ThisField)); | |
} | |
} | |
} | |
for (thisField in URL) { | |
if (ListLen(thisField,".") GT 1 AND ListFindNocase(Scopes, trim(ListFirst(ThisField,".")))){ | |
StructDelete(URL, thisField); | |
} | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment