02 July 2010

Code

Posts relating to the category tag "code" are listed below.

09 January 2009

Security Implications of WCAG 2.0

The Web Content Accessibility Guidelines 2.0 (WCAG 2.0) have created some challenges for those who wish to meet the criteria and also develop to high web security standards.

The WCAG 2.0 became a full W3C Recommendation in December 2008 (see Accessibility and Security Roundup). The WCAG 2.0 contain much more related to transactional systems and there are many criteria which existing development frameworks are unlikely to meet. Inflexible generic methods for navigation, data entry and validation will not always be possible—the context is so important in consideration of accessibility.

The four principals (perceivable, operable, understandable and robust) comprise 12 guidelines and associated testable success criteria. The most difficult issues are related to the highest level of conformance. There are still three conformance levels—A (lowest), AA, and AAA (highest).

The Techniques for WCAG 2.0 are worth reading as these give a guide to developers as how some of the success criteria could be achieved and checked.

Session management

The following are of particular interest:

Session management where authenticated users are authorised to perform certain actions is a fundamental building block of web application security. There are potential issues here if tokens are not expired on time out and log out. This is a particularly important issue on shared computers.

Data entry

And for data entry and validation, the following techniques have security implications:

Getting data entry, checking, confirmation and validation correct is key, and I like the empahsis being placed on this aspect, but there are dangers in poorly thought-out implementations. More accessible web applications are better for everyone—not just people with less experience, knowledge or ability.

Final thoughts

Overall, WCAG 2.0 increases the complexity of specification, design, development and testing of web applications. Many of the techniques could introduce security vulnerabilities, and the listed techniques could be used to develop misuse test cases.

I'm pleased to see in one of the script examples:

This example is limited to client-side scripting, and should be backed up with server-side validation

Very true.

Update 19th May 2009: See also What's the Scope for Accessibility Testing? and Can An Accessible Web Application Be Secure? concerning my presentation at OWASP AppSec EU09.

Posted on: 09 January 2009 at 09:01 hrs

Comments Comments (0) | Permalink | Send Send | Post to Twitter

02 January 2009

Mobile Web Application Mania

Happy new year. In a recent edition of a mobile phone provider's newsletter for business customers, it heralded the growth of mobile applications.

Regarding Nokia's purchase of the Symbian mobile operating system and making it free to other mobile manufacturers in an attempt to combat Google's Android mobile phone operating system. The newsletter mentions that an advantage of Android being an open source platform:

... applications can be freely written for it... So just imagine what can be achieved on your next mobile phone when absolutely anybody can design an application for it...

Armageddon perhaps?

Posted on: 02 January 2009 at 09:32 hrs

Comments Comments (0) | Permalink | Send Send | Post to Twitter

21 November 2008

Free Text Form Field Data Validation

Input data validation is a fundamental practice that web applications need to get right to protect users, their data, your data and your web site. But free text entry fields in web forms can be problematic - we all make mistakes, misread the instructions, type in the wrong fields, avoid filling in the mandatory items and so on. But how should the web application respond to these?

Users can submit data to web applications in many ways - file uploads, page requests, URL parameters, form parameters, file uploads, request headers, cookies and so on, but it is in conventional forms where we need to be somewhat lenient in how we respond to data validation issues.

Form data must be checked for integrity, business rules and validity of the following:

  • Required (whether the field must be submitted, not null)
  • Type (e.g. positive integer, text string, date, true/false boolean)
  • Length/Range (e.g. numerical limits, number of decimal places, length of text, applicability of a date)
  • Format (e.g. DD/MMM/YYYY for a date, international format for telephone numbers, allowed/disallowed characters)
  • Character encoding/character set.

HTML forms allow radio buttons, checkboxes and drop down lists where the value(s) meant to be submitted are predetermined. In these cases it is reasonable that some of these failures are likely to be caused by malicious users tampering with values, or some fault in the application itself.

But what about text fields where users can enter any value in free format? I mentioned in Separate the Text from the Code a posting elsewhere about the display of form entry error messages. At what point to you reject the user input completely as malicious?

You may have mechanisms looking for dangerous input such as custom application code, an application filter module, security settings in your web server software or a web application firewall. If a user accidentally or without malice types text that could be construed as malicious because it matches a signature for something like cross site scripting or SQL injection, when they submit the form they could be presented with something much less friendly. This could occur if the control points are set to intervene rather than simply monitor, and so the 'friendly' message will never appear and they will see something else, like these three examples:

Partial screen capture of page showing message 'Error: Invalid Request' when some potentially malicious input was submitted in a form field. Partial screen capture of page showing message 'Forbidden - You do not have permission to access this document' when some potentially malicious input was submitted in a form field. Partial screen capture of page showing message 'Request validation error' when some potentially malicious input was submitted in a form field - the page also includes details of the script path, ASP.NET version, a full stack trace and information for the developers on how to suppress the message.

So be wary about validation and active blocking. In some cases, user data should be accepted and then sanitised before explaining the problem and possibly re-displaying their data appropriately encoded. The problem might be as simple as putting an item of text in a date field, or using an "incorrect" date format. If the filtering mechanisms are too strict, the usability of the application will be much degraded.

For each item of user input, try to identify:

  1. What is allowed to be received by the web application for each field
  2. Exact validation rules before the application can use, store or transmit the data value
  3. Which control points will be checking and enforcing these
  4. The sensitivity of the values
  5. How the data will be used subsequently
  6. How the data values should be encoded when output.

In some cases nos. 1 and 2 will be the same, but more often they will be different. Build these into your application test cases.

After all, some people live near "Alert Street" and "Script Drive":

Partial screen capture of M&S store finder search results page showing two stores for a search term including script tags - one on Alert Street and one on Script Drive.

For more information on integrity checks, validation and business rules, see data validation from OWASP's Development Guide. I'll discuss client-side validation, whitelisting and blacklisting in future posts.

Posted on: 21 November 2008 at 12:55 hrs

Comments Comments (0) | Permalink | Send Send | Post to Twitter

07 November 2008

Separate the Text from the Code

Documenting all the inputs and outputs is a good strategy when developing a web application. Every piece of textual content should also be identified and stored centrally. This leads to consistency and means identical text can be replaced globally and alternative translations provided more easily. Remember, the context is always important in the decision how to split up text, and how to translate it.

The text of instruction, confirmation and error messages should be handled in the same way... and of course it needs to be changed to something appropriate. I came across the following rather unhelpful message in a Siebel customer relationship management system:

A web form with an error message 'Wrong field values or value types detected in field Description.  Please re-enter your field values.  If you need additional assistance, please refer to the documentation. (SBL-UIF-002999)'

The users of this public system are about as likely to have its documentation to refer to as go on a trip to the moon. Perhaps during development and acceptance testing, not all possible conditions were tested, so what else wasn't checked? It seems this should instead say something like:

Sorry, you have entered too much text in the Description field. Please shorten the text or provide a brief summary and upload the full text as a file attachment.

Of course, telling the user first there is some sort of length limitation would be better. If all such pieces of text are located in a single repository (database table, configuration file, and so on), it can be easier to ensure that any system defaults are replaced with user-friendly and understandable messages. The only saving grace here is that the message implies the system might be doing some sort of type, length checks on data input by users.

A reminder for auditors: check what default text is stored in a system. And, make sure that changes to these text items follow a change control process.

When output text is scattered through developer's code, it is not usually a good sign. Using development frameworks that already have secure and tested error handling modules and separate the logic from words and layout are the way forward.

Update 19th November 2008: Christian Watson has posted a message about Error Message Design Showcase in his SmileyCat Web Design Blog giving an overview of how many sites handle the display of form entry error messages.

Posted on: 07 November 2008 at 09:09 hrs

Comments Comments (0) | Permalink | Send Send | Post to Twitter

09 September 2008

Know Your Form Data

Developers often build data entry forms that don't match with the reality of the information they are trying to collect. This can mean the forms are unusable.

I am surprised about how reluctant most specialist usability companies, at least in the UK, are to considering the security implications during usability testing. Reactions I've come across range from "usability has nothing to do with security" to "the client will deal with that". I think they are missing an opportunity.

Although we hear a lot about confidentiality, information security includes the principles of availability and integrity:

  • Availability - Maintaining systems, resources and data so they are accessible when required and are functioning correctly
  • Integrity - Ensuring data is valid, complete and cannot be modified or deleted without authorisation

Here's an example "change address" form where the integrity checks are not correct and therefore denying use of the service to a customer:

Partial screen capture of an address entry form - the house number, flat number and street names have been left blank and the form submitted to show an error message 'please enter a valid address'

The form belongs to a very customer focused organisation in a highly regulated business sector. Therefore, I suspect that the web site has been through extensive usability testing. But it is not possible to provide an address that doesn't have a house number, flat number or street name. Strange, since there are many valid Royal Mail listed addresses like this, yet this web site has been built to specifically exclude them.

Well, I don't think the project team set out with this intent, but that's what happened. There is no way to change your address, except to phone the call centre. Of course, it might be that the database behind the scenes has some (incorrect) constraints on what it thinks constitutes an address and the developers have coded the web site to match. What makes me suspect this, is that the drop down list of county/region names includes truncated county names, and even entities that are not counties, regions or metropolitan areas. Also, the displayed text is the same as the values submitted by the form. However, that's not the right way to do it.

HTML source code of the drop down list showing county values and names like 'Stafford' and 'Tynewear'

Some of these are not counties, and if the address was on Skye, would you select 'Skye' or 'Highland' (region)?

Even if the back-end system doesn't allow addresses without street names etc, the web site should accept valid addresses and then put the change into a pending state, for subsequent checking and update of the main system. It must be possible somehow, since you can do it by telephone.

The Royal Mail has an overview of what constitutes a correct postal address in the United Kingdom, but it always pays to check the original source which tells a slightly different story: Why, What and How - A Guide to using the PAF® (PDF):

There may be no Thoroughfare information for an address. This usually occurs in rural areas, where the Locality information identifies the location...

This 204-page document also explains how long each address line could be, and everything else about the Royal Mail's Postcode Address File (PAF) products including character conversions. BitBoost Systems maintain a useful International Mailing Address Formats web page but always check with the original sources - don't rely on anyone else's interpretation.

Recommendations:

  • Understand the properties of all your data
  • Don't enforce internal constraints and methods on remote users
  • Don't make your web systems more complex than your other methods of communication (such as telephone)
  • Make it easy for web site user to get it right

And, include consideration of security issues during usability and user acceptance testing.

Posted on: 09 September 2008 at 10:55 hrs

Comments Comments (0) | Permalink | Send Send | Post to Twitter

Code : Web Security, Usability and Design
ISO/IEC 18004:2006 QR code for http://clerkendweller.com

Requested by 38.107.191.107 on Friday, 10 September 2010 at 17:38 hrs (London date/time)

Please read our terms of use and obtain professional advice before undertaking any actions based on the opinions, suggestions and generic guidance presented here. Your organisation's situation will be unique and all practices and controls need to be assessed with consideration of your own business context.

Terms of use http://www.clerkendweller.com/page/terms
Privacy statement http://www.clerkendweller.com/page/privacy
© 2008-2010 clerkendweller.com