# GHSA-2jx3-65f3-xr8r: `OTPHP\Factory::loadFromProvisioningUri()` parses an attacker-supplied `otpauth://` URI and forwards **every** query key to `OTP:

> Attackers can corrupt OTP state or cause uncaught errors by supplying malicious provisioning URIs to the Factory class in the spomky-labs/otphp library.

- **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:** 18 Jun 2026

## What is GHSA-2jx3-65f3-xr8r?

GHSA-2jx3-65f3-xr8r is a vulnerability in spomky-labs/otphp, published on 18 Jun 2026. 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

## Summary

`OTPHP\Factory::loadFromProvisioningUri()` parses an attacker-supplied `otpauth://` URI and forwards **every** query key to `OTP::setParameter($key, $value)`. `setParameter()` resolves the name with `property_exists($this, $parameter)` and performs a dynamic write `$this->{$parameter} = $value` (`src/OTP.php:196-197`). Because the query keys are entirely controlled by whoever produced the URI, a URI can target the internal properties of the OTP object that are not meant to be set from a URI: `parameters`, `issuer`, `label`, `issuer_included_as_parameter`, and (on TOTP) the readonly `clock`. This is an instance of object property mass-assignment (CWE-915).

## Impact

The `Factory` is documented as the entry point for third-party provisioning URIs (e.g. QR codes from Microsoft 365 / Google Authenticator). An application that loads such a URI is exposed to:

- **State corruption.** A URI such as `otpauth://totp/Alice?secret=JBSWY3DPEHPK3PXP&parameters[foo]=bar` overwrites the whole internal `$parameters` array that `createFromSecret()` primed (`period`, `algorithm`, `digits`, `epoch`). The resulting object is silently unusable: `getProvisioningUri()`, `getDigits()`, `at()`, `verify()` then throw `ParameterNotFoundException`.
- **Uncaught TypeError escaping the documented exception type.** A URI such as `otpauth://totp/Alice?secret=JBSWY3DPEHPK3PXP&issuer_included_as_parameter=notabool` assigns a string to a typed `bool` property and raises a `TypeError`. The `try/catch` in `loadFromProvisioningUri()` only wraps `Url::fromString()`; `createOTP()` and `populateOTP()` run outside it, so the `TypeError` (and `Error` on the readonly `clock`) escapes past the documented `InvalidProvisioningUriException`, breaking callers that catch only the documented type.
- **Label/issuer validation bypass.** `parameters[label]=hijacked` stores a label into the parameters array without running the `label` validation callback (keyed on `label`, not `parameters`). `getLabel()` and `getParameter('label')` then disagree — a confused-deputy risk.

## Affected component

- `src/OTP.php:187-201` — `setParameter()` dynamic property write
- `src/Factory.php:50-55` — `populateParameters()` forwarding all query keys

## Proof of concept

```php
use OTPHP\Factory;

// State corruption
$otp = Factory::loadFromProvisioningUri(
    'otpauth://totp/Alice?secret=JBSWY3DPEHPK3PXP&parameters[foo]=bar',
    $clock
);
$otp->getProvisioningUri(); // ParameterNotFoundException: Parameter "period" does not exist

// Uncaught TypeError
Factory::loadFromProvisioningUri(
    'otpauth://totp/Alice?secret=JBSWY3DPEHPK3PXP&issuer_included_as_parameter=notabool',
    $clock
); // TypeError escapes InvalidProvisioningUriException
```

## Remediation

Restrict the keys accepted from a provisioning URI to a known allow-list of public OTP parameters, and never let a URI key resolve to an internal object property via `property_exists`. Route all URI-sourced values through the validated parameter map only.

## Which versions are affected by GHSA-2jx3-65f3-xr8r?

2 open source packages ship an affected version, including spomky-labs/otphp.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `spomky-labs/otphp` | Packagist | All versions | 11.4.3 |
| `spomky-labs/otphp` | Packagist | All versions | 11.4.3 |

## How do I fix GHSA-2jx3-65f3-xr8r?

Upgrade spomky-labs/otphp to 11.4.3 or later.

## Is GHSA-2jx3-65f3-xr8r being exploited?

There is no known exploitation of GHSA-2jx3-65f3-xr8r in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-2jx3-65f3-xr8r and fix it if it is affected.

What it is: GHSA-2jx3-65f3-xr8r is a vulnerability in spomky-labs/otphp, published on 18 Jun 2026. 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-2jx3-65f3-xr8r in the wild and no public exploit code.

Affected packages and fixed versions:
- spomky-labs/otphp (Packagist): affected all versions; fixed in 11.4.3
- spomky-labs/otphp (Packagist): affected all versions; fixed in 11.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-2jx3-65f3-xr8r/ (Markdown: https://insights.sbomify.com/GHSA-2jx3-65f3-xr8r/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-2jx3-65f3-xr8r

---
From sbomify Insights: https://insights.sbomify.com/GHSA-2jx3-65f3-xr8r/
Summaries are generated and may contain mistakes; the official description above is the record.
