Skip to content
Business logic Disclosed report Beginner

Deleting Key-value pair from Frozen HASH or Clearing a Frozen HASH

The delete and clear methods on a frozen Hash in mruby do not check whether the Hash is frozen, allowing an attacker to modify a frozen Hash. This could lead to data corruption.

an0n-j Follow

Originally disclosed on HackerOne

Informational View original
  • Triaged in 5 days
  • Fixed in 6 days
  • Disclosed after 6 days

Hey!

while reviewing mruby for vulnerabilities, I stumble onto a snippet that allow an attacker to delete "key-value Pair" from a "Frozen" Hash or to clear the "Frozen" HASH.

Reproduction Step

1.) Create a Hash like h = { "a" => 100, "b" => 200 } 2.) Freeze this hash 3.) Now call delete method with "KEY" (the case if you don't know the KEY then you can call .keys method to obtaine all available KEYS in the HASH) ( or call .clear method to clear the HASH )

POC

h = { "a" => 100, "b" => 200 } h.freeze h.delete("a") @output = h

Look at h you will get remaining values after deletion even if the HASH has been frozen. ( in case of h.clear you will get empty HASH ).

Explanation

Bug is happened because there is no method calling to check weather the HASH is frozen or not in both methods mrb_hash_delete hash.c#552 and mrb_hash_clear hash.c#619 in https://github.com/mruby/mruby/blob/master/src/hash.c

This bug may come handy to delete details to cause data corruption.

Fix

Just apply mrb_hash_modify(mrb, self); & mrb_hash_modify(mrb, hash); on line 555 and on line 622 respectively.

The original report as published on HackerOne, by an0n-j. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

This bug may come handy to delete details to cause data corruption.

What the attacker needed

Ability to run mruby code

How it was found

  1. Create a Hash with some key-value pairs.
  2. Freeze the Hash.
  3. Call the delete method with a key (or call clear) to modify the frozen Hash.

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 report has not been written yet. The Original tab links to the source.

In programming, a 'frozen' object is meant to be unchangeable, like a locked box. This report shows that in mruby, you can still remove items from a frozen Hash (a collection of key-value pairs) using delete or clear, which should not be allowed. That breaks the promise of immutability and could cause unexpected behaviour.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by an0n-j

View all

4 more disclosed reports, best first.

More from shopify-scripts

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.