-
-
Save ivanionut/7c3b0339a6020470b7e6 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