Skip to content

Add commented-out rubygems_mfa_required to bundle gem template#9487

Merged
hsbt merged 1 commit intoruby:masterfrom
MatheusRich:bundle-gem-mfa-required-hint
Apr 16, 2026
Merged

Add commented-out rubygems_mfa_required to bundle gem template#9487
hsbt merged 1 commit intoruby:masterfrom
MatheusRich:bundle-gem-mfa-required-hint

Conversation

@MatheusRich
Copy link
Copy Markdown
Contributor

@MatheusRich MatheusRich commented Apr 15, 2026

What was the end-user or developer problem that led to this PR?

Package registries are active supply chain attack targets. Recent
high-profile incidents include the Axios NPM compromise
(https://socket.dev/blog/axios-npm-package-compromised) and the LiteLLM
PyPI compromise (https://docs.litellm.ai/blog/security-update-march-2026).

RubyGems supports an MFA-required opt-in via gemspec metadata:

spec.metadata["rubygems_mfa_required"] = "true"

but most gems haven't enabled it. A big reason is discoverability. Nothing
in the bundle gem flow mentions the option, so authors would need to
already know it exists to find it.

Reference: https://guides.rubygems.org/mfa-requirement-opt-in/

What is your fix for the problem, implemented in this PR?

This PR adds a commented-out spec.metadata["rubygems_mfa_required"] = "true" line,
along with a short explanatory comment and a reference link, to the gemspec
template used by bundle gem. Default behavior is unchanged because the
line is commented out, but every new gem author now sees the MFA opt-in
right where they configure their gemspec. Opting in is then a matter of
deleting the leading #.

Package registries are active supply chain attack targets. Recent
high-profile incidents include the Axios NPM compromise
(https://socket.dev/blog/axios-npm-package-compromised) and the LiteLLM
PyPI compromise (https://docs.litellm.ai/blog/security-update-march-2026).

RubyGems supports an MFA-required opt-in via gemspec metadata:

    spec.metadata["rubygems_mfa_required"] = "true"

but most gems haven't enabled it. A big reason is discoverability. Nothing
in the `bundle gem` flow mentions the option, so authors would need to
already know it exists to find it.

Reference: https://guides.rubygems.org/mfa-requirement-opt-in/

This commit adds a commented-out `spec.metadata["rubygems_mfa_required"] = "true"` line,
along with a short explanatory comment and a reference link, to the gemspec
template used by `bundle gem`. Default behavior is unchanged because the
line is commented out, but every new gem author now sees the MFA opt-in
right where they configure their gemspec. Opting in is then a matter of
deleting the leading `# `.
Copy link
Copy Markdown
Member

@hsbt hsbt left a comment

Choose a reason for hiding this comment

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

👍

@hsbt hsbt merged commit 2fd3496 into ruby:master Apr 16, 2026
96 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants