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

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

- **Severity:** Not scored
- **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:** Yes
- **Published:** 27 Jun 2019

## 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.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `mobile-icon-resizer` | npm | From 0.2.0 | 0.4.3 |
| `mobile-icon-resizer` | npm | From 0.2.0 | 0.4.3 |

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

Upgrade mobile-icon-resizer to 0.4.3 or later.

## 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.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-mxjr-xmcg-fg7w and fix it if it is affected.

What it is: GHSA-mxjr-xmcg-fg7w is a code injection vulnerability in mobile-icon-resizer, published on 27 Jun 2019. 
Exploitation: There is no known exploitation of GHSA-mxjr-xmcg-fg7w in the wild and no public exploit code.

Affected packages and fixed versions:
- mobile-icon-resizer (npm): affected from 0.2.0; fixed in 0.4.3
- mobile-icon-resizer (npm): affected from 0.2.0; fixed in 0.4.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-mxjr-xmcg-fg7w/ (Markdown: https://insights.sbomify.com/GHSA-mxjr-xmcg-fg7w/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-mxjr-xmcg-fg7w

---
From sbomify Insights: https://insights.sbomify.com/GHSA-mxjr-xmcg-fg7w/
Summaries are generated and may contain mistakes; the official description above is the record.
