Uh oh!
There was an error while loading. Please reload this page.
zlib: prevent uncaught exception in zlibBuffer - #1811
Conversation
cjihrig
commented
May 27, 2015
Can you add a test? |
There was a problem hiding this comment.
Could you do something more like:
err=null;try{buf=Buffer.concat(buffers,nread);}catch(e){err=e;}buffers=[];engine.close();callback(err,buf);targos
commented
May 27, 2015
Do you mean test that the error is correctly caught ? |
cjihrig
commented
May 28, 2015
There is an upcoming |
trevnorris
commented
Jun 4, 2015
The check should be there. But if we're confident that nread is the length of all buffers then only need to check it against kMaxLength, and return an error if greater than. No need for the try catch. |
targos
commented
Jun 4, 2015
@trevnorris Good point, I made that change. Also added a check in the sync code to generate the same error. |
trevnorris
commented
Jun 4, 2015
True. And that may be a problem on ARM devices. @rvagg Thoughts? |
rvagg
commented
Jun 4, 2015
yeah, that's not going to be a happy time on the small devices, if it must be tested I guess you might want to first test for the amount of system memory available, but that's also going to be tricky for cross-platform support, the alternative is to just skip it if arch == arm, but there's also mips (tessel) and Windows 10 on rpi and Atom and ... |
chrisdickinson
commented
Jun 4, 2015
My vote would be to make an internal module ( |
trevnorris
commented
Jun 4, 2015
that may be possible by |
targos
commented
Jun 5, 2015
@trevnorris your proposal is working, thanks! I added a test. |
trevnorris
commented
Jun 5, 2015
One more addition to the test. Can you set it back to the original value of |
targos
commented
Jun 6, 2015
Done. Can somebody start a CI? |
brendanashworth
commented
Jun 8, 2015
targos
commented
Jun 10, 2015
All green! LGTY ? |
trevnorris
commented
Jun 10, 2015
LGTM @indutny have any objections to this change? |
indutny
commented
Jun 10, 2015
LGTM! It does look like a security concern to me. I think we may want to issue a CVE. What are your thoughts on this? |
trevnorris
commented
Jun 10, 2015
I believe the only issue is that a client could forcefully crash a server. That's not a trivial issue by any means. I'm just not sure if it classifies as security vulnerability or not. If you think it is then cool. Let's do a CVE. |
indutny
commented
Jun 10, 2015
Yeah, but it is a bit trivial do so (see the test). Anyway, how should we fill a CVE cc @nodejs/tsc |
targos
commented
Jun 10, 2015
trevnorris
commented
Jun 10, 2015
Yup. Let's save that for the next one. This one has already been signed off. :-) |
targos
commented
Jun 15, 2015
ping @trevnorris : can this be landed ? |
trevnorris
commented
Jun 15, 2015
dcousens
commented
Jun 15, 2015
Great work all, definitely should have a CVE. |
indutny
commented
Jun 15, 2015
I think we should land it anyway, there is no point in releasing stuff without this ;) I don't have any further comments since I wasn't ever involved in the process of filing CVE. cc @piscisaureus |
If the accumulation of data for the final Buffer is greater than kMaxLength it will throw an un-catchable RangeError. Instead now pass the generated error to the callback. PR-URL: #1811 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
trevnorris
commented
Jun 15, 2015
Landed in 3806d87. Thanks for the patch. |
misterdjules
commented
Jun 17, 2015
@indutny@trevnorris @nodejs/tsc If I understand correctly, this issue also exists in node v0.10.x and node v0.12.x, so before issuing a CVE, I would suggest getting ready to backport and release the changes in this PR into those branches. Is that something you could help with? |
misterdjules
commented
Jun 17, 2015
Created nodejs/node-v0.x-archive#25536 to track that. |
trevnorris
commented
Jun 17, 2015
@misterdjules The fix itself is straight forward, but currently the way to test uses properties on the smalloc module. Not sure how this could be tested on v0.10 without needing to use 1GB of memory. |
PR-URL: #1996 Notable changes * module: The number of syscalls made during a require() have been significantly reduced again (see #1801 from v2.2.0 for previous work), which should lead to a performance improvement (Pierre Inglebert) #1920. * npm: - Upgrade to v2.11.2 (Rebecca Turner) #1956. - Upgrade to v2.11.3 (Forrest L Norvell) #2018. * zlib: A bug was discovered where the process would abort if the final part of a zlib decompression results in a buffer that would exceed the maximum length of 0x3fffffff bytes (~1GiB). This was likely to only occur during buffered decompression (rather than streaming). This is now fixed and will instead result in a thrown RangeError (Michaël Zasso) #1811.
PR-URL: #1996 Notable changes * module: The number of syscalls made during a require() have been significantly reduced again (see #1801 from v2.2.0 for previous work), which should lead to a performance improvement (Pierre Inglebert) #1920. * npm: - Upgrade to v2.11.2 (Rebecca Turner) #1956. - Upgrade to v2.11.3 (Forrest L Norvell) #2018. * zlib: A bug was discovered where the process would abort if the final part of a zlib decompression results in a buffer that would exceed the maximum length of 0x3fffffff bytes (~1GiB). This was likely to only occur during buffered decompression (rather than streaming). This is now fixed and will instead result in a thrown RangeError (Michaël Zasso) #1811.
If the final buffer needs to be larger than kMaxLength, the concatenation fails and there is no way to catch the error:
Testcase : https://gist.github.com/targos/643a802e0ed4fa60f3bd