Skip to content
Memory corruption Disclosed report Advanced

bcpowmod accepts negative scale and corrupts _one_ definition

bcpowmod accepted a negative scale, which could corrupt the internal _one_ definition and lead to memory corruption.

fms Follow

Originally disclosed on HackerOne

Bounty$500 View original
  • Fixed in 6 days
  • Paid in 6 days
  • Disclosed after 3.5 years

https://bugs.php.net/bug.php?id=72093

Two issues reported on the same bug, bcpowermod accepts a negative value which also is able to corrupt the one definition and leads to memory corruption problems.

Reported to developers on 2016-04-24, fixed 2016-04-25 and released at 2016-04-28, affected PHP 5.5 , 5.6 and 7.

http://php.net/ChangeLog-5.php#5.5.35 http://php.net/ChangeLog-5.php#5.6.21 http://php.net/ChangeLog-7.php#7.0.6

The original report as published on HackerOne, by fms. 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

Likely the function did not validate that the scale argument was non-negative, allowing a negative value to corrupt internal state.

Impact

Could lead to memory corruption, potentially causing a crash or other undefined behaviour.

What the attacker needed

Ability to call bcpowmod with negative scale

The fix

The issue was fixed in PHP 5.5.35, 5.6.21, and 7.0.6.

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.

PHP has a function called bcpowmod for doing maths with very large numbers. It takes a 'scale' argument that says how many decimal places to keep. The bug was that if you gave it a negative number for scale, it messed up some internal data and could crash or corrupt memory. This is dangerous because it can make the program behave unpredictably or crash.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by fms

View all

33 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.