Skip to content

chore: add minimal age to package installations#270

Merged
Mrtenz merged 3 commits intomainfrom
ellul/min-package-age
Oct 20, 2025
Merged

chore: add minimal age to package installations#270
Mrtenz merged 3 commits intomainfrom
ellul/min-package-age

Conversation

@NicholasEllul
Copy link
Contributor

@NicholasEllul NicholasEllul commented Sep 22, 2025

Summary

This pull request enforces a 3-day minimum release age for all NPM packages. Packages published more recently will be blocked from installation, reducing the risk of supply-chain attacks involving newly compromised releases.

Teams that need exceptions can override this restriction by listing packages under the npmPreapprovedPackages option.

This is a new feature included in yarn v4.10.*


Note

Adds a 3‑day npm package age gate in Yarn with allowlists for @metamask/* and @lavamoat/*, and bumps Yarn to 4.10.3.

  • Supply chain security:
    • Configure Yarn with npmMinimalAgeGate: 4320 and npmPreapprovedPackages for @metamask/* and @lavamoat/* in .yarnrc.yml.
  • Tooling:
    • Update packageManager to yarn@4.10.3 in package.json.

Written by Cursor Bugbot for commit f364f48. This will update automatically on new commits. Configure here.

@NicholasEllul NicholasEllul requested a review from a team as a code owner September 22, 2025 20:59
@NicholasEllul NicholasEllul changed the title feat: add minimal age to package installations chore: add minimal age to package installations Sep 22, 2025
@NicholasEllul NicholasEllul force-pushed the ellul/min-package-age branch 2 times, most recently from 98c532a to 0dd7ca3 Compare September 24, 2025 20:13
Gudahtt
Gudahtt previously approved these changes Sep 24, 2025
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@NicholasEllul NicholasEllul force-pushed the ellul/min-package-age branch from 0dd7ca3 to e1f68b9 Compare October 2, 2025 15:53
cursor[bot]

This comment was marked as outdated.

mcmire
mcmire previously approved these changes Oct 2, 2025
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, LGTM!

@NicholasEllul NicholasEllul requested a review from Gudahtt October 17, 2025 16:55
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Mrtenz Mrtenz enabled auto-merge (squash) October 20, 2025 10:06
@Mrtenz Mrtenz merged commit da75fb7 into main Oct 20, 2025
22 checks passed
@Mrtenz Mrtenz deleted the ellul/min-package-age branch October 20, 2025 10:09
Mrtenz added a commit to MetaMask/core that referenced this pull request Oct 20, 2025
## Explanation

This bumps Yarn to the latest version (`4.10.3`), which includes support
for setting an age gate for NPM packages. It's set to 3 days following
the security recommendations, meaning that packages must be at least 3
days old to be installed.

## References

MetaMask/metamask-module-template#270

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Updates Yarn to 4.10.3 and configures a 3‑day NPM minimal age gate
with preapproved MetaMask and LavaMoat scopes.
> 
> - **Tooling**:
> - **Yarn version**: Require `yarn@4.10.3` in root `package.json` and
enforce via `yarn.config.cjs`.
> - **NPM age gate**: In `.yarnrc.yml`, set `npmMinimalAgeGate: 4320`
and add `npmPreapprovedPackages` for `@metamask/*` and `@lavamoat/*`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
4ce1763. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
github-merge-queue bot pushed a commit to MetaMask/snaps that referenced this pull request Oct 20, 2025
## Explanation

This bumps Yarn to the latest version (`4.10.3`), which includes support
for setting an age gate for NPM packages. It's set to 3 days following
the security recommendations, meaning that packages must be at least 3
days old to be installed.

## References

MetaMask/metamask-module-template#270

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Upgrades Yarn to 4.10.3, adds a 3-day npm age gate with preapproved
packages, and updates related configs and LavaMoat policy references.
> 
> - **Build/Config**:
> - **Yarn upgrade**: Set `yarnPath` and root `packageManager` to
`yarn@4.10.3` in `.yarnrc.yml`, `package.json`, and `yarn.config.cjs`.
> - **NPM age gate**: Add `npmMinimalAgeGate: 4320` and
`npmPreapprovedPackages` (`@metamask/*`, `@lavamoat/*`) in
`.yarnrc.yml`.
> - **LavaMoat policy**:
> - Update `policy.json` to reference `depcheck>readdirp>picomatch`
instead of `ts-loader>micromatch>picomatch` in relevant entries.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
635d8c1. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
github-merge-queue bot pushed a commit to MetaMask/snaps that referenced this pull request Oct 20, 2025
## Explanation

This bumps Yarn to the latest version (`4.10.3`), which includes support
for setting an age gate for NPM packages. It's set to 3 days following
the security recommendations, meaning that packages must be at least 3
days old to be installed.

## References

MetaMask/metamask-module-template#270

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Upgrades Yarn to 4.10.3, adds a 3-day npm age gate with preapproved
packages, and updates related configs and LavaMoat policy references.
> 
> - **Build/Config**:
> - **Yarn upgrade**: Set `yarnPath` and root `packageManager` to
`yarn@4.10.3` in `.yarnrc.yml`, `package.json`, and `yarn.config.cjs`.
> - **NPM age gate**: Add `npmMinimalAgeGate: 4320` and
`npmPreapprovedPackages` (`@metamask/*`, `@lavamoat/*`) in
`.yarnrc.yml`.
> - **LavaMoat policy**:
> - Update `policy.json` to reference `depcheck>readdirp>picomatch`
instead of `ts-loader>micromatch>picomatch` in relevant entries.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
635d8c1. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
github-merge-queue bot pushed a commit to MetaMask/metamask-extension that referenced this pull request Oct 24, 2025
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

This bumps Yarn to the latest version (`4.10.3`), which includes support
for setting an age gate for NPM packages. It's set to 3 days following
the security recommendations, meaning that packages must be at least 3
days old to be installed.

From the [Yarn docs](https://yarnpkg.com/configuration/yarnrc):

> Minimum age of a package version according to the publish date on the
npm registry in minutes to be considered for installation.
> 
> If a package version is newer than the minimal age gate, it will not
be considered for installation. This can be used to reduce the
likelihood of installing compromised packages.

See MetaMask/metamask-module-template#270 for
reference.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/37119?quickstart=1)

## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry:

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Bumps Yarn to 4.10.3 and adds a 3-day NPM package age gate with
allowlist for MetaMask and LavaMoat packages.
> 
> - **Tooling**:
>   - Update `package.json` `packageManager` to `yarn@4.10.3`.
> - **Yarn config** (`.yarnrc.yml`):
>   - Add `npmMinimalAgeGate: 4320` (3 days).
> - Add `npmPreapprovedPackages` allowlist: `@metamask/*`,
`@lavamoat/*`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
8e3cc51. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
github-merge-queue bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Oct 24, 2025
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

Yarn 4.10.3 includes support for setting an age gate for NPM packages.
I've set it to 3 days following the security recommendations, meaning
that packages must be at least 3 days old to be installed.

From the [Yarn docs](https://yarnpkg.com/configuration/yarnrc):

> Minimum age of a package version according to the publish date on the
npm registry in minutes to be considered for installation.
> 
> If a package version is newer than the minimal age gate, it will not
be considered for installation. This can be used to reduce the
likelihood of installing compromised packages.

See MetaMask/metamask-module-template#270 for
reference.

## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry:

## **Related issues**

Fixes:

## **Manual testing steps**

```gherkin
Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]
```

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Sets a 3-day npm age gate in `.yarnrc.yml` and preapproves
`@metamask/*` and `@lavamoat/*` packages.
> 
> - **Config (`.yarnrc.yml`)**:
> - Set `npmMinimalAgeGate: 4320` (3 days) to restrict installation of
very new packages.
> - Add `npmPreapprovedPackages` allowing `@metamask/*` and
`@lavamoat/*` to bypass the age gate.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
00535c2. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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