# GHSA-7vcx-v65q-9wpg: XML-RPC for PHP's `Wrapper::buildClientWrapperCode` method allows code injection via malicious `$client` argument

> Attackers can inject malicious code if developers use specific wrapper methods with untrusted data or copy debugger output, leading to code execution.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 11 Jan 2023

## What is GHSA-7vcx-v65q-9wpg?

GHSA-7vcx-v65q-9wpg is a code injection vulnerability in phpxmlrpc/phpxmlrpc, published on 11 Jan 2023. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

In order for this weakness to be exploited, the following conditions have to apply, at the same time:

- method `Wrapper::buildClientWrapperCode`, or any methods which depend on it, such as `Wrapper::wrapXmlrpcServer`, `Wrapper::wrapXmlrpcMethod` or `Wrapper::buildWrapMethodSource` must be in use. Note that they are _not_ used by default in either the Client or Server classes provided by the library; the developer has to specifically make use of them in his/her own code
- the `$client` argument to either of those methods should have been built with malicious data, ie. data controlled by a 3rd party, passed to its constructor call

This is most likely an uncommon usage scenario, and as such the chances of exploitation may be low.

*NB* the graphical debugger which is shipped as part of the library is vulnerable to this, when used with the option "Generate stub for method call" selected. In that case, the debugger will _display_ but not _execute_ the malicious code, which would have to be provided via carefully crafted values for the "Address" and "Path" inputs.

The attack scenario in this case is that a developer copies into his/her own source code the php snippet generated by the debugger, in a situation where the debugger is used with "Address"/"Path" input values supplied by a 3rd party.
The malicious payload in the "Address"/"Path" input values should be easily recognized as suspicious by any barely proficient developer, as it resembles a bog-standard injection attack.
It goes without saying that a responsible developer should not blindly copy and paste into his/her own code anything generated by a 3rd party tool, such as the phpxmlrpc debugger, without giving it at least a cursory scan.

Originally reported as issue #80

## Which versions are affected by GHSA-7vcx-v65q-9wpg?

2 open source packages ship an affected version, including phpxmlrpc/phpxmlrpc.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `phpxmlrpc/phpxmlrpc` | Packagist | All versions | 4.9.0 |
| `phpxmlrpc/phpxmlrpc` | Packagist | All versions | 4.9.0 |

## How do I fix GHSA-7vcx-v65q-9wpg?

Upgrade phpxmlrpc/phpxmlrpc to 4.9.0 or later.

## Is GHSA-7vcx-v65q-9wpg being exploited?

There is no known exploitation of GHSA-7vcx-v65q-9wpg in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-7vcx-v65q-9wpg and fix it if it is affected.

What it is: GHSA-7vcx-v65q-9wpg is a code injection vulnerability in phpxmlrpc/phpxmlrpc, published on 11 Jan 2023. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-7vcx-v65q-9wpg in the wild and no public exploit code.

Affected packages and fixed versions:
- phpxmlrpc/phpxmlrpc (Packagist): affected all versions; fixed in 4.9.0
- phpxmlrpc/phpxmlrpc (Packagist): affected all versions; fixed in 4.9.0

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-7vcx-v65q-9wpg/ (Markdown: https://insights.sbomify.com/GHSA-7vcx-v65q-9wpg/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-7vcx-v65q-9wpg

---
From sbomify Insights: https://insights.sbomify.com/GHSA-7vcx-v65q-9wpg/
Summaries are generated and may contain mistakes; the official description above is the record.
