Copy link to clipboard
Copied
Hi, we are looking into better XSS (Cross-site scripting) prevention.
Does anyone have other recommendations? I couldn't find any recent posts about this in these forums.
Yes, check out the encodeForHTML, and other functions starting with encodeFor. I wrote up a guide to XSS in ColdFusion here which goes into detail.
Beyond that - script protect is a trivial protection, I wouldn't rely on it for doing too much - there are many many ways around it.
The getSafeHTML function is also a good function, but it is best for cases when you know you have some legitimate HTML in the variable. If you shouldn't have HTML in a variable, (eg: name, phone number, etc) then use en
...Copy link to clipboard
Copied
Yes, check out the encodeForHTML, and other functions starting with encodeFor. I wrote up a guide to XSS in ColdFusion here which goes into detail.
Beyond that - script protect is a trivial protection, I wouldn't rely on it for doing too much - there are many many ways around it.
The getSafeHTML function is also a good function, but it is best for cases when you know you have some legitimate HTML in the variable. If you shouldn't have HTML in a variable, (eg: name, phone number, etc) then use encodeForHTML instead.
Finally, great job adding cfqueryparam, but that is not going to help you with XSS, but it will help you with SQL Injection.
Copy link to clipboard
Copied
Thanks for reply, and that guide is very clear! I think there a small typo under the explanation of encodeForHTMLAttribute() though... the example uses encodeForHTML(). I think it's supposed to be encodeForHTMLAttribute().
Copy link to clipboard
Copied
Thanks Tim - good catch - I have fixed that
Find more inspiration, events, and resources on the new Adobe Community
Explore Now