Repository navigation
fix(tarball): bound gzip size hints - #12993
Conversation
|
Warning Review limit reached
Next review available in: 16 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughPacquet caps untrusted gzip and zip preallocation hints at 64 MiB. Gzip hints are filtered before configuring decompression, zip entry sizes are clamped, tests cover boundary behavior, and a patch changeset documents the update. ChangesPacquet preallocation bounds
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12993 +/- ##
==========================================
- Coverage 85.45% 85.45% -0.01%
==========================================
Files 501 501
Lines 80654 80657 +3
==========================================
+ Hits 68924 68926 +2
- Misses 11730 11731 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.65739056144,
"stddev": 0.19326845903938733,
"median": 2.63905232854,
"user": 2.3957043199999997,
"system": 1.8346377399999998,
"min": 2.4449414730399996,
"max": 2.92084054904,
"times": [
2.69044367604,
2.92084054904,
2.9030476090399997,
2.8980534530399997,
2.49336641804,
2.47733580304,
2.58766098104,
2.46545700104,
2.69275865104,
2.4449414730399996
]
},
{
"command": "pacquet@main",
"mean": 2.59012812644,
"stddev": 0.1565464804471143,
"median": 2.52465565704,
"user": 2.28990192,
"system": 1.7871142400000004,
"min": 2.4474786210399997,
"max": 2.8334004340399996,
"times": [
2.4601108410399997,
2.6023267620399997,
2.5091326820399997,
2.77021214604,
2.8334004340399996,
2.46748516104,
2.4575206650399997,
2.4474786210399997,
2.81343532004,
2.54017863204
]
},
{
"command": "pnpr@HEAD",
"mean": 1.63111444834,
"stddev": 0.1430856327216798,
"median": 1.64561331654,
"user": 1.61473482,
"system": 1.5215756399999996,
"min": 1.40446487804,
"max": 1.8210823200400001,
"times": [
1.52765914304,
1.76049049104,
1.66441084404,
1.40446487804,
1.8210823200400001,
1.4183341630400002,
1.73773695904,
1.62681578904,
1.73723005604,
1.6129198400400002
]
},
{
"command": "pnpr@main",
"mean": 1.6339826541399998,
"stddev": 0.17121594174723997,
"median": 1.64630946754,
"user": 1.6678167199999998,
"system": 1.5754921400000002,
"min": 1.41130198004,
"max": 1.94026168504,
"times": [
1.67596788904,
1.42866249504,
1.7630242720400002,
1.41130198004,
1.57524953304,
1.44990889704,
1.74176719004,
1.73703155404,
1.61665104604,
1.94026168504
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.31145705100000004,
"stddev": 0.037655765460563616,
"median": 0.29954296750000003,
"user": 0.26784232,
"system": 0.60229514,
"min": 0.26777122400000003,
"max": 0.39317340500000003,
"times": [
0.32232433200000005,
0.29644486500000006,
0.28527989800000003,
0.30226445,
0.28418772500000006,
0.26777122400000003,
0.29682148500000005,
0.30903449800000005,
0.35726862800000003,
0.39317340500000003
]
},
{
"command": "pacquet@main",
"mean": 0.35605429090000007,
"stddev": 0.0136564562503561,
"median": 0.35218526150000007,
"user": 0.30461511999999996,
"system": 0.68203394,
"min": 0.34234915800000004,
"max": 0.38496822,
"times": [
0.34404496300000004,
0.35480864500000003,
0.35731777300000006,
0.34234915800000004,
0.35284206900000004,
0.37499772600000003,
0.34623440000000005,
0.35152845400000005,
0.38496822,
0.35145150100000005
]
},
{
"command": "pnpr@HEAD",
"mean": 0.36054417550000006,
"stddev": 0.013723071816906893,
"median": 0.35987195450000004,
"user": 0.30039472,
"system": 0.6692095399999999,
"min": 0.34222162300000003,
"max": 0.39197832600000004,
"times": [
0.36014051900000005,
0.366302047,
0.369703822,
0.34926926900000005,
0.35287884500000005,
0.35236421,
0.39197832600000004,
0.35960339,
0.34222162300000003,
0.360979704
]
},
{
"command": "pnpr@main",
"mean": 0.34422062150000005,
"stddev": 0.012335081321216409,
"median": 0.34420309200000004,
"user": 0.28757341999999997,
"system": 0.64493434,
"min": 0.33139603300000003,
"max": 0.36517076500000006,
"times": [
0.35326499100000003,
0.36098962100000004,
0.34448554800000003,
0.34392063600000006,
0.33197658100000005,
0.36517076500000006,
0.33219838100000004,
0.34496766500000003,
0.333835994,
0.33139603300000003
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.8970082435400006,
"stddev": 0.04279188513088855,
"median": 2.90350565024,
"user": 2.4444551,
"system": 1.8223485999999998,
"min": 2.80930282674,
"max": 2.9660474007400004,
"times": [
2.80930282674,
2.9660474007400004,
2.9228015597400003,
2.89670568174,
2.87658757374,
2.8766965147400003,
2.86609826774,
2.9103056187400003,
2.92856844274,
2.9169685487400003
]
},
{
"command": "pacquet@main",
"mean": 2.8471213850400003,
"stddev": 0.060281885720403654,
"median": 2.8342537392400002,
"user": 2.3079247,
"system": 1.6686738,
"min": 2.7836878727400003,
"max": 2.95184578274,
"times": [
2.82926037474,
2.84543301274,
2.83924710374,
2.8693780607400003,
2.7836878727400003,
2.81833589374,
2.78518343574,
2.80134776074,
2.95184578274,
2.9474945527400003
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6237310741399997,
"stddev": 0.13818841120349495,
"median": 1.58720417974,
"user": 1.7100009,
"system": 1.6140923,
"min": 1.4833449657400002,
"max": 1.8859091877400003,
"times": [
1.54082988674,
1.8372606527400002,
1.51787537574,
1.6529700517400001,
1.8859091877400003,
1.55923981274,
1.61516854674,
1.64083848774,
1.50387377374,
1.4833449657400002
]
},
{
"command": "pnpr@main",
"mean": 1.6986828253400001,
"stddev": 0.12096439537901121,
"median": 1.69447215974,
"user": 1.5767601,
"system": 1.4813449,
"min": 1.49113188874,
"max": 1.8517738977400002,
"times": [
1.49113188874,
1.84824769374,
1.6530139787400002,
1.7565700907400001,
1.6428846537400001,
1.55086448874,
1.72099293374,
1.8033972417400002,
1.6679513857400001,
1.8517738977400002
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6192824396400001,
"stddev": 0.04629313909255523,
"median": 0.6229767096400001,
"user": 0.8037636799999998,
"system": 0.7408885399999997,
"min": 0.56048872864,
"max": 0.70788732164,
"times": [
0.56700699664,
0.58611606064,
0.61901202664,
0.70788732164,
0.6393703886400001,
0.62694139264,
0.64203092964,
0.66168964264,
0.56048872864,
0.58228090864
]
},
{
"command": "pacquet@main",
"mean": 0.57117032184,
"stddev": 0.032362030163673124,
"median": 0.5629271091400001,
"user": 0.7238951799999999,
"system": 0.71758494,
"min": 0.54364161764,
"max": 0.65495898764,
"times": [
0.58740975864,
0.55109517464,
0.55874271264,
0.5661604006400001,
0.57577880964,
0.54586854564,
0.54364161764,
0.55969381764,
0.56835339364,
0.65495898764
]
},
{
"command": "pnpr@HEAD",
"mean": 0.31557349043999994,
"stddev": 0.018823788591652586,
"median": 0.31567765414000004,
"user": 0.21056017999999996,
"system": 0.54590924,
"min": 0.28857818264,
"max": 0.34496386264,
"times": [
0.34496386264,
0.32219624464,
0.33415917564,
0.29695051664,
0.31691530264,
0.29974594464,
0.28857818264,
0.31444000564,
0.30179402964,
0.33599163964
]
},
{
"command": "pnpr@main",
"mean": 0.3102248663399999,
"stddev": 0.016582161034069072,
"median": 0.30795546314,
"user": 0.19413507999999996,
"system": 0.5398469399999999,
"min": 0.28841465364,
"max": 0.34213715964,
"times": [
0.34213715964,
0.33131449664,
0.31580039864,
0.30776363564,
0.30814729064,
0.29895118364,
0.30102865964,
0.31468004564,
0.28841465364,
0.29401113964
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.9286401799,
"stddev": 0.04532661533811079,
"median": 1.9257021572,
"user": 1.06966976,
"system": 0.8727502399999999,
"min": 1.8742246827,
"max": 2.0161817857,
"times": [
1.9845043437000003,
1.9365270817,
1.8868664527,
1.9429473297000002,
1.9348032287,
1.9166010857,
1.9131816447,
1.8805641637000001,
1.8742246827,
2.0161817857
]
},
{
"command": "pacquet@main",
"mean": 1.8918243022000003,
"stddev": 0.04559765612402977,
"median": 1.8815538172000001,
"user": 1.0258950599999999,
"system": 0.8484582399999999,
"min": 1.8220881847000001,
"max": 1.9740174977000002,
"times": [
1.9468696277000002,
1.9740174977000002,
1.9265476967000001,
1.8822653347,
1.8976365417,
1.8571095507000002,
1.8220881847000001,
1.8808422997000003,
1.8680699947000001,
1.8627962937000002
]
},
{
"command": "pnpr@HEAD",
"mean": 0.290298283,
"stddev": 0.013775612840605692,
"median": 0.28584151570000005,
"user": 0.16644145999999999,
"system": 0.5199101399999999,
"min": 0.27210727370000004,
"max": 0.31403943170000004,
"times": [
0.28129954570000004,
0.2894467047,
0.27210727370000004,
0.3020386097,
0.30965979870000004,
0.28091566570000004,
0.2827720067,
0.28179276870000003,
0.31403943170000004,
0.2889110247
]
},
{
"command": "pnpr@main",
"mean": 0.30543456179999995,
"stddev": 0.01520131631038301,
"median": 0.3106384057,
"user": 0.20054165999999998,
"system": 0.52912924,
"min": 0.28005967470000004,
"max": 0.3206407337,
"times": [
0.28005967470000004,
0.2999075037,
0.3147216667,
0.3086533167,
0.3126234947,
0.32046350770000004,
0.3206407337,
0.32036938670000004,
0.2886919157,
0.2882144177
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.35251358476,
"stddev": 0.030219305740509406,
"median": 0.34258810936,
"user": 0.33590887999999997,
"system": 0.08349700000000002,
"min": 0.32757882386000003,
"max": 0.41230227186,
"times": [
0.35046281786,
0.32757882386000003,
0.40398691386,
0.41230227186,
0.34549678186,
0.33967943686,
0.34552465186000003,
0.33275673686,
0.33536310886000004,
0.33198430386
]
},
{
"command": "pacquet@main",
"mean": 0.38615761996,
"stddev": 0.015979763358612786,
"median": 0.38516012536,
"user": 0.36741008,
"system": 0.097607,
"min": 0.35751350786,
"max": 0.41219951586000003,
"times": [
0.35751350786,
0.39591496186,
0.38516776386,
0.38397381486000004,
0.36865177186000003,
0.37889165686000004,
0.40415376786,
0.41219951586000003,
0.38995695186,
0.38515248686000003
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08713043882969695,
"stddev": 0.003397194852585654,
"median": 0.08650698386000001,
"user": 0.01830130121212121,
"system": 0.012586803030303026,
"min": 0.08272759886000002,
"max": 0.10232726986000001,
"times": [
0.08509635686000001,
0.08650698386000001,
0.08652619586000002,
0.08742821986000002,
0.08532100286000001,
0.08315959986000002,
0.08838189086,
0.08455760386000001,
0.08524421186000002,
0.08796593486000001,
0.08878542086,
0.08628673786,
0.08572355186000001,
0.08687182286000002,
0.08272759886000002,
0.08591173686,
0.09032899486000001,
0.09025852286000001,
0.08506846786000001,
0.08884734386000001,
0.08520492686000002,
0.08904183486000002,
0.08291990986000002,
0.08603692686000002,
0.08683315386000001,
0.08525632986000001,
0.08543921386000002,
0.09001161186000001,
0.08700469186000001,
0.08829201786000002,
0.08946938786000001,
0.08646900686000002,
0.10232726986000001
]
},
{
"command": "pnpr@main",
"mean": 0.09108202599333333,
"stddev": 0.004089490806947493,
"median": 0.09003404536000001,
"user": 0.01940421333333333,
"system": 0.01504715,
"min": 0.08465973386000002,
"max": 0.10148767386000002,
"times": [
0.09038175086000001,
0.09049870886000001,
0.09099249186000001,
0.09675302386000001,
0.09490320786,
0.08862326886,
0.09346033386000001,
0.09396047286,
0.08780898486000001,
0.08642372586000001,
0.08465973386000002,
0.08693388586,
0.10148767386000002,
0.08865498086000001,
0.08775720286000001,
0.09778363186000001,
0.09266323186000001,
0.08658073886,
0.08798925886000002,
0.08787616686000001,
0.09611517986000001,
0.09466005786000001,
0.09486655586000001,
0.08694239586000001,
0.08704426886000001,
0.08968633986,
0.09461790686000002,
0.08944110386000001,
0.09373799686,
0.08915649886000002
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.69351045676,
"stddev": 0.1444423508069782,
"median": 4.66506967506,
"user": 2.4205289,
"system": 1.8231519799999998,
"min": 4.519257480059999,
"max": 4.93325840106,
"times": [
4.82312229206,
4.519257480059999,
4.93325840106,
4.624556968059999,
4.81659558106,
4.55283488806,
4.53890646506,
4.80747624906,
4.70558238206,
4.6135138610599995
]
},
{
"command": "pacquet@main",
"mean": 4.728085576659999,
"stddev": 0.21476393104465027,
"median": 4.654477571059999,
"user": 2.5789649,
"system": 1.93682008,
"min": 4.48968599806,
"max": 5.08993308306,
"times": [
5.07116035706,
4.62775807006,
4.81875995106,
4.59145715706,
5.08993308306,
4.61072079506,
4.7993392970599995,
4.50084398606,
4.48968599806,
4.68119707206
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5811489337599993,
"stddev": 0.08816031796032221,
"median": 3.5491528345599996,
"user": 1.6814489,
"system": 1.52637218,
"min": 3.47913501706,
"max": 3.75789762506,
"times": [
3.75789762506,
3.47913501706,
3.5389355270599996,
3.60187637806,
3.5461892950599996,
3.5521163740599997,
3.50982495806,
3.5056666970599997,
3.6803070080599998,
3.63954045806
]
},
{
"command": "pnpr@main",
"mean": 3.7253112439600002,
"stddev": 0.14261204498953264,
"median": 3.68734963506,
"user": 2.0731687,
"system": 1.9062899799999997,
"min": 3.58872830906,
"max": 3.99048952706,
"times": [
3.65654353606,
3.58872830906,
3.7244285800599997,
3.59047002706,
3.6336585430599997,
3.69822932206,
3.99048952706,
3.67646994806,
3.72457499706,
3.9695196500599996
]
}
]
} |
|
| Branch | pr/12993 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,623.73 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 290.30 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 315.57 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 87.13 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,631.11 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,581.15 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 360.54 ms |
243063a to
a1541d0
Compare
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Confidence Score: 4/5The security fix is structurally sound — no attacker-controlled value can drive an arbitrarily large eager allocation. One aspect needs explicit resolution before merging: the new gzip helper clamps oversized hints to 64 MiB, while the PR description and squash commit body claim they are omitted (returning no hint). Either the code should be updated to filter rather than clamp, or the description/tests should be updated to reflect clamping. The core security property is achieved, and the codebase is internally consistent (code and tests agree on clamping). However, the squash commit body says "omitted rather than clamped," which would be a permanent factual error in git history. Resolving whether the intended behavior is clamp or omit is the one outstanding question before this is ready to merge. pnpm/crates/tarball/src/lib.rs — the bounded_gzip_size_hint function and its description need to agree on whether oversized hints are clamped or omitted. Reviews (5): Last reviewed commit: "docs(tarball): trim preallocation commen..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.changeset/bound-pacquet-gzip-hints.md:
- Line 5: Update the changeset description to document the 64 MiB limit for both
registry-provided gzip preallocation hints and untrusted ZIP entry size hints,
preserving the existing scope and release-note context.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3f26a6fb-639f-4152-b118-0456e2a04a2c
📒 Files selected for processing (3)
.changeset/bound-pacquet-gzip-hints.mdpnpm/crates/tarball/src/lib.rspnpm/crates/tarball/src/tests.rs
a1541d0 to
f2406a7
Compare
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1. Oversized hint forces 64MiB
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pnpm/crates/tarball/src/lib.rs (1)
2462-2474: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winExtract unrelated changes to maintain scope discipline.
The PR objective indicates that this PR is dedicated to bounding gzip size hints to prevent oversized preallocations. However, it also bundles an unrelated error code refactor and a new
manifest_subdirresolution feature. As per path instructions fromREVIEW_GUIDE.md, please strictly follow scope discipline by limiting PRs to one logical change and only touching files justified by the mitigation.Please extract these unrelated changes into separate pull requests:
pnpm/crates/tarball/src/lib.rs#L2462-L2474: revert the addition of themanifest_subdirfield.pnpm/crates/tarball/src/lib.rs#L148-L152: revert the diagnostic error code renames (and the corresponding renames on the remaining variants).pnpm/crates/tarball/src/lib.rs#L2512-L2546: revert themanifest_subdirmatching and store index suppression logic.pnpm/crates/tarball/src/lib.rs#L2558-L2589: revert theread_subdir_manifesthelper function.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm/crates/tarball/src/lib.rs` around lines 2462 - 2474, Limit this PR to the gzip size-hint bounding change by reverting the unrelated additions in pnpm/crates/tarball/src/lib.rs: remove manifest_subdir at lines 2462-2474, restore the original diagnostic error codes and remaining variants at lines 148-152, remove manifest_subdir matching and store-index suppression at lines 2512-2546, and remove the read_subdir_manifest helper at lines 2558-2589.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@pnpm/crates/tarball/src/lib.rs`:
- Around line 2462-2474: Limit this PR to the gzip size-hint bounding change by
reverting the unrelated additions in pnpm/crates/tarball/src/lib.rs: remove
manifest_subdir at lines 2462-2474, restore the original diagnostic error codes
and remaining variants at lines 148-152, remove manifest_subdir matching and
store-index suppression at lines 2512-2546, and remove the read_subdir_manifest
helper at lines 2558-2589.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0e50bef5-83e1-479c-8df8-785f0d5b830c
📒 Files selected for processing (3)
.changeset/bound-pacquet-gzip-hints.mdpnpm/crates/tarball/src/lib.rspnpm/crates/tarball/src/tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- .changeset/bound-pacquet-gzip-hints.md
- pnpm/crates/tarball/src/tests.rs
Hoisting the 64 MiB cap to a shared constant moved it away from the comment that justified it, leaving the rationale at the zip call site while the constant itself carried none. That site also restated "64 MiB" in prose directly above the named constant, which is the drift the shared constant exists to prevent. State the why once at the constant: both hint sources are attacker-controlled, and post-download work runs concurrently, so a per-task reservation is multiplied across every task in flight. Document why the gzip path drops an oversized hint instead of clamping it, since the two call sites deliberately differ. zune-inflate turns the hint into an infallible zero-filled `vec![0; hint]`, so clamping would let any package that overstates its size pin the whole ceiling up front. The zip path can clamp because its `try_reserve` reports a refusal as an error rather than aborting.
The existing test exercises `bounded_gzip_size_hint` in isolation, so nothing caught `decompress_gzip` forwarding `dist.unpackedSize` straight to zune-inflate — the security-relevant wiring the fix depends on. Decompress a real gzip payload with an oversized hint and assert the output. Verified the test bites by reverting the guard: it fails on the unbounded `vec![0; hint]` reservation.
|
Code review by qodo was updated up to the latest commit 4b0f5a2 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
|
Rebased onto the latest The fix itself holds up. I traced the path to confirm it is genuinely reachable rather than theoretical: Three automated findings are being declined, with reasons: Qodo: "Changeset missing
|
Dropping an oversized `dist.unpackedSize` bounded the eager allocation but also discarded the hint for genuinely large packages, leaving them to grow from zune-inflate's 37 KB default in 4 KiB steps. Measured on an 80 MiB package: 72.3 ms dropped vs 11.4 ms clamped, a ~6x regression on the install hot path for every package above the ceiling. Clamping reaches the same ceiling. A lying hint reserves at most 64 MiB, and `vec![0; 64 MiB]` is lazily backed, so untouched pages never become resident: 20 concurrent tiny packages each claiming `usize::MAX` hold +0.7 MiB RSS, against +1280 MiB were the pages eager. The decoder still grows on demand, so an archive larger than the ceiling decodes in full — verified by round-tripping 80 MiB through `decompress_gzip`. This also makes the fix the smallest correct one: behavior now changes only for figures above the ceiling, and matches the sibling zip entry reservation, which has always clamped against the same bound.
|
Correcting my earlier comment: I defended the "drop the hint rather than clamp it" choice there, and measurement showed that reasoning was wrong. Switched to clamping in 4cd4bc7. Two claims I made without measuring, both of which turned out to be false: "Dropping the hint costs only buffer growth." It costs ~6x. With no hint, zune-inflate starts from its 37 KB default and resizes in 4 KiB steps — roughly 20,000 resizes for an 80 MiB package. Release build, best-of-3, decompressing 80 MiB:
Packages under the ceiling are unaffected either way — the hint passes through untouched — so this only hit the >64 MiB tail. But that tail is real (Electron, Playwright, Cypress, prebuilt native binaries) and it sits on the install hot path, which "Clamping would let every package that overstates its size pin the whole ceiling up front." It does not. Clamping costs ~+0.6 MiB RSS over dropping, for a ~6x decode speedup. So clamping reaches the same 64 MiB ceiling, keeps the reservation the hint exists for, and is the smaller change: behavior now differs from pre-fix code only for figures above the ceiling, rather than also penalizing honest large packages. It also matches the sibling zip entry reservation, which has always clamped against this same bound — the two paths no longer diverge, which removes the asymmetry I documented in 638c19f. Verified an archive above the ceiling still decodes in full — 80 MiB round-tripped through Boundary tests updated: Written by an agent (Claude Code, claude-opus-4-8). |
|
Code review by qodo was updated up to the latest commit 4cd4bc7 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
The ceiling's doc justified clamping by contrasting it against dropping the hint, an alternative that exists only in this branch's history and that a reader of the merged code cannot see. It also pinned zune-inflate internals (a 37 KB default, 4 KiB growth steps) that will rot. State the guarantee instead: the bound applies to the reservation, not the output. `bounded_gzip_size_hint` opened by narrating its own body, and the wiring test restated both the callee's rationale and its own assertion. Keep the gzip-specific why on the helper, and let the test's doc carry only the reason it exists next to the helper's unit test.
|
Code review by qodo was updated up to the latest commit 0c58e3d |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
| fn bounded_gzip_size_hint(unpacked_size: Option<usize>) -> Option<usize> { | ||
| unpacked_size.map(|size| size.min(MAX_UNTRUSTED_PREALLOC_BYTES)) | ||
| } |
There was a problem hiding this comment.
Clamps rather than omits oversized hints
The PR description and squash commit body both say "Hints above the ceiling are omitted rather than clamped, allowing legitimate large archives to keep decoding through normal buffer growth." The implementation does the opposite: .min(MAX_UNTRUSTED_PREALLOC_BYTES) always returns Some(64 MiB) for oversized inputs. With many concurrent downloads of large packages each hint-over-limit task still eagerly reserves 64 MiB upfront. The tests also assert the clamping behavior.
If the intent is truly to omit oversized hints (so no eager allocation occurs for hints beyond the ceiling), the function body should use .filter instead: unpacked_size.filter(|&size| size <= MAX_UNTRUSTED_PREALLOC_BYTES). If clamping is the deliberate design, the PR description, squash commit body, and test assertions all need to be updated to say "clamped" rather than "omitted."
There was a problem hiding this comment.
Good catch, and thank you — the second reading is right: clamping is deliberate, and the prose was stale. I switched the implementation from omitting to clamping in 4cd4bc7 and failed to update the description alongside it.
Fixed by updating the Summary and the Squash Commit Body, which now describe clamping and carry the measurements behind the choice. That mattered more than a stale description: the Squash Commit Body becomes the permanent commit message on main, so merging as-is would have written a false record into git history. The test assertions already match the implementation, so they stand as-is.
On the memory concern — "with many concurrent downloads of large packages each hint-over-limit task still eagerly reserves 64 MiB upfront" — that was my worry too, and it's why the code originally omitted. It does not hold up under measurement. vec![0; 64 MiB] is lazily backed, so pages the decoder never writes never become resident. With 20 concurrent tiny packages each claiming usize::MAX (matching post_download_semaphore's num_cpus * 2), every buffer held alive at once:
20 lying pkgs (usize::MAX hint) held: RSS +0.7 MiB (eager would be +1280 MiB)
Clamping costs ~+0.6 MiB RSS over omitting, and buys ~6x on decode: an 80 MiB package goes from 72.3 ms to 11.4 ms, because an omitted hint leaves the decoder growing from its 37 KB default in 4 KiB steps. Full numbers are in the description.
Worth flagging the one limit of that evidence: it is measured on macOS. Linux and macOS both mmap large allocations with lazily-zeroed pages, so it should carry over, but two configurations charge committed memory even when untouched — Linux with vm.overcommit_memory=2, and Windows commit charge. I judged that acceptable because the sibling zip entry reservation has always clamped against this same 64 MiB bound, so clamping the gzip hint introduces no exposure the module did not already accept.
Written by an agent (Claude Code, claude-opus-4-8).
Summary
Registry metadata can supply an arbitrary
dist.unpackedSize, and pacquet passed that value directly to zune-inflate as an eager output-buffer allocation hint. zune-inflate reserves the hint as an infallible zero-filledvec![0; hint], so an arbitrary registry figure aborts the process rather than failing gracefully — multiplied across concurrent post-download tasks.The TypeScript CLI does not use
dist.unpackedSizeas a decompressor allocation hint, so no TypeScript-side change is needed.Why clamp rather than omit
Omitting an oversized hint also bounds the allocation, but discards the pre-sizing for honest large packages, which then grow from zune-inflate's 37 KB default in 4 KiB steps. Decompressing an 80 MiB package (release, best-of-3):
Clamping is safe from a memory-consumption perspective:
vec![0; 64 MiB]is lazily backed, so pages the decoder never writes never become resident. With 20 concurrent tiny packages each claimingusize::MAX(matchingpost_download_semaphore'snum_cpus * 2), every buffer held alive at once:Clamping therefore keeps the change to the smallest correct one — behavior differs from the pre-fix code only for figures above the ceiling — and matches the sibling ZIP entry reservation, which has always clamped against this same bound.
Verified with:
cargo test --locked -p pacquet-tarball --lib(74 passed)decompress_gzipwith a truthful over-ceiling hint, length and content assertedcargo fmt --all --checkcargo clippy --locked -p pacquet-tarball --all-targets -- --deny warningsRUSTDOCFLAGS=-D warnings cargo doc --locked -p pacquet-tarball --no-depstypos pnpm/crates/tarball .changeset/bound-pacquet-gzip-hints.mdSquash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Codex, GPT-5).
Description and squash body revised by an agent (Claude Code, claude-opus-4-8) after the clamp change.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit