Skip to content
Business logic Disclosed report Intermediate

Clearing , Shifting and Pop Value from Frozen Array

In mruby, the pop, shift and clear methods on an Array did not check whether the array was frozen, so a frozen array could still be modified. An attacker able to run Ruby code could remove or clear elements of an array that was meant to be immutable.

an0n-j Follow

Originally disclosed on HackerOne

Informational View original
  • Triaged in 1 hour
  • Fixed in 42 hours
  • Disclosed after 8 months

Hey again!

Founded another missing best practice in mruby. That allow an attacker to Delete (pop) or clear the Frozen ARRAY. This report is similar to 194866 POC

$a = [1,2,3,4,5].freeze

$a.pop

"#=> This will give 5 and $a will become [1,2,3,4]"

$a.shift

"#=> This will give 1 and $a will become [2,3,4,5]"

$a.clear

"#=> This will clear the whole FROZEN ARRAY."

Explanation

The issue is in mrb_ary_pop , mrb_ary_shift & in mrb_ary_clear methods of Array.c because there is no method calling to check the weather the Array is frozen or not. I'm not too much familiar with ruby to determine its impact, may be it doesn't effect at all but it should be fix.

Fix

Apply ary_modify method in all above mentioned methods.

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

Root cause

The pop, shift and clear methods in Array.c did not call the ary_modify check that enforces the frozen state.

Impact

Code that relies on freeze to protect an array could have its contents removed or cleared, though the reporter is unsure of the real-world impact.

What the attacker needed

Ability to run Ruby code in mruby

The fix

The ary_modify check should be applied in the pop, shift and clear methods so frozen arrays cannot be changed.

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 Ruby, calling freeze on an object is meant to lock it so it cannot be changed. This report shows that three array methods still changed a frozen array anyway, because they never checked the lock. The reporter is unsure how serious this is in practice.

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.