🔒 Password Exposed Helper Function - Check if a password has been exposed in a data breach.

Overview

🔒 Password Exposed Helper Function

This PHP package provides a password_exposed helper function, that uses the haveibeenpwned.com API to check if a password has been exposed in a data breach.

Build Status StyleCI

Installation

The password_exposed package can be easily installed using Composer. Just run the following command from the root of your project.

composer require "divineomega/password_exposed"

If you have never used the Composer dependency manager before, head to the Composer website for more information on how to get started.

Usage

To check if a password has been exposed in a data breach, just pass it to the password_exposed method.

Here is a basic usage example:

switch(password_exposed('hunter2')) {

    case PasswordStatus::EXPOSED:
        // Password has been exposed in a data breach.
        break;

    case PasswordStatus::NOT_EXPOSED:
        // Password has not been exposed in a known data breach.
        break;

    case PasswordStatus::UNKNOWN:
        // Unable to check password due to an API error.
        break;
}

If you prefer to avoid using helper functions, the following syntax is also available.

$passwordStatus = (new PasswordExposedChecker())->passwordExposed($password);

SHA1 Hash

You can also supply the SHA1 hash instead of the plain text password, by using the following method.

$passwordStatus = (new PasswordExposedChecker())->passwordExposedByHash($hash);

or...

$passwordStatus = password_exposed_by_hash($hash);
Comments
  • Next Major Release - A Suggestion

    Next Major Release - A Suggestion

    Hello,

    It's me again ;)

    Actually this PR shouldn't be so big, but somehow it happened.

    I would implement this library into my own projects, but wanted to use my own HTTP client and cache provider. This was not possible in the original version. So I made some changes to make it possible. Some new dependencies need PHP7 to run. That's why I increased the minimum version to 7.1 in this PR. Additionally I added some help functions and an abstract class and interface. This allows developers to make their own implementations as needed.

    Think of it as a kind of beta for version 3. I haven't adapted the Readme yet. Just check it out and give me feedback.

    If you would accept the PR i would write a Symfony bridge to ;)

    Best regards.

    opened by nicklog 15
  • Test enhancement

    Test enhancement

    Changed log

    • Upgrade PHPUnit version to ^6.5.
    • Add php: >=7.0 in require block and define this in composer.json.
    • Add the test classes namespace in autoload-dev block and define this in composer.json.
    opened by peter279k 8
  • ca-certs.json not found in data directory.

    ca-certs.json not found in data directory.

    Hi ,

    This is my issue on password store /update,

    Issue: "ParagonIE \ Certainty \ Exception \ FilesystemException ca-certs.json not found in data directory"

    And i added screen shot.Please kindly give me a solution https://user-images.githubusercontent.com/45994584/50214954-a68a1600-03a7-11e9-914b-71d0966e6b55.png

    opened by siva2507 6
  • Laravel 5.7 incompatibility

    Laravel 5.7 incompatibility

    It seems this package should not indicate support for v1 of the guzzle6-adapter package, because the type of object returned differs between v1 and v2 of the guzzle6-adapter.

    This causes a compatibility issue with Laravel 5.7

    It is caused by Laravel 5.7 requiring the laravel/nexmo-notification-channel as standard, which depends on the nexmo/client which enforces the use v1 of the guzzle6-adapter.

    My plan of action is going to be:

    • Create a simple PSR18 Guzzle adapter package, that returns an object which implements the correct PSR18 client interface.
    • Modify this package to make use of the new PSR18 Guzzle adapter package.

    This issue was discovered by @tswestendorp. See https://github.com/DivineOmega/password_exposed/pull/24.

    bug 
    opened by DivineOmega 4
  • Changed some return types

    Changed some return types

    \Http\Client\HttpClient doesn't implement \Psr\Http\Client\ClientInterface in php-http/guzzle6-adapter ^1.1 which makes the package incompatible with recent versions of laravel/framework

    opened by tswestendorp 4
  • Add method that does not make use of the real password

    Add method that does not make use of the real password

    However unlikely, passing a real password to a library is a risk in itself. Since there is no need to do that in this case we should provide a method to check a password by it's SHA-1 hash.

    opened by tacovandenbroek 4
  • Test enhancement

    Test enhancement

    Changed log

    • The php-7.1.33 version is latest stable php-7.1 version now.
    • Remove trusty dist and these php-7.x versions are enabled on xenial dist by default.
    • Upgrade the PHPUnit version to be ^7.0||^8.0. To be compatible with PHPUnit 7.x and PHPUnit 8.x versions, it should add :void to be compatible with PHPUnit\Framework\TestCase::setUp method.
    • Using the assertTrue and assertFalse assertions to assert expected value is true or false.
    opened by peter279k 3
  • Make hashing optional

    Make hashing optional

    Maybe I didn't see it or am I right that it currently only takes blank strings as input? Useful for the exact moment when users have to choose a new password.

    But it would be even nicer to also be able to use this tool for checking against already hashed passwords. Would that work with Troys API? With different hash types? Or does it anyways only work with sha1?

    opened by leymannx 3
  • Integrate with paragonie/certainty for validated SSL/TLS certificates

    Integrate with paragonie/certainty for validated SSL/TLS certificates

    This also makes the library's docblocks, etc. fully type-safe and uses Psalm to verify it.

    Keep in mind that Certainty requires PHP 5.6 so this might be a no-go if you wanted e.g. PHP 5.4 compatibility.

    opened by paragonie-scott 2
  • SHA1 hashes are publicly exposed in the cache dir

    SHA1 hashes are publicly exposed in the cache dir

    It's possible to recover the SHA1 of every password checked in the last 30 days by browsing the /tmp/password-exposed-cache folder.

    Example

    <?php
    
    require_once(__DIR__ . '/vendor/autoload.php');
    
    const DEMO_PASSWORD = 'WdBNSvWGnovprIe92mn4w3oinmWFxkbTHffqf8S8dUhYmNnbNjLJnUS1M7N6gVZ';
    
    $passwordStatus = password_exposed(DEMO_PASSWORD);
    
    echo 'Using a demo password of ' . DEMO_PASSWORD . ' with SHA1 ' . sha1(DEMO_PASSWORD) . PHP_EOL;
    echo 'Status is: ' . $passwordStatus;
    

    Output:

    ➜ password_exposed git:(master) ✗ php play.php Using a demo password of WdBNSvWGnovprIe92mn4w3oinmWFxkbTHffqf8S8dUhYmNnbNjLJnUS1M7N6gVZ with SHA1 604c4b2521a23ccd21572619e84a895e4153d88a Status is: not_exposed

    ➜ password_exposed git:(master) ✗ tree /tmp/password-exposed-cache /tmp/password-exposed-cache └── 60 └── 4c4b2521a23ccd21572619e84a895e4153d88a.cache

    1 directory, 1 file

    PR changes to caching the API response instead.

    opened by symm 2
  • api keys

    api keys

    for commercial use haveibeenpwned uses api-keys for authentication.

    looking at the current api of this package, I don't know where/how to pass in the api key into the lib. Am I the only one in need for this feature? :)

    opened by staabm 1
  • Run $lines through array_filter() to remove empty strings that can cause unhandled exceptions

    Run $lines through array_filter() to remove empty strings that can cause unhandled exceptions

    In some cases, the response body pulled from the HaveIBeenPwned API can end with a blank space after the final new line characters. When pulled into the $lines array, this creates an index that consists of just a blank string.

    When attempting to call list() on the result of calling explode(':', $line), an Exception is thrown.

    This Exception is not caught in this package, or within Laravel NIST which uses it. The stack trace of this Exception exposes the User's password to any logs that record it.

    Passing the $lines array through an array_filter() removes any blank indexes and prevents this error.

    opened by jamieb-tillo 2
  • Empty string in $line causes an Exception that can expose a User's password

    Empty string in $line causes an Exception that can expose a User's password

    In this method, if the $line variable does not contain a colon (e.g., is an empty string), then the call to list() will throw an Exception.

    https://github.com/DivineOmega/password_exposed/blob/327f93ee5cab54622077bcae721412b55be16720/src/AbstractPasswordExposedChecker.php#L147

    This exception is not caught by the handling in NIST or the DivineOmega packages. The stack trace of this exception will contain the submitted password in plain text.

    opened by jamieb-tillo 1
  • please bump old psr/cache  deps

    please bump old psr/cache deps

    hi,

    cant install as a dependemcy from divineomega/laravel-password-exposed-validation-rule :

    Running composer update langleyfoxall/laravel-nist-password-rules
    Loading composer repositories with package information
    Updating dependencies
    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - divineomega/password_exposed v3.2.0 requires psr/cache ^1.0 -> found psr/cache[1.0.0, 1.0.1] but the package is fixed to 3.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
        - langleyfoxall/laravel-nist-password-rules[v5.0.0, ..., v5.0.1] require divineomega/laravel-password-exposed-validation-rule ^2.4.0 -> satisfiable by divineomega/laravel-password-exposed-validation-rule[v2.4.0].
        - divineomega/laravel-password-exposed-validation-rule v2.4.0 requires divineomega/password_exposed ^3.2.0 -> satisfiable by divineomega/password_exposed[v3.2.0].
        - Root composer.json requires langleyfoxall/laravel-nist-password-rules ^5.0 -> satisfiable by langleyfoxall/laravel-nist-password-rules[v5.0.0, v5.0.1].
    

    https://github.com/DivineOmega/password_exposed/blob/327f93ee5cab54622077bcae721412b55be16720/composer.json#L25

    opened by simonbuehler 2
  • Very strange rename error

    Very strange rename error

    We had a user in production get a strange error today which seems to originate from this package:

    rename(/home/sites/15a/5/564543e965/production/releases/161/vendor/divineomega/password_exposed/src/../bundles/ca-certs.json,/home/sites/15a/5/564543e965/production/releases/161/vendor/divineomega/password_exposed/src/../bundles/ca-certs-backup-20210915192000.json): No such file or directory
    

    Its only happened once but should I be worried here?

    opened by Jamesking56 0
Releases(v3.2.0)
Owner
Jordan Hall
Jordan Hall
A minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.

Current version: 1.3.5 PrivateBin is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted a

null 4.6k Jan 7, 2023
A simple php (lumen) app for sharing sensitive text (basically like onetimesecret), but with full end-to-end AES-256-GCM encryption so even the server has no access to the data, and developed with very simple deployment in mind.

A simple php (lumen) app for sharing sensitive text (basically like onetimesecret), but with full end-to-end AES-256-GCM encryption so even the server has no access to the data, and developed with very simple deployment in mind.

Alan Woo 51 Nov 21, 2022
A simple, yet feature rich password manager for Nextcloud

Easy to use yet feature-rich and secure password manager for Nextcloud

M. Wieschollek 169 Jan 3, 2023
Password manager featuring client-side encryption, vaults, folders and more.

vaults is a password manager featuring client side AES-256 encryption, PBKDF2 hashing, vaults, password generation & more. Features Technical overview

null 27 Nov 18, 2022
Antware NinjaCrypter is an experimental username and password cookie string class for PHP

Antware NinjaCrypter is an experimental username and password cookie string class for PHP. For study case this crypter is based on password crypting ideology but can also encrypt username and password for storing cookie string that way your login details will not be exposed by hackers that search through cookie string.

Chukwu Remijius 1 Nov 25, 2021
Strong cryptography tools and password hashing

laminas-crypt ???? Русским гражданам Мы, участники Laminas, родились и живем в разных странах. У многих из нас есть друзья, родственники и коллеги как

Laminas Project 29 Dec 15, 2022
Pretty Good Privacy (PGP) is an encryption program that provides cryptographic privacy and authentication for data communication.

Pretty Good Privacy (PGP) is an encryption program that provides cryptographic privacy and authentication for data communication. PGP is used for signing, encrypting, and decrypting texts, e-mails, files, directories, and whole disk partitions and to increase the security of e-mail communications. Phil Zimmermann developed PGP in 1991.

[sCRiPTz-TEAM] 3 Dec 31, 2021
HTML/PHP/CSS website that tracks two API data

Detailed instructions on how to build and run Step 1: download XAMPP for a live web server XAMPP download 1 XAMP download 2 Step 2: Download all files

Winsor Tse 0 Jun 2, 2022
Easily anonymize sensitive data through eloquent queries

Laravel Encryptable This package allows you to anonymize sensitive data (like the name, surname and email address of a user) similarly to Laravel's En

H-FARM Innovation 93 Sep 6, 2022
Obfuscate your data by generating reversible, non-sequential, URL-safe identifiers.

Laravel Hashid Laravel Hashid provides a unified API across various drivers such as Base62, Base64, Hashids and Optimus, with support for multiple con

Elf Sundae 390 Nov 16, 2022
Automatic Encrypt and Decrypt your database data. Tested and used on Laravel 8

Laravel Encrypt Database Automatic Encrypt and Decrypt your database data. Tested and used on Laravel 8. I'm yet building the tests. Important Note th

Wellington Barbosa 2 Dec 15, 2021
Run locally to export crypto tx data from crypto exchanges using their api connections, and process into a normalised format.

CryptoCredible The missing crypto-exchange data exporter tldr: run locally to export your crypto tx data from popular exchanges via api connections. E

Lee Overy 6 Apr 6, 2022
SЁCU is a public API to store self-destructing data payloads with url shortener and handle anonymous chat-rooms.

SЁCU Introduction SЁCU is a public API to store self-destructing data payloads. This repository includes only backend part using Laravel framework. Fr

SЁCU 27 Nov 21, 2022
🔒 Laravel validation rule that checks if a password has been exposed in a data breach.

?? Laravel Password Exposed Validation Rule This package provides a Laravel validation rule that checks if a password has been exposed in a data breac

Jordan Hall 85 Apr 26, 2022
🔒 Laravel validation rule that checks if a password has been exposed in a data breach.

?? Laravel Password Exposed Validation Rule This package provides a Laravel validation rule that checks if a password has been exposed in a data breac

Jordan Hall 85 Apr 26, 2022
Making multiple identical function calls has the same effect as making a single function call.

Making multiple identical function calls has the same effect as making a single function call.

李铭昕 4 Oct 16, 2021
YCOM Impersonate. Login as selected YCOM user 🧙‍♂️in frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
A helper package to flash a bootstrap alert to the browser via a Facade or a helper function.

Alert Box (Laravel) A helper package to flash a bootstrap alert to the browser via a Facade or a helper function. <div class="alert alert-info fade in

Ben-Piet O'Callaghan 17 Dec 30, 2022
Database lookup tool in php, skidlookup has not been claimed so if u want to use this src all right's go to u, idea came from fedsearch

skidlookup Database lookup tool in php, skidlookup has not been claimed so if u want to use this src, all right's go to u, idea came from fedsearch in

Nano 12 Dec 1, 2021