Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

Revert "fix(bidi): prevent prototype pollution in BiDi deserialization" (#41346)

Yury Semikhatskyb1aef233dd16
diff --git a/packages/playwright-core/src/server/bidi/bidiDeserializer.ts b/packages/playwright-core/src/server/bidi/bidiDeserializer.ts
index 10aa5314ea..bd09192d65 100644
--- a/packages/playwright-core/src/server/bidi/bidiDeserializer.ts
+++ b/packages/playwright-core/src/server/bidi/bidiDeserializer.ts
@@ -102,7 +102,7 @@ function deserializeBidiMapping(
bidiValue: bidi.Script.ObjectRemoteValue | bidi.Script.MapRemoteValue,
internalIdMap: Map<bidi.Script.InternalId, any>
) {
- const result = getValue(bidiValue, internalIdMap, () => Object.create(null));
+ const result = getValue(bidiValue, internalIdMap, () => ({}));
for (const [serializedKey, serializedValue] of bidiValue.value || []) {
const key =
typeof serializedKey === 'string'
diff --git a/tests/page/page-evaluate.spec.ts b/tests/page/page-evaluate.spec.ts
index 91737ca7d9..39ad0d027f 100644
--- a/tests/page/page-evaluate.spec.ts
+++ b/tests/page/page-evaluate.spec.ts
@@ -875,15 +875,3 @@ it('should ignore dangerous object keys', async ({ page }) => {
const result = await page.evaluate(arg => arg, input);
expect(result).toEqual({ safeKey: 'safeValue' });
});
-
-it('should not pollute Object.prototype when returning __proto__ key', async ({ page }) => {
- const result = await page.evaluate(() => {
- const obj = Object.create(null);
- Object.defineProperty(obj, '__proto__', { value: { polluted: true }, enumerable: true });
- obj['safeKey'] = 'safeValue';
- return obj;
- });
- // Verify Object.prototype was not polluted
- expect(({} as any).polluted).toBeUndefined();
- expect(result['safeKey']).toBe('safeValue');
-});