GHSA-mxjr-xmcg-fg7w Arbitrary Code Injection in mobile-icon-resizer

Not scored Published

Attackers can execute arbitrary JavaScript code by providing malicious configuration files to the mobile-icon-resizer library.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Not stated
Victim action needed
A user has to click or open something
Fix
Available

What is GHSA-mxjr-xmcg-fg7w?

GHSA-mxjr-xmcg-fg7w is a code injection vulnerability in mobile-icon-resizer, published on 27 Jun 2019.

Official description

mobile-icon-resizer resizes large images for use as icons for iOS and Android.

mobile-icon-resizer has a code execution vulnerability in versions before 0.4.3.

mobile-icon-resizer takes an options object as an argument to define the resulting icons as such:

var options = {
  config: './config.js'
}
resize(options, function(err){});

config.js would need to be a file on the filesystem and look something like:

var config = {
  iOS: {
    "images": [
     /* iOS image definitions are not vulnerable */
    ]
  },
  android: {
    "images" : [
      {
        "baseRatio" : "console.log('Executing script as baseRatio property')",
        "folder" : "drawable-ldpi"
      },
      {
        "ratio" : "console.log('Executing script as ratio property')",
        "folder" : "drawable-mdpi"
      },
    /* other android image defintiions ... */
    ]
  }
};

exports = module.exports = config;

The parameters ratio and baseRatio are passed directly to eval(), thus allowing dynamic javascript payloads to be executed.

Recommendation

Update to version 0.4.3 or later.

Which versions are affected by GHSA-mxjr-xmcg-fg7w?

2 open source packages ship an affected version, including mobile-icon-resizer.

PackageAffectedFixed in
mobile-icon-resizer npmFrom 0.2.00.4.3
mobile-icon-resizer npmFrom 0.2.00.4.3

How do I fix GHSA-mxjr-xmcg-fg7w?

Upgrade mobile-icon-resizer to 0.4.3 or later.

Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.

Is GHSA-mxjr-xmcg-fg7w being exploited?

There is no known exploitation of GHSA-mxjr-xmcg-fg7w in the wild and no public exploit code.

Sources

Is GHSA-mxjr-xmcg-fg7w in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free