The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,861 other subscribers

Archive for the ‘.NET’ Category

More vulnerabilities solved than just the ASP.NET hash collision DoS: Microsoft Security Bulletin MS11-100 – Critical : Vulnerabilities in .NET Framework Could Allow Elevation of Privilege (2638420)

Posted by jpluimers on 2011/12/29

In addition to the ASP.NET hash collision Denial of Service attack, Microsoft patches 3 more vulnerabilities resulting in an Aggregate Severity Rating that is Critical.

This is a summary of the vulnerabilities. Please read the full MS11-100 bulletin for more details and how to download and install the patches.

Vulnerability Severity Rating Maximum Security Impact Affected Software CVE ID
Important Denial of Service Collisions in HashTable May Cause DoS Vulnerability CVE-2011-3414
N/A or Moderate N/A or Spoofing Insecure Redirect in .NET Form Authentication Vulnerability CVE-2011-3415
Critical Elevation of Privilege ASP.Net Forms Authentication Bypass Vulnerability CVE-2011-3416
Important Elevation of Privilege ASP.NET Forms Authentication Ticket Caching Vulnerability CVE-2011-3417

The CVE-2011-3415 is N/A in .NET 1.1, and Moderate in all other .NET versions.

–jeroen

via Microsoft Security Bulletin MS11-100 – Critical : Vulnerabilities in .NET Framework Could Allow Elevation of Privilege (2638420).

Posted in .NET, ASP.NET, C#, Development, Software Development, VB.NET, Visual Studio and tools | Tagged: , , , , , | Leave a Comment »

Many more web platforms vulnerable to the hash collision attack (not only ASP.NET) #28C3 @hashDoS #hashDoS @ccc

Posted by jpluimers on 2011/12/29

When writing my Patch your ASP.NET servers ASAP early this morning, I didn’t have time to research the full extend of the vulnerabilities published at 28C3 (slides, mp4), though a small bell was ringing a message that I had seen something like it before earlier this century.

I was right, this posting on perlmonks direct me to a /. posting in 2003 pointing me to the research paper on low-bandwidth attacks based on hash collisions (pdf version) that I had seen before. Perl 5.8.1 fixed it September 2003 (search for “hash” in that link).

The attack can be used for DoS because a normal distributed hash table insert of n elements will be running O(n), but a carefully crafted insert of those elements will run O(n^2).

Carefully crafting a worst case scenario depends on how well you can predict collisions in the underlying hash table implementation, which – apparently – is not too difficult, and requires little bandwidth.

Many platforms and languages are vulnerable (already archived at the WayBack machine), including those based on Java, Tomcat, .NET, Ruby, PHP and more in greater or lesser extent. I have the impression that the list only includes big names, but presume platforms based on smaller names (ASP, Delphi, Objective C) are equally vulnerable.

Just read the articles on CERT 903934, oCERT 2011-003Arstechnica, Cryptanalysis.euHeise (German), Hackillusion and the research paper published at 28C3.

a few quotes:

“This attack is mostly independent of the underlying Web application and just relies on a common fact of how Web application servers typically work,” the team wrote, noting that such attacks would force Web application servers “to use 99% of CPU for several minutes to hours for a single HTTP request.”

“Prior to going public, Klink and Wälde contacted vendors and developer groups such as PHP, Oracle, Python, Ruby, Google, and Microsoft. The researchers noted that the Ruby security team and Tomcat have already released fixes, and that “Oracle has decided there is nothing that needs to be fixed within Java itself, but will release an updated version of Glassfish in a future CPU (critical patch update).”

“The algorithmic complexity of inserting n elements into the
table then goes to O(n**2), making it possible to exhaust hours of CPU time using a single HTTP request”

“We show that PHP 5, Java, ASP.NET as well as v8 are fully vulnerable to this issue and PHP 4,
Python and Ruby are partially vulnerable, depending on version or whether the server
running the code is a 32 bit or 64 bit machine.”

Microsoft seems to have been notified pretty late in the cycle, I presume because the researchers started with a some platforms and finally realized the breath of platforms involved.

The ultimate solution is to patch/fix the platforms using for instance a randomized hash function a.k.a. universal hashing.

Microsoft will provide a patch for ASP.NET later today, Ruby already patched and other vendors will soon or have already (please comment if you know of other platforms and patches).

The links this morning indicated there were no known attacks. That is (maybe was) true for ASP.NET, but for PHP a public proof of concept of such a DoS is has been published by Krzysztof Kotowicz (blog) with sources at github and a demo html page.

Temporary workarounds (based on the some of the links in this and the prior blog post, and the workarounds mentioned here and here):

  1. If you can: replace hash tables by more applicable data structures
    (I know this falls in the for-if anti-pattern category, but lots of people still use a hammer when a different tool works much better)
  2. Limit the request size
  3. Limit the maximum number of entries in the hash table
  4. Limit form requests only for sites/servers/etc that need it.
  5. Limit the CPU time that a request can use
  6. Filter out requests with large number of form entries

Some platforms already have applied temporary workarounds (I know of Tomcat (default max 10000 parameters), and PHP (default max_input_vars = 1000) did, and looks like the ASP.NET fix will do too).

Other platforms (like JRuby 1.6.5.1, CRuby 1.8.7 (comments) and Perl 5.8.1 in September 2003 ) fixed it the proper way.

Note: workarounds are temporary measures that will also deny legitimate requests. The only solution is to apply a fix or patch.

A major lesson learned today for a few people around me: when vendors start publishing “out of band” updates, do not trust a single 3rd party assessment with state “initial investigation”, but be diligent and do some further research.

–jeroen

PS: Just found out that most Azure users won’t need to manually apply a fix: just make sure your Hosted Service OS servicing policy is set to “Auto”.

Posted in .NET, ASP.NET, C#, Cloud Development, Delphi, Development, Java, PHP, Ruby, Scripting, Software Development, Web Development, Windows Azure | 6 Comments »

Patch your ASP.NET servers ASAP: ASP.NET Security Update Shipping Thursday, Dec 29th – ScottGu’s Blog

Posted by jpluimers on 2011/12/29

Quotes:

The security update we are releasing resolves a publicly disclosed Denial of Service issue present in all versions of ASP.NET.  We’re currently unaware of any attacks on ASP.NET customers using this exploit, but we strongly encourage customers to deploy the update as soon as possible.

Attacks such as these are not specific to any particular language or operating system. Presenters at the security conference discussed how to cause them using standard HTTP form posts against several different web frameworks (including ASP.NET). Because these attacks on web frameworks can create Denial of Service issues with relatively few HTTP requests, there is a high likelihood of attacks happening using this approach. We strongly encourage customers to deploy the update as soon as possible.

The security update we are releasing on Thursday, December 29th updates ASP.NET so that attackers can no longer perform these attacks. The security update does not require any code or application changes.

During the 28e Chaos Communication Congress in Germany, on December 28, 2011 a security vulnerability was showed that potentially can DOS many types of web servers (including ASP.NET) with a carefully crafted 100 kilobyte plain HTTP form post request.

Information on the ASP.NET vulnerability was published by Microsoft on December 27, 2011.

ASP.NET on all supported .NET versions (1.0 SP3, 1.1 SP1, 2.0 SP2, 3.5 SP1, 4.0) on all supported Windows versions (XP, Server 2003 and R2, Vista, 7, Server 2008 and R2) are affected.

Since the vulnerability as being very severe, Microsoft will publish an out of band fix today (December 29, 2011) at around 10 AM Pacific time (during winter, this 1800 UTC) on Windows Update, Windows Server Update and the Microsoft Download Center followed 3 hours later by a webcast at 01 PM Pacific time (2100 UTC).

More about about 28C3 in German.

–jeroen

via: ASP.NET Security Update Shipping Thursday, Dec 29th – ScottGu’s Blog.

Posted in .NET, ASP.NET, Development, Software Development | 1 Comment »

Added a few links to my “Tools” page, @WordPress bug spuriously inserting div tags still present.

Posted by jpluimers on 2011/12/28

While re-designing a Visual Studio 2010 plus Delphi XE2 install for a specific client, I updated some of my Tools page links:

And found out that the WordPress still wrongly inserts div tags when you step out a list by pressing Enter twice is still present. Annoying, as it has been there for at least 2 years, so I’m still interesting in people having a workaround for it.

–jeroen

Posted in .NET, C#, Delphi, Development, Software Development, TFS (Team Foundation System), Visual Studio 2008, Visual Studio 2010, Visual Studio and tools | 1 Comment »

Overview of .NET Framework, CLR and Visual Studio version numbers – via StackOverflow.com

Posted by jpluimers on 2011/12/14

I love StackOverflow.com; since they clean out duplicate questions very well, it now is becoming a very good site for reference materials as well.

I won’t duplicate the tables of .NET CLR/Framework and Visual Studio version numbers here as it will age: the tables linked below will somehow be updated by someone. The real power of SO.

–jeroen

Via: How do the .NET Framework, CLR and Visual Studio version numbers relate to each other? – Stack Overflow.

Posted in .NET, Development, Power User, Software Development | Leave a Comment »

WinForms UserControl and Visual Studio 2010 debugging – The process cannot access the file … because it is being used by another process – Stack Overflow

Posted by jpluimers on 2011/12/13

When doing WinForms development in Visual Studio 2010 (including SP1), be aware of a bug with UserControls that hamper debugging; sometimes you get an error like this:

Error 9 Unable to copy file "obj\x86\Debug\MyProject.exe" to "bin\Debug\MyProject.exe". The process cannot access the file 'bin\Debug\MyProject.exe' because it is being used by another process.

When using SysInternals’ Process Explorer to see which process has handles open to MyProject, you will see that devenv.exe (The Visual Studio IDE) is the culprit: sometimes it has a lot of handles open.

The workaround is simple: close all UserControls before debugging your WinForms application.

A real pity, as UserControls are a very useful feature when developing software (many platforms use the same paradigm, .NET certainly wasn’t the first to introduce it, and it is available in for instance WPF as well).

Note that there are other causes of the same error message, but for me this was the issue.

–jeroen

Via: visual studio 2010 – VisualStudio2010 Debugging – The process cannot access the file … because it is being used by another process – Stack Overflow.

Posted in .NET, C#, Development, Software Development, VB.NET, Visual Studio 2010, Visual Studio and tools | 2 Comments »

When writing applications, include Keyboard Shortcuts for both the CUA and Windows/Apple shortcuts

Posted by jpluimers on 2011/12/06

When you write applications, it is important to include both the CUA and the Windows/Apple keyboard shortcuts, and get the tab order of keyboard accessible user elements right.

Many modern applications seem to put less and less emphasis on the most efficient user input device: the keyboard.

You should: it makes your application much more pleasant to use.

I wrote about CUA before, but the Windows and Mac shortcuts are just as important.

A small table (please post a comment if you know additions):

Keyboard Shortcuts for the most common tasks.
Function CUA Windows Mac
Copy Ctrl + Insert Ctrl + C Command + C
Cut Shift + Delete Ctrl + X Command + X
Paste Shift + Insert Ctrl + V Command + V
Delete before cursor Backspace Delete
Delete after cursor Delete Fn + Delete
Undo Alt + Backspace Ctrl + Z Command + Z
Redo Ctrl + Y Command + Y
Confirm the current task Enter Return
Cancel the current task Escape Escape
Next field Tab Tab
Previous field Shift + Tab Shift + Tab
Next pane Ctrl + F6
Previous pane Alt + F6
Next window F6  Cmd + `
Previous window Shift + F6
Application menu Alt + Space
Windows menu
Local menu Shift + F10 Local Menu

Note that many Linux programs follow both the CUA and Windows settings.

References:

–jeroen

Posted in .NET, Delphi, Development, Keyboards and Keyboard Shortcuts, Power User, Software Development, xCode/Mac/iPad/iPhone/iOS/cocoa | Leave a Comment »

Source Code Pretty Printing in various languages

Posted by jpluimers on 2011/12/05

Totally forgot about this: YAPP – yet another pretty printer.

–jeroen

via: delphi – Save source code with formatting syntax highlight – Stack Overflow.

Posted in .NET, C#, Development, Prism, Software Development | Leave a Comment »

Duh moment: in C#, the integer zero (0) is compatible with all enums

Posted by jpluimers on 2011/11/30

Even if you have used something for over a decade, you can learn about it :)

I was refactoring bits of code where someone clearly didn’t understand the benefits of enumerations, similar to this very contrived example:

using System;

namespace Demo
{
    // explicit equivalence of: 
    // public enum TrafficLight { Red, Yellow, Green };
    public enum TrafficLight { Red = 0, Yellow = 1, Green = 2 };

    public class Program
    {
        public static void Main()
        {
            // old code:
            Console.WriteLine(IntIsRedTrafficLight((int)TrafficLight.Red));
            Console.WriteLine(IntIsRedTrafficLight((int)TrafficLight.Yellow));
            Console.WriteLine(IntIsRedTrafficLight((int)TrafficLight.Green));
        }

        public static bool IntIsRedTrafficLight(int trafficLight)
        {
            return (trafficLight == (int)TrafficLight.Red);
        }
    }
}

The code was using way too many casts, and my goal was something as simple as this: Read the rest of this entry »

Posted in .NET, C#, Development, Software Development | Leave a Comment »

I was baffled…

Posted by jpluimers on 2011/11/15

When I saw code like this in a production app, I was speachless:

			if (matcher.Trim().Length > 0)
			{
				if (eesteWhere){sqlWhere += "WHERE ";eesteWhere = false;}
				else{sqlWhere += "AND ";}
				sqlWhere += "m.matcher like '" + matcher.Trim() + "%' ";
			}

Not once, twice, but hundred of fragments like these. Not generated, but hand copy-pasted. And the client thought they were running stable, reliable apps :(

This is soo XSCD ‘Exploits of a Mom‘ (aka Bobby Tables):

The department that wrote the code has been closed a while ago, but some serious refactoring time needs to be invested here, as all applications delivered by that department are vulnerable to SQL Exploits.

–jeroen

Posted in .NET, C#, C# 2.0, Database Development, Development, Software Development, SQL, SQL Server | Leave a Comment »