My favourite string for testing web applications

Weird title, huh?

When creating templates, pages and action responses for your web application you really need to take HTML escaping into consideration. Sometimes the use cases of the system are so many that you may omit HTML escaping for some piece of dynamic or user entered text.

HTML escaping means converting <foo>bar & " to &lt;foo&gt;bar &amp; &quot; in the HTML source.

One of the reasons for HTML escaping is to avoid XSS attacks or simply to make your site valid.

Reasons for making your HTML output valid include:

  1. It’s the “right thing to do”
  2. Does not tire the browser
  3. Allows you to manually detect (via CTRL+SHIFT+A on web developer toolbar) for real HTML output errors
  4. Saves you from css rendering issues due to HTML anomalies
  5. Ensures your content is easily parsable from third party agents (crawlers, scrappers, XSLT transformators etc)

So my favourite string is <script’”<i>
You can alter your development database content using statements like these:

update articles set title=concat("<script'\"<i>", title);
update users set firstname=concat("<script'\"<i>", lastname), lastname=concat("<script'\"<i>", lastname);
update categories set title=concat("<script'\"<i>", title);
...

If after this database content change your site is not functional then there is a problem. You can also check for HTML validity with CTRL+SHIFT+A on web developer toolbar and quickly spot areas where you missed HTML escaping.

You could even automate this whole process by having a tool (JTidy?) scan that all your pages and use cases produce valid HTML. So indirectly you would be testing for insecure (in XSS terms) parts of the application.

HTML escaping in JSTL
HTML escaping in freemarker
HTML escaping in velocity

5 Responses to “My favourite string for testing web applications”

  1. bar & " Says:

    bar & “

  2. Raghavan alias Saravanan M Says:

    HTML Escaping! — a nice catch! :)

  3. Raghavan alias Saravanan M Says:

    The webdeveloper plugin/addon seems to be nice! The ‘View CSS’ option is of my favorite activity! :)

  4. SBL CMS Software | Security Monitoring Says:

    Informative blog…

    Regards,
    SBL Software
    http://www.sblsoftware.com/embedded-household.aspx

  5. ambreen tariq Says:

    yep mine fav script is too..<script’” ..and for software testing tools i go for testertools.com and use their open source software.

Leave a Reply

You must be logged in to post a comment.