Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Vulnerabilities #35

Open
paragonie-security opened this issue May 8, 2024 · 0 comments
Open

Security Vulnerabilities #35

paragonie-security opened this issue May 8, 2024 · 0 comments

Comments

@paragonie-security
Copy link

Insecure Key Management

This is not a secure way to derive a secret. You're hashing data using SHA256, hex-encoded, then only extracting 16 hex characters.

$salt = substr(hash('sha256', config('laravelDatabaseEncryption.encrypt_key')), 0, 16);

$salt = substr(hash('sha256', config('laravelDatabaseEncryption.encrypt_key')), 0, 16);

This gives you an output that is the square root of the security you expect.

This is also called a "salt" but it's actually an AES key, as we'll see in the next section.

Insecure Encryption

AES_ENCRYPT() encrypts data using ECB mode, and also exposes your key (called a "salt" per the previous section) to anyone capable of running SHOW PROCESSLIST on the server.

$data = DB::table($parameters[0])->whereRaw("CONVERT(AES_DECRYPT(FROM_BASE64(`{$parameters[1]}`), '{$salt}') USING utf8mb4) = '{$value}' ");

$data = DB::table($parameters[0])->whereRaw("CONVERT(AES_DECRYPT(FROM_BASE64(`{$parameters[1]}`), '{$salt}') USING utf8mb4) = '{$value}' ");

Recommendations

Fixing these vulnerabilities would require rearchitecting this library from the ground up with secure data encryption practices in mind. If you managed to make it secure, it would not be compatible with the current implementation. Therefore, you would be better off starting over from scratch.

We have an open source library that provides secure searchable field-level encryption that may be a better starting point than AES_ENCRYPT().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant