Summary
spomky-labs/otphp: Mass-assignment in Factory::loadFromProvisioningUri lets a hostile provisioning URI corrupt OTP state or leak an uncaught TypeError
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).
Affected component
src/OTP.php:187-201,setParameter()dynamic property writesrc/Factory.php:50-55,populateParameters()forwarding all query keys
Proof of concept
use OTPHP\Factory;
// State corruption
$otp = Factory::loadFromProvisioningUri(
'otpauth://totp/Alice?secret=JBSWY3DPEHPK3PXP¶meters[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
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¶meters[foo]=baroverwrites the whole internal$parametersarray thatcreateFromSecret()primed (period,algorithm,digits,epoch). The resulting object is silently unusable:getProvisioningUri(),getDigits(),at(),verify()then throwParameterNotFoundException. - Uncaught TypeError escaping the documented exception type. A URI such as
otpauth://totp/Alice?secret=JBSWY3DPEHPK3PXP&issuer_included_as_parameter=notaboolassigns a string to a typedboolproperty and raises aTypeError. Thetry/catchinloadFromProvisioningUri()only wrapsUrl::fromString();createOTP()andpopulateOTP()run outside it, so theTypeError(andErroron the readonlyclock) escapes past the documentedInvalidProvisioningUriException, breaking callers that catch only the documented type. - Label/issuer validation bypass.
parameters[label]=hijackedstores a label into the parameters array without running thelabelvalidation callback (keyed onlabel, notparameters).getLabel()andgetParameter('label')then disagree, a confused-deputy risk.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
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.
Frequently Asked Questions
- What is GHSA-2JX3-65F3-XR8R? GHSA-2JX3-65F3-XR8R is a medium-severity security vulnerability in spomky-labs/otphp (composer), affecting versions < 11.4.3. It is fixed in 11.4.3.
- Which versions of spomky-labs/otphp are affected by GHSA-2JX3-65F3-XR8R? spomky-labs/otphp (composer) versions < 11.4.3 is affected.
- Is there a fix for GHSA-2JX3-65F3-XR8R? Yes. GHSA-2JX3-65F3-XR8R is fixed in 11.4.3. Upgrade to this version or later.
- Is GHSA-2JX3-65F3-XR8R exploitable, and should I be worried? Whether GHSA-2JX3-65F3-XR8R is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-2JX3-65F3-XR8R is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-2JX3-65F3-XR8R? Upgrade
spomky-labs/otphpto 11.4.3 or later.