ColdFusion Code Security Michael Smith President TeraTech, Inc ColdFusion, database & VB custom development and training. 800-447-9120.

Slides:



Advertisements
Similar presentations
Implementing Tableau Server in an Enterprise Environment
Advertisements

ATTACKING AUTHENTICATION The Web Application Hacker’s Handbook, Ch. 6 Presenter: Jie Huang 10/31/2012.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
Lesson 17: Configuring Security Policies
ColdFusion Code Security Michael Smith President TeraTech, Inc ColdFusion, database & VB custom development and training
It’s always better live. MSDN Events Security Best Practices Part 2 of 2 Reducing Vulnerabilities using Visual Studio 2008.
Online Security Tuesday April 8, 2003 Maxence Crossley.
Information Networking Security and Assurance Lab National Chung Cheng University The Ten Most Critical Web Application Security Vulnerabilities Ryan J.W.
It’s always better live. MSDN Events Securing Web Applications Part 1 of 2 Understanding Threats and Attacks.
ASP.NET 2.0 Chapter 6 Securing the ASP.NET Application.
Security in SQL Jon Holmes CIS 407 Fall Outline Surface Area Connection Strings Authenticating Permissions Data Storage Injections.
Designing Security In Web Applications Andrew Tomkowiak 10/8/2013 UW-Platteville Software Engineering Department
Web Application Vulnerabilities Checklist. EC-Council Parameter Checklist  URL request  URL encoding  Query string  Header  Cookie  Form field 
Web-based Document Management System By Group 3 Xinyi Dong Matthew Downs Joshua Ferguson Sriram Gopinath Sayan Kole.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Martin Kruliš by Martin Kruliš (v1.0)1.
CHAPTER 12 COOKIES AND SESSIONS. INTRO HTTP is a stateless technology Each page rendered by a browser is unrelated to other pages – even if they are from.
Security.NET Chapter 1. How Do Attacks Occur? Stages of attack Examples of attacker actions 1. FootprintRuns a port scan on the firewall 2. PenetrationExploits.
The Art of Debugging Shlomy Gantz 02/13/01MDCFUG.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
More on Fusebox at Fusebox Development Methodology : More on Fusebox at Fusebox Development Methodology.
© All rights reserved. Zend Technologies, Inc. PHP Security Kevin Schroeder Zend Technologies.
WaveMaker Visual AJAX Studio 4.0 Training Authentication.
Week 7 IBS 685. Displaying an Image using CFOUTPUT 1.Save images in a folder under wwwroot directory 2.Create a database column and name it e.g. imagefilename.
Web Programming Language Week 7 Dr. Ken Cosh Security, Sessions & Cookies.
SSL, Single Sign On, and External Authentication Presented By Jeff Kelley April 12, 2005.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Oracle Application Express Security. © 2009 Oracle Corporation Authentication Out-of-the-Box Pre-Configured Schemes LDAP Directory credentials Oracle.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
1 Maryland ColdFusion User Group Session Management December 2001 Michael Schuler
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
10/20/2015 ©2006 Scott Miller, University of Victoria 1 User Authentication Content Generation The Use of Cookies Content Pooling Rev 1.5.
ColdFusion Security Michael Smith President TeraTech, Inc ColdFusion, Database & VB custom development
Effective Security in ASP.Net Applications Jatin Sharma: Summer 2005.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
October 3, 2008IMI Security Symposium Application Security through a Hacker’s Eyes James Walden Northern Kentucky University
Application.cfm tips and Tricks Michael Smith President TeraTech, Inc ColdFusion, database & VB custom development and training.
By Sean Rose and Erik Hazzard.  SQL Injection is a technique that exploits security weaknesses of the database layer of an application in order to gain.
Web Database Programming Week 7 Session Management & Authentication.
Cookies and Sessions IDIA 618 Fall 2014 Bridget M. Blodgett.
MEMBERSHIP AND IDENTITY Active server pages (ASP.NET) 1 Chapter-4.
Controlling Web Site Access Using Logins CS 320. Basic Approach HTML form a php page that collects the username and password  Sends them to second PHP.
Cookies COEN 351 E-commerce Security. Client / Session Identification HTTP Headers Client IP Address HTTP User Login FAT URLs Cookies.
PHP Secure Communications Web Technologies Computing Science Thompson Rivers University.
Implementing and Using the SIRWEB Interface Setup of the CGI script and web procfile Connecting to your database using HTML Retrieving data using the CGI.
Copyright © 2006, Infinite Campus, Inc. All rights reserved. User Security Administration.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASSIGNMENT 2 Salim Malakouti. Ticketing Website  User submits tickets  Admins answer tickets or take appropriate actions.
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
1/20 1 How to become a Guru Coder Michael Smith, TeraTech, Inc x110 Copyright.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
COOKIES AND SESSIONS.
ASP.NET 2.0 Security Alex Mackman CM Group Ltd
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
Error Handling Michael Smith President TeraTech, Inc ColdFusion, Database & VB custom development
Cool CF Debugging Shlomy Gantz 07/29/01CF_ODYSSEY.
19 Copyright © 2008, Oracle. All rights reserved. Security.
ArcGIS for Server Security: Advanced
Building Secure ColdFusion Applications
Authentication & .htaccess
ColdFusion And Section 508 Michael Smith, President TeraTech, Inc
PHP: Security issues FdSc Module 109 Server side scripting and
Configuring Internet-related services
Nate Nelson I*LEVEL, Inc.
Cookies and sessions Saturday, February 23, 2019Saturday, February 23,
ColdFusion Form Handling Michael Smith, President TeraTech, Inc
Presentation transcript:

ColdFusion Code Security Michael Smith President TeraTech, Inc ColdFusion, database & VB custom development and training

Speaker Information Who am I? n Michael Smith n President of TeraTech, Inc Rockville MD u u ttWebReportServer, CFXGraphicserver n MDCFUG, CFUN-02, Fusebox Conf n Articles in CFDJ, Fusion Authority

Introduction The ColdFusion security challenge: n Keeping hackers out n While still letting users and friendly apps in n Balance security vs easy of use

ColdFusion Security Here is what we will be covering: n Error handling n Form Validation n Page parameter validation n User Authentication n Members Only n Encryption and passwords

Not covered in this talk n Server security n Database security n Hardware security n Operating system security n TeraTech’s CF201 Class covers more security topics than we can cover in an hour.

Error handling n Always have an error handler in Application.cfm n Never display default CF errors - gives out SQL information and template paths n Instead error to admin n Don’t explain why attempt failed n Standard processing time

Error handling code In Application.cfm: <CFMAIL to="#error.MailTo#" subject="ColdFusion Error"> #error.RemoteAddress# #error.Template# #error.DateTime# #error.Diagnostics#

Form Validation n Why it is important n Underscore validation n CFFORM validation n Javascript validation n CF validation n SQL validation n Fake form submits

Why is validation important? n Malicious exploits are possible n Bad data may be entered n Server crashes n Hacker can force an error message

Underscore Validation n AKA Form-level validation n Easiest to implement n Runs on the server based on this hidden parameter from the form page n Trusts the browser that the form variable is passed n Effectively client-side, although actual validation occurs on the server

CFFORM Validation n Automagically generates form-level validation and javascript validation n Works well enough in simple forms n Does not adapt well for complex forms, need for complex validation, javascript, etc. n Generally roll-your-own is preferred n Still trusts browser

Javascript Validation n Available many places u Swipe from the source code generated by CFForm u n Totally browser dependent n With CF Form, won’t even submit if javascript not present n Effectively useless with 508 n BUT! Least server traffic

CF Validation n Occurring on the ACTION page, on the server side n Need not trust the browser n 508 compliant, browser independent n A little more complicated to write, but necessary on public sites

Authentication n Stateless web - any page can call another - this is good for open sites n Hacker pages call your page with false data n Use CGI. HTTP_REFERER to control who calls you n Use CGI. CF_TEMPLATE_PATH application.cfm control what is run. Warning - Can be spoofed by browser

Fake form submits n Hacker copies your HTML source to their machine, edits form fields and submits to your action page. n They can now edit your hidden fields or remove fields to generate error messages n Hidden form field token n Check HTTP_REFERER is in your domain

Fake URLs n Hacker edits your URL to get data they shouldn’t see or to force page error. n Protect URLs with checksum – eg hash() function.

Fake cookies n Cookies can be faked too – they are just in text file on client machine n Don’t assume cookie value is valid n For top security add checksum to cookie.

Page Validation n URL and Form parameters used in SQL u SELECT * FROM EMP WHERE ID = #USERID# u Extra SQL commands on SQL Server M%20MyCustomerTable u | VBA functions - shell() on Access u xp_cmdshell in SQL Server n Use VAL() on parameters or check for ‘ and | or use n Encrypt Variables n Checksum URLs

CFQUERYPARAM n Code example SELECT * FROM courses WHERE Course_ID= n Also runs faster SQL too – cached query plan.

Protect CFINCLUDE and CFMODULE files n Don’t let CFINCLUDE and CFMODULE files be run standalone – they may do bad things or generate error messages n Protect using a naming convention/ subdirectory and test in application.cfm of CGI.script_name n Especially important for Fusebox applications with many include files

Code to protect CFINCLUDE files n For Fusebox In Application.cfm: n Non-Fusebox – check filename/directory

Code Defensively n Assume bad things will happen and code for them n Always code the CFELSE and CFDEFAULTCASE n Check input parameters exist using CFPARAM, they are of correct type and are that they are in range. E.g.

Datasource password n Don’t put datasource userid and password in CF Admin – if any template is compromised hacker can destroy data n Don’t hardcode in every CFQUERY call n Use request variables in application.cfm and encrypt it n Or for super security set up user accounts in Oracle and have users enter userid/password when they logon.

Input massaging n Textarea field may be stored to database for redisplay n Bad users may enter JavaScript or CF functions into your text hoping you will use evaluate() on them. n Strip them out using a regular expression.

CFCONTENT n CFCONTENT can be misused to send back your source code – eg filename/path in URL n Store files it sends in directory outside of webroot.

Logins n Use Strong SSL where available u n Require at least 8 chr password n Consider requiring numbers in password n Consider forcing regular password changes depending on application n Strong form validation n Consider blocking accounts after multiple failed attempts

Authentication u Protected Header code In your application.cfm or header.cfm to be included in every page. Your protected links here Warning - spoofed IP numbers will get around this code

Members Only n Session, client and cookies n Refresh issues n Timeouts n Remember me

Session, client and cookies Client Management n Use short timeouts. (conflicts with 508) n Consider rolling your own security u Use CFID / CFToken from URL or create your own cookies u Store information in database with a table to keep track of ID/Token combinations against user Ids u Most flexible method

Session, client and cookies Client Management n If you use session management (as enabled with CFApplication) u Lock your usage u Limit session timeout, minutes not hours u Consider passing session vars into request vars at top and bottom of page

Session, client and cookies Client Management n Use client variables in place of session variables where you do not need to store complex values n Configure storage so that variables are stored in a DB, NOT the registry n Use WDDX if you have the occasional need for a complex variable n Don’t use too many cookies n Manually test for timeout less than 2 hours – client.last_access_datetime

Timeouts n Use as short a timeout as practical n Don’t want users annoyed n Do want to protect against trouble n Consider (also/instead) having cookies go away after browser closing u This is the default with cookies if you do not specify a time n If you create your own session management, you can do more

Session Tracking n Who is logged on now u Keep track of login times to see who’s logged in now, can record activity and determine based on last activity or logoff option n Variable and structure dump u Use CF_Dump or CF5 CFDump tags to output all session variables or all cookies, etc. objects.com/docs.cfm?f=cf_dump.htm

Session hang over n User logs in then closes browser without logging out. n Hacker uses browser and if the session has not timed out they are logged in as previous user n Use CFCOOKIE on CFID and CFTOKEN to set these session cookies to expire immediately on browser close.

Remember Me Sites with Login functions often have “Remember Me” option n Be careful - want to be clear what this option means n Use to set your own cookie n Store something other than username / password or a flag - consider some random values n Don’t turn option on by default

Members Only Summary n Session variables can still be used, with locks, but Client or Cookies are preferable n Use after insert/cfmail to avoid issues n Short timeouts for login - experiment n Remember Me is easy with Cookie

Back button hacking n Hacker uses back button to view sensitive information from a users browser n Consider disabling back button, especially on logout

Encryption n Encrypt source so even if downloaded can not be read n Be aware that decryption programs exist n Encrypt sensitive data such as credit card numbers in database using CF encrypt() and decrypt(). n Consider storing hash() of password instead of plain text.

Hashing passwords SELECT PasswordHash FROM SecureData WHERE UserID=

Refresh Issues If delete/insert/update pages are refreshed, or other action pages, problems occur – hacker sees error message. n Immediately after one of these actions to avoid this n Use the addtoken=“yes” parameter to keep any session changes across pages

Resources n ecurityzone/ ecurityzone/ n veloper/securityzone/ veloper/securityzone/ n Security section

What Security Means n Security is hard because a hacker only needs one window to be open to get in while the poor webmaster must work on closing dozens of holes. n Security is a way of thinking - how can they get in... n More knowledge is power - don’t keep security tips secret!

Next Steps n Conduct a security audit u Download Michael Dinowitz’s MunchkinLAN to test your site for holes u Remove CFDOCS n Validate pages n Authenticate pages n TeraTech’s CF201 class n Questions? me at