Skip to content

[v7.x] fix(decompress): treat inherited Object.prototype names as unsupported encodings (#5807) - #6024

Open
mrityunjay-pandey wants to merge 1 commit into
nodejs:v7.xfrom
mrityunjay-pandey:backport/v7.x-decompress-proto
Open

mrityunjay-pandey wants to merge 1 commit into
nodejs:v7.xfrom
mrityunjay-pandey:backport/v7.x-decompress-proto

Conversation

@mrityunjay-pandey

Copy link
Copy Markdown

This relates to...

Backport of #5807 to v7.x.

Rationale

supportedEncodings in lib/interceptor/decompress.js is a plain object literal on v7.x too, so Content-Encoding: constructor or __proto__ resolves through the prototype chain. With the tests from #5807 applied to v7.x, the constructor and gzip, constructor cases never settle and __proto__ throws out of the interceptor (3 failing tests, the run hits the timeout).

Changes

Features

N/A

Bug Fixes

  • The decompress interceptor passes through Object.prototype names as unsupported encodings instead of hanging or throwing.

Breaking Changes and Deprecations

N/A

Status

Tested locally on Linux with Node 24: node --test test/interceptors/decompress.js (48 pass), npm run lint and npm run test:unit (1324 tests, 1321 pass, 3 skipped, 0 fail).

…d encodings (nodejs#5807)

supportedEncodings is a plain object literal, so the guard

  if (!supportedEncodings[encoding])

resolves inherited names through the prototype chain instead of rejecting
them. onResponseStart lowercases the header first, which leaves exactly two
reachable from the wire: constructor and __proto__.

A response carrying Content-Encoding: constructor calls Object(), pushes the
plain object it returns into the decompressor chain, and the request then
never settles; __proto__ throws TypeError out of the interceptor. Give the
table a null prototype so only its own entries can match.

(cherry picked from commit ca5111e)
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.15%. Comparing base (7d60c7b) to head (b986a7a).

Additional details and impacted files
@@           Coverage Diff           @@
##             v7.x    #6024   +/-   ##
=======================================
  Coverage   93.15%   93.15%           
=======================================
  Files         112      112           
  Lines       37626    37627    +1     
=======================================
+ Hits        35052    35053    +1     
  Misses       2574     2574           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants