rubygems CVE-2022-29176 explained
A flaw in the gem yank process allowed a malicious user to yank a gem they did not own by manipulating the version slug. An attacker could remove a legitimate gem and then upload a different file with the same name, version, and platform.
greg.molnar.io
Published on greg.molnar.io
#rails #security #rubygems
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The version lookup used a user-supplied slug without verifying that the fetched version belonged to the gem the user was authorised to access.
What the attacker needed
A valid API key; a gem you own
The fix
A secondary check was introduced to verify that the fetched version's gem matches the gem the user is authorised to access.
How it was found
- Authenticate with a valid API key.
- Provide a gem name you own so the ownership check passes.
- Set the version slug to a target gem's name and version.
- The system fetches the target version and allows yanking it.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When you remove a gem from RubyGems, the system checks that you own it. But the check for the specific version was flawed: it looked up the version using a value you could control, so you could point it at someone else's gem. This let an attacker delete a popular gem and replace it with a malicious one.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.