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

Moving encrypted files with rename() leaves them unencrypted on disk #22

Closed
TravisCarden opened this issue Jul 25, 2016 · 3 comments
Closed
Labels

Comments

@TravisCarden
Copy link
Contributor

TravisCarden commented Jul 25, 2016

PHP does not necessarily call the stream_close() method on stream wrappers every time it calls stream_open(). For example, when copying a file (copy()) it calls both, but when moving a file (rename()) it does not. The result is that renaming a file using EncryptStreamWrapper decrypts the file but does not re-encrypt it, leaving it unencrypted on disk. And when core issue file_unmanaged_move() should issue rename() where possible instead of copy() & unlink() [#1377740] landed (8.1.4), this problem became acute. I discovered this by way of the dropzonejs entity browser widget, which uses file_unmanaged_move() to save new uploads. I played around with moving the encryption to a different method (i.e., stream_write()), but without success. It has been suggested to me that we shouldn't be using stream wrappers to solve this problem in the first place--that encryption is a job for PHP stream filters instead. (Perhaps switching to filters would help with #5, too.) @dawehner

@nerdstein
Copy link
Contributor

Please follow this: defuse/php-encryption#283

@dawehner dawehner added the bug label Jul 29, 2016
@dawehner
Copy link
Contributor

This issue, given its security implications, is certainly critical.

I'll try to experiment more with stream filters, which also would give us more experience to maybe solve the streaming aspect of things

@TravisCarden
Copy link
Contributor Author

Moved to https://www.drupal.org/node/2802455.

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

No branches or pull requests

3 participants