Skip to content

password_verify() failed to verify bcrypt passwords containing null bytes #21673

@LamentXU123

Description

@LamentXU123

Description

The following code:

<?php
$hash = password_hash("secret", PASSWORD_BCRYPT);
var_dump(password_verify("secret", $hash));
var_dump(password_verify("secret" . chr(0) . "suffix", $hash));
?>

Resulted in this output:

bool(true)
bool(true)

But I expected this output instead:

bool(true)
bool(false)

PHP Version

all supported version

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions