GithubHelp home page GithubHelp logo

Using of semicolon in csrf token? about csrf HOT 9 CLOSED

koajs avatar koajs commented on May 2, 2024
Using of semicolon in csrf token?

from csrf.

Comments (9)

tj avatar tj commented on May 2, 2024

cookie libs should escape but yeah there's no reason for us to use a semicolon there

from csrf.

jonathanong avatar jonathanong commented on May 2, 2024

the csrf token itself is never sent through cookies. the csrf secret this.session.secret is (though if you use a db store then it won't). that spec is outdated and not a real spec (afaik). the way it works should be fine.

from csrf.

remoe avatar remoe commented on May 2, 2024

@visionmedia, yes the libs 'should' escape this. But in koa it doesn't do this by default:

https://github.com/jed/cookies/blob/master/lib/cookies.js#L50
https://github.com/jed/cookies/blob/master/lib/cookies.js#L84

right? ;)

@jonathanong , yes your sample doesn't use cookies. but this should be an option. For example Angular.js use this by default:

http://docs.angularjs.org/api/ng.$http#description_security-considerations_cross-site-request-forgery-protection

And here is the real specification:

http://www.w3.org/Protocols/rfc2109/rfc2109 / Set-Cookie Syntax

from csrf.

jonathanong avatar jonathanong commented on May 2, 2024

you can open a PR in jed/cookies

you can't use this library for angular since this library doesn't send a csrf token as a cookie. you could just create another library specifically for angular.

from csrf.

jonathanong avatar jonathanong commented on May 2, 2024

or we could just use something else instead of a semicolon so you could. suggestion?

from csrf.

remoe avatar remoe commented on May 2, 2024

I think most of the current code will work, also with angular or whatever. One can set the cookie by self like:

this.cookies.set('csrf-token', this.csrf, { expires: expire, httpOnly: false });

So, the only thing is the semicolon. Escaping the semicolon should also work, but this is not optimal.
This one:

http://www.senchalabs.org/connect/csrf.html

doesn't use a semicolon.

from csrf.

jonathanong avatar jonathanong commented on May 2, 2024

hmmm we've been setting JSON sessions with commas and probably whitespace. wonder how that has been working

from csrf.

jonathanong avatar jonathanong commented on May 2, 2024

4cd36fb

from csrf.

remoe avatar remoe commented on May 2, 2024

Thanks, tested ;)

from csrf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.