Cookie version 0.4.0 represents a significant update to the popular "cookie" library, a utility designed for parsing and serializing HTTP cookies in Node.js environments. Released in May 2019, it builds upon the foundation of the earlier 0.3.1 version, which was published in May 2016, introducing several improvements that enhance the developer experience and address modern coding standards.
A key difference lies in the development dependencies. Version 0.4.0 incorporates a more comprehensive suite of tools, including eslint for code linting, benchmark and beautify-benchmark for performance analysis, and eslint-plugin-markdown for linting Markdown files within the project. These additions suggest a focus on code quality, maintainability, and performance optimization. The older version relied solely on mocha and istanbul for testing and code coverage.
While both versions share the same core functionality, author and MIT license, the updated repository URL in 0.4.0 (from https://github.com/jshttp/cookie to git+https://github.com/jshttp/cookie.git) indicates a potential shift in repository management. Developers migrating to 0.4.0 should appreciate the increased focus on code quality evident in the added development dependencies. If performance is critical in your application, the inclusion of benchmarking tools in version 0.4.0 allows for the comparison of the impact of the cookie library. This makes version 0.4.0 a more robust choice.
All the vulnerabilities related to the version 0.4.0 of the package
cookie accepts cookie name, path, and domain with out of bounds characters
The cookie name could be used to set other fields of the cookie, resulting in an unexpected cookie value. For example, serialize("userName=<script>alert('XSS3')</script>; Max-Age=2592000; a", value)
would result in "userName=<script>alert('XSS3')</script>; Max-Age=2592000; a=test"
, setting userName
cookie to <script>
and ignoring value
.
A similar escape can be used for path
and domain
, which could be abused to alter other fields of the cookie.
Upgrade to 0.7.0, which updates the validation for name
, path
, and domain
.
Avoid passing untrusted or arbitrary values for these fields, ensure they are set by the application instead of user input.