JSCK demo update

I believe in releasing code as early as possible and often. So I’ve released another version of JSCK, the code isn’t a complete solution at the moment and is more of a proof of concept rather than a final version you can use on live sites but it highlights the method well and should provide good security against CSRF attacks.

Thanks to everyone who provided feedback in particular Alex AKA kuza55, he raised some very good points and highlighted potential problems.

New features

1. 15 minute expiry dates on all tokens.
2. Multiple tokens can be used at once.
3. I’ve added support for assigning a class to a link and form to enable/disable the token protection.
4. The system can now calls the code from a external file which makes the code cleaner.

Bugs/Outstanding

1. The random code generation sometimes produces a invalid key. (Should be fixed now)
2. Disabled Javascript support needs to be added.
3. Doesn’t work in Safari (yet).
4. Only tested working in Firefox.
5. Referrer checking.
6. JQuery plugin.
7. Fix IE
8. Rewrite JS into DOM code.
9. Source cleanup and final release.

Source code

I was going to wait until I had completed the final version but to help those of you requesting the files with WGET, I’ve decided to release it early 🙂 Please do not use this code on a live web server, the kit is currently in beta and shouldn’t be considered live code.

JSCK Source code

New JSCK demo

10 Responses to “JSCK demo update”

  1. Gareth Heyes writes:

    Looks like I release code a little too early, damn the tokens aren’t working correctly on my server.

  2. Alex@Net writes:

    Hello,

    Do you have in a plan to write a something like a jQuery plugin for this functionality? If would be great to just $(‘myForm’).protect();

    Thanks,
    Alex

  3. Gareth Heyes writes:

    Good idea Alex, I shall consider doing that when I’ve fixed the bugs and released the final version.

  4. Gareth Heyes writes:

    *fixed*

    It now seems to work correctly on my server.

  5. Marco Ramilli writes:

    Sure! It work correctly on my server too.
    @Alex && @Gareth
    the jQuery pulgin could be a big deal, really good idea.

  6. sky writes:

    yeah,THE ie IS NOT TESTED,JS HAS ERROR!

  7. Gareth Heyes writes:

    Thanks Sky I will fix the error

  8. Bill Zeller writes:

    Hi,

    This doesn’t seem to protect against CSRF attacks, since any website (including an attacker’s site), can include the Javascript file that will add a correct token to the links on the page. For example, the following page illustrates a successful CSRF attack against your demo:
    http://www.from.bz/test/jsck.php

    The page includes the jsck Javascript file and then adds the following Javascript:

    var oldOnload = window.onload;
    window.onload = function()
    {
    oldOnload();
    window.location = document.links[0].href;

    }

    Best Regards,
    Bill Zeller

  9. Gareth Heyes writes:

    Bill excellent POC! Very clever, I completely missed that sort of attack 🙂

  10. Gareth Heyes writes:

    I’ve patched it now, your POC should no longer work.