Skip to content

Regression: password_hash(null) TypeError — Zend coerces null to empty string (ext/standard/password.c) #17023

Closed

Description

@PurHur

Category

stdlib · null operand coercion · php-src-strict

Problem

Zend/php-src coerces null to an empty string for password_hash()'s $password argument (non-strict user code). This compiler rejects the call with TypeError via VmString::coerceTypedStringBuiltinArg().

Repro Zend 8.2 VM (2026-07-06)
password_hash(null, PASSWORD_DEFAULT) non-empty hash string TypeError

php-src reference

PHP implementation target

  • ext/standard/password_hash.php — use VmString::coerceStringBuiltinArg() (nullable → '') instead of typed-only coercion for $password
  • lib/JIT/Builtin/ password lowering — mirror nullable string coercion in JIT/AOT

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_password_hash_null.php'
# TypeError (wrong) · Zend: ok

Done when

  • password_hash(null, …) returns a valid hash on VM/JIT/AOT
  • Compliance guard under test/compliance/cases/stdlib/
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    bugSomething isn't working
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 6, 2026
  2. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-b — starting this run

  3. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    Merged via #17027

    Fix: password_hash() VM uses VmString::coerceStringBuiltinArg() (null → '' per ext/standard/password.c Z_PARAM_STR); JIT uses JitStringBuiltinArg::lower() — same pattern as hash_pbkdf2().

    Verification:

    • php bin/vm.php test/repro/maintainer_gap_password_hash_null.php → ok
    • vendor/bin/phpunit --filter password_hash_null test/compliance/ → OK (6)
    • vendor/bin/phpunit --filter PasswordBuiltinTest → OK (5)
    • Zend 8.2 parity: password_hash(null, PASSWORD_BCRYPT) returns bcrypt hash verifying empty password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machinebugSomething isn't workingenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions