Js-cookie: Add input validation and tamper-proofing to README.md

Created on 11 Mar 2020  路  6Comments  路  Source: js-cookie/js-cookie

I can contribute a draft PR for this if you like. Just mention me.

Might be worth reminding that JSON and URL encoding converter:
https://github.com/js-cookie/js-cookie#converters
obviously won't work if you use an external library to do the storage encryption/tamper-proofing. (Can't decode a properly encrypted string...)

In the security industry, we see a lot of cookie-related CSRF and XSS vulnerabilities due to people...

  • Misunderstanding how effective HTTP Secure , SameSite, and HttpOnly is (they are mostly not)
  • Not knowing how to use them
  • Misunderstanding that you're not safe just because your cookie doesn't have a form (malware is mostly scripted not GUI anyways)
  • Directly using input without sanitization or encryption/tamper-proofing (Hence issues #459 and #496 and https://www.chromestatus.com/feature/5633521622188032)

Many people simply Ctrl + C. Secure coding is still not widely taught. So it would help if the README can show proper use. Like a comment that reminds them to run validate.js or something on results after Cookies.get('name'), etc. That way you can still keep the shippable + dependencies small, but still encourage best practice.

No huge explainer needed about HTTP headers. Can just link to a resource:
https://web.dev/samesite-cookies-explained/

feature request

Most helpful comment

@carhartl Yes, a reminder about the new requirements about SameSite: None and converters would be good. (Like your existing reminder about InternetGetCookie and domain...)

And... This README can't possibly completely cover all of security. :) I am only suggesting a minimal hint, like your comments:

Cookies.get('foo', { domain: 'sub.example.com' }) //domainwon't have any effect...!

10% of people never read anything. We can't help that... But they'll ask experts for help. Experts learn by reading. We can help _them_.

All 6 comments

Hi Courtney, in general it鈥榮 a good idea, but the readme imo shouldn鈥檛 be the place to educate people about security best practices, and I鈥榤 trying to keep it as dense as possible. The impression (from issues we get) I got is that people often do not read the readme/documentation and I鈥榤 afraid it won鈥檛 get better if we add more things to it.

We do try to maintain a useful wiki, how about adding to that?

Related: Chrome started to make SameSite: lax a default, might be worth to mention..

@courtneyaschwartz Not sure what you had in mind though.. after rereading this it might have been adding just a bit to the converters section?

@carhartl Yes, a reminder about the new requirements about SameSite: None and converters would be good. (Like your existing reminder about InternetGetCookie and domain...)

And... This README can't possibly completely cover all of security. :) I am only suggesting a minimal hint, like your comments:

Cookies.get('foo', { domain: 'sub.example.com' }) //domainwon't have any effect...!

10% of people never read anything. We can't help that... But they'll ask experts for help. Experts learn by reading. We can help _them_.

@courtneyaschwartz Cool! If you would like to send a PR with these improvements you have in mind that would be much appreciated.. thank you!

Sure, no problem. Probably tonight.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oninross picture oninross  路  9Comments

czebe picture czebe  路  3Comments

columbian-chris picture columbian-chris  路  4Comments

nanndemoiikara picture nanndemoiikara  路  5Comments

edwardfhsiao picture edwardfhsiao  路  8Comments