Skip to content

Commit a06091a

Browse files
committed
Limit memory allocation of get_bytes to 1MB
If get_bytes() can pad unlimited, a RSA pub key could be crafted that would allocate GB's of nulls, thereby forming a DoS-vector. paramiko/paramiko@3bbcf80
1 parent e9a9ffa commit a06091a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

message.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ paramikojs.Message.prototype = {
7373
get_bytes : function(n) {
7474
var b = this.packet.substring(this.position, this.position + n);
7575
this.position += n;
76-
if (b.length < n) {
76+
var max_pad_size = 1 << 20; // Limit padding to 1 MB
77+
if (b.length < n && n < max_pad_size) {
7778
return b + new Array(n - b.length + 1).join('\x00');
7879
}
7980
return b;

0 commit comments

Comments
 (0)