WordPress / WordPress/two-factor

Normalize malformed primary-provider meta before array-key access

Open
#944 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
825
Forks
187
Avg merge
2d 11h
Merged PRs (30d)
17

Description

Problem

Malformed _two_factor_provider user meta can reach provider-array offset access without scalar validation. With at least two available providers, setting the primary value to an object, array, or nested array causes a fatal/warning during primary resolution.

Reproduction

  1. Configure two available providers for a user.
  2. Set _two_factor_provider to stdClass, an array, or a nested array.
  3. Resolve the user primary provider.

Observed around class-two-factor-core.php:791-799:

  • PHP 8: TypeError from illegal array offset type.
  • PHP 7.4: Illegal offset type warnings.

Expected

Normalize persisted primary-provider meta to a bounded scalar provider key before lookup. Malformed state must not fatal admin, profile, CLI, REST, or authentication paths, and authentication should remain fail-closed when persisted state cannot be resolved safely.

Evidence

Found during the aggressive multisite fuzz review of #933:

  • 50,001 randomized provider states
  • PHP 7.4/WordPress 6.9 and PHP 8.x/current/trunk
  • Stable minimized reproduction for object, array, and nested-array values

This is adjacent to but distinct from enabled-provider meta normalization tracked in #941.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in class-two-factor-core.php around lines 791-799, then trace how the primary provider is resolved from _two_factor_provider. Exercise the resolution with object, array, and nested-array values and verify that admin, profile, CLI, REST, and authentication paths do not fatal; unresolved persisted state must fail closed.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
authentication, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.