Skip to content

Commit 31a6c6e

Browse files
committed
Explicitly handle __proto__. Closes #21
1 parent 2f386a5 commit 31a6c6e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ exports.disposition = function (header) {
9696
const result = {};
9797
parameters.replace(internals.contentDispositionParamRegex, ($0, $1, $2, $3, $4, $5) => {
9898

99+
if ($1 === '__proto__') {
100+
throw Boom.badRequest('Invalid content-disposition header format includes invalid parameters');
101+
}
102+
99103
if ($2) {
100104
if (!$3) {
101105
throw Boom.badRequest('Invalid content-disposition header format includes invalid parameters');

test/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,10 @@ describe('disposition()', () => {
163163
const header = 'form-data; filename=x';
164164
expect(() => Content.disposition(header)).to.throw('Invalid content-disposition header missing name parameter');
165165
});
166+
167+
it('errors on __proto__ param', () => {
168+
169+
const header = 'form-data; name="file"; filename=file.jpg; __proto__=x';
170+
expect(() => Content.disposition(header)).to.throw('Invalid content-disposition header format includes invalid parameters');
171+
});
166172
});

0 commit comments

Comments
 (0)