php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #76071 function.openssl-encrypt php 5.6 code example it poor from a security standpoin
Submitted: 2018-03-09 07:36 UTC Modified: 2019-01-13 04:22 UTC
From: junk at gathond dot dk Assigned:
Status: No Feedback Package: OpenSSL related
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
34 + 5 = ?
Subscribe to this entry?

 
 [2018-03-09 07:36 UTC] junk at gathond dot dk
Description:
------------
---
From manual page: http://www.php.net/function.openssl-encrypt
---
The example code has a few items which if not downright security issues, at least is bad practice from a security POV.

issue 1: 
The IV should be included in the HMAC calculation, otherwise this is left open to manipulation. 

issue 2: 
When decrypting the MAC should be verified before attempting to decrypt the contents, otherwise any timing impacts on the decryption itself may still leak information about the correctness of the guess.

Because of issue 1 it would probably also be better to reorder the data in the example so it is $iv.$ciphertext_raw.$hmac instead.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-01 22:18 UTC] girgias@php.net
-Status: Open +Status: Feedback -Package: Documentation problem +Package: OpenSSL related -Operating System: ANY +Operating System: N/A
 [2019-01-01 22:18 UTC] girgias@php.net
Is this still the case?
Moreover, would it be possible to add a patch using the online editor, located at https://edit.php.net ?
 [2019-01-13 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2019-01-13 11:15 UTC] junk at gathond dot dk
Is this good enough, and you you meant by a patch through the online editor?

http://edit.php.net/?patch=en/reference/openssl/functions/openssl-encrypt.xml&project=PHP

Otherwise let me know
 [2019-01-13 11:20 UTC] junk at gathond dot dk
I'm unable to change the status though, I just get a message saying I'm not allowed to do so.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 06:03:37 2021 UTC