GHSA-2jx3-65f3-xr8r: spomky-labs/otphp Mass-assignment Vulnerability

MODERATE
CWE-915
Published
Advisory Summary

GHSA-2jx3-65f3-xr8r is a MODERATE mass-assignment vulnerability (CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes) affecting spomky-labs/otphp libraries in the Packagist ecosystem. The issue involves mass-assignment in factory::loadfromprovisioninguri lets a hostile provisioning uri corrupt otp state or leak an uncaught typeerror. Remediation is available by upgrading affected packages to version 11.4.3.

GHSA-2jx3-65f3-xr8r at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-2jx3-65f3-xr8r
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes
Affected Product spomky-labs/otphp
Package Ecosystem Packagist
Published Date
Last Updated

How to Fix GHSA-2jx3-65f3-xr8r

To remediate this vulnerability, upgrade all affected spomky-labs/otphp dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

spomky-labs/otphp fixed: 11.4.3
Upgrade spomky-labs/otphp to 11.4.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for spomky-labs/otphp

How to Check if You Are Affected

To determine whether your application is affected by GHSA-2jx3-65f3-xr8r, inspect your project dependencies for spomky-labs/otphp:

inspect dependencies for spomky-labs/otphp

Analyze the terminal output to locate any version of spomky-labs/otphp in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 11.4.3), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes, where the product receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified. In spomky-labs/otphp, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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

GHSA-2jx3-65f3-xr8r Affected spomky-labs/otphp Versions

1 component(s)
Fixed Versions:
11.4.3
Product / Package Ecosystem Affected Versions Fixed Version
spomky-labs/otphp
Packagist
< 11.4.3
11.4.3

References

Frequently Asked Questions

What is GHSA-2jx3-65f3-xr8r?
GHSA-2jx3-65f3-xr8r is a security vulnerability in spomky-labs/otphp involving Mass-assignment in Factory::loadFromProvisioningUri lets a hostile provisioning URI corrupt OTP state or leak an uncaught TypeError under CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes.
Which spomky-labs/otphp versions are affected?
Affected versions include releases prior to 11.4.3 across affected packages: spomky-labs/otphp.
What version fixes GHSA-2jx3-65f3-xr8r?
Upgrading to 11.4.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is spomky-labs/otphp affected?
Yes, spomky-labs/otphp is affected in releases prior to 11.4.3. Upgrade your dependency to 11.4.3 or later.
What CWE is associated with GHSA-2jx3-65f3-xr8r?
GHSA-2jx3-65f3-xr8r is classified under CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes (The product receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.).
How can I check Packagist dependencies for GHSA-2jx3-65f3-xr8r?
Run the dependency tree command: 'inspect dependencies for spomky-labs/otphp'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-2jx3-65f3-xr8r",
  "modified" : "2026-06-18T21:07:41Z",
  "published" : "2026-06-18T21:07:41Z",
  "aliases" : [ ],
  "summary" : "spomky-labs/otphp: Mass-assignment in Factory::loadFromProvisioningUri lets a hostile provisioning URI corrupt OTP state or leak an uncaught TypeError",
  "details" : "## Summary\n\n`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).\n\n## Impact\n\nThe `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:\n\n- **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`.\n- **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.\n- **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.\n\n## Affected component\n\n- `src/OTP.php:187-201` — `setParameter()` dynamic property write\n- `src/Factory.php:50-55` — `populateParameters()` forwarding all query keys\n\n## Proof of concept\n\n```php\nuse OTPHP\\Factory;\n\n// State corruption\n$otp = Factory::loadFromProvisioningUri(\n    'otpauth://totp/Alice?secret=JBSWY3DPEHPK3PXP&parameters[foo]=bar',\n    $clock\n);\n$otp->getProvisioningUri(); // ParameterNotFoundException: Parameter \"period\" does not exist\n\n// Uncaught TypeError\nFactory::loadFromProvisioningUri(\n    'otpauth://totp/Alice?secret=JBSWY3DPEHPK3PXP&issuer_included_as_parameter=notabool',\n    $clock\n); // TypeError escapes InvalidProvisioningUriException\n```\n\n## Remediation\n\nRestrict 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.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "spomky-labs/otphp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "11.4.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Spomky-Labs/otphp/security/advisories/GHSA-2jx3-65f3-xr8r"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/spomky-labs/otphp/GHSA-2jx3-65f3-xr8r.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Spomky-Labs/otphp"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-915" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-18T21:07:41Z",
    "nvd_published_at" : null
  }
}