Skip to content

Commit

Permalink
Re-add the __proto__.polluted check that was removed by mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
syhol committed Sep 26, 2023
1 parent c91cd6b commit b64323b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions library/src/schemas/record/record.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ describe('record', () => {
test('should prevent prototype pollution', () => {
const schema = record(string(), any());
const input = JSON.parse('{"__proto__":{"polluted":"yes"}}');
expect(input.__proto__.polluted).toBe('yes');
expect(({} as any).polluted).toBeUndefined();
const output = parse(schema, input);
expect(output.__proto__?.polluted).toBeUndefined();
Expand Down
1 change: 1 addition & 0 deletions library/src/schemas/record/recordAsync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ describe('recordAsync', () => {
test('should prevent prototype pollution', async () => {
const schema = recordAsync(string(), any());
const input = JSON.parse('{"__proto__":{"polluted":"yes"}}');
expect(input.__proto__.polluted).toBe('yes');
expect(({} as any).polluted).toBeUndefined();
const output = await parseAsync(schema, input);
expect(output.__proto__?.polluted).toBeUndefined();
Expand Down

0 comments on commit b64323b

Please sign in to comment.