Entries Tagged as “web application security”

Security Enhancements in ColdFusion Splendor - PBKDF2 and AntiSamy

April 07, 2014 / Pavankumar

  Security | ColdFusion 11 | Splendor | web application security

ColdFusion 11 added few more security functions to the rich set of coldfusion security functions. Some of them includes protection against XSS using AntiSamy framework, PBKDF2 key derivation etc. In this blog post we will introduce you to the Antisamy and PBKDF2 key derivation functions added in coldfusion Splendor.

AntiSamy Support:

If there is a need to accept HTML/CSS input from the user then there is high possibility that the input containing XSS. In this case We can not use encoding functions as the HTML/CSS as the input need to be rendered by the browser. AntiSamy API provides an input validation technique which helps programmer to verify user-driven HTML/CSS input markup using a whitelist policy to ensure the input does not contain XSS. Antisamy validates using a policy file in which we can specify which HTML tags, attributes, css properties are allowed in the given input. The policy gives us more control on input validation/sanitization by providing directives,  regular expressions, rules for htmt tags and css properties . AntiSamy provides some example policy files which can be downloaded from here. They can be modified to suit your own project requirements. Check AntiSamy developer guide to know more about policy files.

Two new functions isSafeHTML and getSafeHTML were added which validates and cleans the given unsafe html as per the given policy.

isSafeHTML can be used to know whether the given input markup is in accordance with the rules specified in the antisamy policy. Returns true if valid else false if any violations are found.

getSafeHTML sanitizes the given input based on the the rules specified in an antisamy policy file. Returns cleanHTML string by cleaning the input against the defined policy.

The function syntax as below:

getSafeHTML(input [, PolicyFile ], throwOnError])
isSafeHTML(input [, PolicyFile ])
where

input      The HTML input markup text to sanitize/validate.

PolicyFile (Optional)      Specify the path to the AntiSamy policy file. Given path can be an absolute path or a relative to the Application.cfc/cfc.Given path can be an absolute path or a relative to the Application.cfc/cfc.In case if not specified, there is a provision to set this at application level. Else the default policy file shipped with ColdFusion will be used. Default policy antisamybasic.xml can be found in the lib directory.

throwOnError (Optional)       If set to true and given input violates the allowed HTML rules specified in the policy file an exception will be thrown. The exception message contains the list of violations raised because of the input. If set to false ignores the exception returns the HTML content filtered, cleaned according to the policy rules. Defaults to false.

Policy file can be set at application level using the key this.security.antisamypolicy in Application.cfc. The value must be an absolute path to the policy file or relative to the Application.cfc/cfm.

<cfcomponent>
<cfset this.security.antisamypolicy = "antisamy.xml">
</cfcomponent>

Here is a simple example which uses antisamy-tinymce.xml policy which allows many text formatting tags ,simple css properties and disallows javascript.

<!--- I am just using static input in this example when using this replace it with the relevant form parameter --->
<cfset unsafeHTML = "<script>alert('lorem ipsum lorem ipsum');</script><b>lorem ipsum lorem ipsum</b>">
<cfset isSafe = isSafeHTML(unsafeHTML)>
<cfset SafeHTML = getSafeHTML(unsafeHTML , "", false)>
 
<!--- returns No and provides the clean html as <b>lorem ipsum lorem ipsum</b> removes script from input  --->
<cfoutput> is Safe : #isSafe# Safe HTML : #SafeHTML# </cfoutput>
<cftry>
    <cfset SafeHTML = getSafeHTML(unsafeHTML , "", true)>
<cfcatch type="Application">
<!--- if throwOnError is true get the erros as specified below --->
<cfoutput>
    Errors in the input: <br/> #cfcatch.detail#
</cfoutput>
</cfcatch>
</cftry>

More detailed information and examples on antisamy can be found from here.

PBKDF2 Key Derivation:

PBKDF2 (Password based key derivation function) is a key derivation function which can be used to derive a cryptographic random key of desired key size from the humany-manageable passwords. PBKDF2 is widely used for generating random cryptography keys which can be used as key to encryption and HMAC algorithms. The function syntax as below

GeneratePBKDFKey(algorithm, inputString, salt, iterations, keysize)

algorithm
The encryption algorithm used to generate the encryption key. Supported algorithms are PBKDF2WithHmacSHA1, PBKDF2WithSHA1, PBKDF2WithSHA224,  PBKDF2WithSHA256,PBKDF2WithSHA384, PBKDF2WithSHA512.

inputString
Specify the input string (password/pass-phrase) which will be used for deriving the encryption key.

salt
Random cryptographic salt. Recommended length is 64 bits (8 characters) and must be randomly generated using a pseudo random number generator.

iterations
Desired Number of Iterations to perform the cryptographic operation. The minimum recommended number of iterations is 1000.

keySize
Desired arbitrary key length size in bits.

Below example shows how to derive a 192 bit encryption key from the given password. Then we are using key to encrypt and decrypt the data using AES algorithm. No need to store the encryption key as it will be derived from the password.

salt="A41n9t0Q";
        <!--- hard coding the password but in real password should be from some form parameter ---> 
	password = "Password@123";
	PBKDFalgorithm = "PBKDF2WithSHA224";
	dataToEncrypt= "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua";
	encryptionAlgorithm = "AES";
	derivedKey = GeneratePBKDFKey(PBKDFalgorithm ,password ,salt,4096,192);
	writeOutput("Generated PBKDFKey (Base 64) : " & derivedKey);
	encryptedData = encrypt(dataToEncrypt, derivedKey, encryptionAlgorithm, "BASE64");
	writeoutput("Data After Encryption: " & encryptedData);

        
	salt="A41n9t0Q";
	password = "Password@123";
	PBEalgorithm = "PBKDF2WithSHA224";
	derivedKey = GeneratePBKDFKey(PBKDFalgorithm ,password ,salt,4096,192);
	decryptedData = decrypt(encryptedData, derivedKey, encryptionAlgorithm, "BASE64");
	writeoutput("Data After Decryption: " & decryptedData);


More information and examples on PBKDF2 can be found from here.


Public Beta for ColdFusion and ColdFusion Builder is now available!

February 19, 2014 / Rakshith Naresh

  Performance | Thunder | Adobe ColdFusion | Mobile | productivity | Rapid Application Development | Splendor | web application development | web application security

In case you haven't already noticed,the public beta for the major version of ColdFusion codenamed Splendor and for the next major version of ColdFusion Builder Thunder is now available.

Here is where you can get access to the public beta for both the products on Adobe Labs - http://labs.adobe.com/technologies/coldfusion/

You can quickly go over what's new in ColdFusion Splendor here. There are also a couple of videos on the video tab that gives you a quick introduction to what's new in ColdFusion. The link for the documentation home page is at - https://wikidocs.adobe.com/wiki/display/coldfusionen/Home

There are lots of new features and enhancements in Splendor and in Thunder. We look forward to hearing your feedback during the public beta.

 

 

 

 


trycf.com - Excellent learning initiative for ColdFusion

December 23, 2013 / Rakshith Naresh

  Adobe ColdFusion | Announcements | web application development | web application security

trycf.com is a new learning initiative by Abram Adams. The idea of the portal is to offer tutorials for new or beginner level ColdFusion developers with interactive tutorials using which you can type in CFML code on the browser and see the results live! This is a great way to quickly learn the CFML programming without having to download ColdFusion. 

What's more, Abram Adams also has a contest running right now where the you, the ColdFusion community, can help take this initiative to the next levels by submitting tutorials that thousands of other developers can use to learn. The process of submitting the turorials for the contest is simple and is outlined here. The top entry in the contest will receive $300 and every valid entry will receive a copy of ColdFusion Builder! Submit your turotials now!

learncfinaweek.com, again a community driven initiative, is already a popular resource for learning the basics of ColdFusion in just a week's time. I am confident that trycf.com too will turn out to be an excellent learning resource for CF developers.

 

 


New Security Update Available for ColdFusion 9.0, 9.0.1, 9.0.2 and 10

November 12, 2013 / Pavankumar

  Security | Adobe ColdFusion | Adobe ColdFusion 10 | Announcements | Hotfix | Updates | web application security

New security update is available for coldfusion versions 9.0, 9.0.1, 9.0.2 and 10.0. This hotfix addresses the security issues specified in the technote here. Here is the link to the security bulletin for this hotfix. It also includes few important bug fixes for coldfusion 10 as specified here.

We recommend locking down your server by following the lock down guide and disable unused features in the production environments. 


ColdFusion case study: ITRX Corp.

November 04, 2013 / Rakshith Naresh

  Administrator | Adobe ColdFusion 10 | web application | web application development | web application security

One of the world’s leading open-source research websites was experiencing performance issues because increasing volumes of data were taxing the system’s available memory. To solve the problem, the Social Science Research Network (SSRN) called on ITX Corp., an IT solutions provider. ITX rebuilt the site using Adobe ColdFusion, which helped eliminate memory problems, cut development times through the reuse of modularized code, and streamline SSRN’s web technology infrastructure.

 

“Not only did the upgrade to 64-bit Adobe Cold Fusion help stop server crashes, it also helped reduce the number of servers SSRN needs to run its site,” says Fernando D’Agostino, lead architect at ITX. “Previously, SSRN had 14 servers. Now it has 8, which reduces costs associated with server purchases, maintenance, and support.”  http://adobe.ly/19XDRHf


Blue Mango Theme Design By Mark Aplet

Super Powered by Mango Blog