Subscribe: Pete Freitag's Homepage
http://www.petefreitag.com/rss/web/
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
apache catalina  apache  coldfusion filter  coldfusion  filter  invoke  java coldfusion  java org  java  org apache  org  session 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Pete Freitag's Homepage

Pete Freitag's Homepage



Covering ColdFusion, Java, Web Development, and other topics



Last Build Date: Mon, 20 Jun 2016 23:10:00 GMT

 



Securing Legacy CFML - dev.Objective() 2016 Slides

Mon, 20 Jun 2016 23:10:00 GMT

Back from another great dev.Objective() conference in Minneapollis. This year Foundeo was a sponsor, and I spoke on Securing Legacy CFML Code. Find the slides here.




My CFSummit 2015 Slide Decks

Fri, 13 Nov 2015 02:05:00 GMT

I was fortunate enough to be able to do two different talks this year at the Adobe CFSummit 2015 conference.

My first session, was a hands on Pre-Conference workshop taught by David Epler and myself, it was titled: Hack & Fix - Hands on ColdFusion Security Training. This was a 3 hour workshop which had a VM preloaded with the hackable CFML training app: HackableType that was first created by Jason Dean and I in 2010. Students then try to hack the vulnerable code, and then fix it. It went very well thanks to David, and all who attended!

Hack & Fix - Hands on ColdFusion Security Training - View Slides

For my second session I presented on Locking down ColdFusion Servers, an overview of the ColdFusion 11 Lockdown Guide. View Slides

My company Foundeo was a Gold sponsor of CFSummit 2015. I enjoyed meeting lots of our HackMyCF and FuseGuard customers and hopefully a few soon to be customers!




Adding Chrome Custom Search for CFDocs

Fri, 16 Oct 2015 20:07:00 GMT

I read some complaints recently that the new Adobe documentation site is not friendly with a chrome custom search engine (because the URIs are different based on what the tag/function starts with).

If you want to setup a custom search engine in chrome, it is really easy:

  1. Using Chrome go to chrome://settings/searchEngines
  2. Scroll down to an empty text box that says Add a new search engine
  3. In the first box type cfdocs.org in the second box type cf and in the third box type http://cfdocs.org/%s

Now type cf followed by a space in the address bar, and then a tag or function name.




Disable Flash Remoting on ColdFusion Servers

Thu, 03 Sep 2015 20:37:00 GMT

Due to the recent security vulnerability ABSP15-20 / APSB15-21 in BlazeDS there has been increased interest in disabling flash remoting when not needed -- if you followed the lockdown guide for CF9, CF10, or CF11 you should already have it disabled. This only applies to ColdFusion 10 and ColdFusion 11 right? Nope! Your ColdFusion 7-9 servers may also be vulnerable to this issue but since they are considered EOL or End Of Life, they are no longer supported or patched by Adobe so there is no hotfix to apply. If you do need flash remoting on these servers you can manually update the flex-messaging-core.jar file in your lib directory. I tested this on a CF 9.0.2 server tested that it worked by using the ColdFusion Server Monitor. David Epler has posted some instructions for manually patching a CF9 server. How can I disable Flash Remoting on ColdFusion Servers There are a few ways this can be accomplished, I recommending doing each way to provide layers of assurance or defense in depth. Uncheck: Enable Flash Remoting in ColdFusion Administrator - this is the easiest way to go, but I don't trust this method to fully disable anything that might be vulnerable to a security issue. Block URIs on your web server web server blocks are always my favorite approach because they are blocked before hitting the CF server at all, they are the most efficient way to protect resources in most cases. If you are using IIS 7+ you can block (if you are using IIS6 or lower you are running an EOL operating system with many other security issues to consider, time to upgrade!) using Request Filtering. It can run on a per site basis or on a global basis - for security rules like this it makes sense to run them on a global basis. Click on the URL tab and then Deny Url Sequence to add the following URIs to block, test them out in your browser to make sure you get a 404: /flex2gateway /flashservices /flex-internal /CFFormGateway /cfform-internal To block them on Apache you could do something like this globally in httpd.conf: RedirectMatch 404 (?i).*/flex2gateway.* RedirectMatch 404 (?i).*/flashservices.* RedirectMatch 404 (?i).*/flex-internal.* RedirectMatch 404 (?i).*/cfformgateway.* RedirectMatch 404 (?i).*/cfform-internal.* Using nginx you can do something like this (thanks Joseph Lamoree) : location ~* ^/(flex2gateway|flashservices|flex-internal|CFFormGateway|cfform-internal|messagebroker) { return 403; } Keep in mind that when blocking only on the web server Flash Remoting is still enabled so you could still use the server monitor over the Internal Web Server, or if you have it running on its own port. Disable by Removing Servlet Mappings Removing Servlet Mappings removes the URL pattern to Servlet (the java code that executes requests) definition at the JEE servlet container level. It is done by editing the web.xml file found in the WEB-INF folder. You can either delete the ... tag or comment it out with an <-- XML comment --> (only uses two dashes). Here's an example of a servlet mapping on CF9: MessageBrokerServlet /flex2gateway/* You can also disable the servlet mappings that have the following URL patterns: /flashservices/gateway/* /flex-internal/* /CFFormGateway/* /cfform-internal/* You can also remove the Servlets that correspond to these servlet-mapping but I have seen cases where CF would not start due to removing a servlet that is expected to be there. Removing unnecessary servlets can improve your CF server startup time and potentially reduce resource utilization, so it may be worth experimenting with for you. What if I am running Railo / Lucee There is a good chance your server could also be vulnerable to this issue, because many installers included BlaseDS and servlet mappings. T[...]



HackMyCF Adds SSL/TLS Scanner

Wed, 27 May 2015 20:37:00 GMT

I'm pleased to announce a feature of HackMyCF that I've been excited about for a while: SSL / TLS Scanning.

If you stay up to date with security news you know that there have been a large number of vulnerabilities or weaknesses discovered in SSL or TLS protocols and implementations. For example, we have LogJam, Heartbleed, POODLE, CRIME, BEAST, and those are just the ones with cool names :)

While we have been issuing warnings when SSLv2 and SSLv3 (poodle) are enabled for a while, but here are some of the new checks we have added:

  • Warn if TLS 1.2 is not enabled
  • LogJam: Weak DH Group Size (less than 2048 bits) and some common prime warnings (not fully inclusive)
  • Warn if SSL Certificate will expire soon, or is expired
  • Warn if certificate is signed with SHA1 (will cause warnings/errors in recent Chrome versions)
  • Warn if TLS compression is enabled (CRIME)
  • Test for OpenSSL Heartbleed vulnerability
  • Warn if Public Key Size less than 2048 bits

Here's a screenshot from an example HackMyCF report:

Customers can enable this feature if they have set protocol = HTTPS in their server settings.




IncompatibleClassChangeError after ColdFusion 11 Update 5

Mon, 20 Apr 2015 23:24:00 GMT

If you use the Encrypt function in ColdFusion 11, you may experience an error that looks like this: java.lang.IncompatibleClassChangeError: Expected static method coldfusion.runtime.CFPage.Encrypt(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; at cfprobe2ecfm877726397._factor9(/hackmycf/probe.cfm:258) at cfprobe2ecfm877726397.runPage(/hackmycf/probe.cfm:1) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:246) at coldfusion.tagext.lang.IncludeTag.handlePageInvoke(IncludeTag.java:736) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:572) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.IpFilter.invoke(IpFilter.java:45) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:466) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:42) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:142) at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:30) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:58) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at coldfusion.CfmServlet.service(CfmServlet.java:219) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at coldfusion.inspect.weinre.MobileDeviceDomInspectionFilter.doFilter(MobileDeviceDomInspectionFilter.java:121) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:422) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:744) The solution is to clear the Template Cache, this is done quite easily in the ColdFusion administrator under Server Settings » Caching simply cli[...]



Scope Injection in CFML

Tue, 03 Mar 2015 22:59:00 GMT

Here is an interesting vulnerability that I have come across several times in real CFML code during code reviews, I have spoken about it at conferences but have never written about it. Since it doesn't really have a name, I call it Scope Injection, you'll see why in a minute.

We have the following code:


    Do something only an admin can do...

Now lets suppose that this session.isAdmin is set upon a successful authentication, but for unauthenticated sessions isAdmin is undefined in the session scope (onSessionStart does not initialize it).

Now suppose a request to the above code like this:

/admin/something.cfm?session.isAdmin=1

What happens when the above code example is run:

  • CF checks to see if session.isAdmin is defined in the session scope
  • The variable session.isAdmin was not defined in the session scope, so it starts searching other scopes, such as the url scope.
  • CF finds url.session.isAdmin defined and uses that value to evaluate the if statement as true.
  • Code that should only be executed by an admin can actually be executed by anyone.

Mitigating Scope Injection in CFML

To mitigate this, you should make sure that variables are initialized properly, a good place to do this is in your Application.cfc event lifecycle methods, onSessionStart for session scoped variables, onApplicationStart for application scoped variables, onRequestStart for request scope variables, etc.

So to mitigate this issue, we simply need this:


    

If you are extra paranoid you can also use StructKeyExists to make sure the variable is defined:


  do admin stuff

Scope Injection in Railo / Lucee

This particular example is not vulnerable in the version of Railo / Lucee I tested, apparently because it does not allow cascading on builtin scopes. You can still have a scope injection issue on variables that are not in a builtin scope, consider this:


   


  do admin stuff

There is also a setting in the Railo / Lucee administrator that allows you to turn off cascading (under scopes) by setting it to strict. You can also do this in your Application.cfc:

this.scopeCascading = "strict";

When the scopeCascading setting is set to strict it removes the possibility of a scope injection vulnerability, and may also improve performance.

How FuseGuard protects from Scope Injection

FuseGuard customers have been enjoying protection from scope injection for the past 3 years. It operates in a strict mode by default which prevents inputs like url.one.two, with strict mode off it only looks at valid scope names (like session, application, etc).

As of version 2.3 you can also set a prefix to ignore, for example fusebox apps commonly have url's like ?fusebox.action=foo so you can tell FuseGuard to allow that by adding:

filter.setIgnorePrefixList("fusebox");

You can also ignore a variable a-la-carte like this:

filter.ignoreVariable("url", "one.two");



Upload Files Directly to Amazon S3 using ColdFusion

Wed, 26 Nov 2014 22:19:00 GMT

Here's a quick example showing how to upload a file directly to Amazon S3 (bypassing your server). The tricky part in getting this to work is that you don't want to allow anyone to upload a file anywhere on your S3. To accomplish this you can create an AWS Access Control Policy, base64 encode it, and then sign it using HMAC-SHA1 with your AWS Secret Key. A policy is a JSON string that might look like this:

{ "expiration": "2014-11-26T13:23:00.000Z",
  "conditions": [
    {"bucket": "example-bucket-name" },
    ["eq", "$key", "image.jpg"],
    {"acl": "public-read" },
    {"redirect": "https://example.com/upload-complete.cfm" },
    ["starts-with", "$Content-Type", "image/"]
  ]
}

To generate this policy dynamically we might do something like this:






{ "expiration": "#DateFormat(expDate, "yyyy-mm-dd")#T#TimeFormat(expDate, "HH:mm")#:00.000Z",
  "conditions": [
    {"bucket": "example-bucket-name" },
    ["eq", "$key", "#JSStringFormat(fileName)#"],
    {"acl": "public-read" },
    {"redirect": "https://example.com/upload-complete.cfm" },
    ["content-length-range", 1, 1048576],
    ["starts-with", "$Content-Type", "image/"]
  ]
}






Because we are using the HMac function you must be on CF10+ or Railo 4.1+ if you are on an older version you will need to find a third party hmac implementation.

Next you create a form that posts directly to Amazon S3:

File:

According to the S3 documentation there are some conditions in which the redirect will not happen:

Please note that the redirect is not guaranteed to be followed. It is possible that an upload would succeed, but that a networking problem on the end-users network prevents them from following the redirect. It is also possible that in certain failure conditions, that a file is actually uploaded but you are not notified about the upload.

To get around this uncertainty you can setup Event Notifications for the S3 bucket you are uploading to.

The other thing to note is that if an error occurs the redirect will not happen and the user will be presented with an XML error message. To handle that more gracefully you could upload the file via AJAX, and then handle the error condition within JavaScript.




Minor JavaDocs.org Update

Tue, 28 Oct 2014 22:51:00 GMT

As you may know I run a few doc shortcut sites, cfdocs.org for CFML has been going quite well since publishing the source on github with a bunch of community contributions.

The other site I use alot is JavaDocs.org, I recently updated it to point to Java SE Version 8, and JEE Version 7. I also added package shortcuts to it, so you can hit urls like javadocs.org/javax.servlet and get a summary of all the classes / interfaces in that package.

I hope you find the sites handy.




nginx Directive rewrite is not terminated

Sat, 18 Oct 2014 01:47:00 GMT

I have been setting up some sites on nginx today (moving from an apache server) and have been pretty happy with how an Apache rewrite rule like:

RewriteRule /foo/([0-9]+)/ /foo.cfm?id=$1

Can be done in nginx like this:

rewrite /foo/([0-9]+)/ /foo.cfm?id=$1;

This was working great until I ran into this error:

[emerg] 4603#0: directive "rewrite" is not terminated by ";" in /etc/nginx/sites-enabled/example.com.conf:26

But the line referenced did end with a semicolin!

It turns out the problem was that my rewrite rule had {} in it, for example:

rewrite ^/archive/([0-9]{4})/ /archive.cfm?year=$1;

Replacing the {4} with simply a + worked (though is less precise).