Skip to content

[QA] fix-encrypted-version prints weird output while doing nothing #256

Closed
owncloud/core
#38567

Description

@jnweiger

Seen with encryption 1.5.0RC1 in owncloud 10.7.0RC1

  • enable encryption.
  • setup an external SFTP drive and configure it without encryption.
  • move 'ownCloud Manual.pdf' into the SFTP folder.
  • inspect the contents of the FTP server manually. The pdf is unencrypted. OK
  • run
    occ encryption:fix-encrypted-version -p SFTP/ownCloud\ Manual.pdf admin
Verifying the content of file /admin/files/SFTP/ownCloud Manual.pdf
Attempting to fix the path: /admin/files/SFTP/ownCloud Manual.pdf
Increment the encrypted version to 2
Increment the encrypted version to 3
Increment the encrypted version to 4
Increment the encrypted version to 5
Increment the encrypted version to 6
  • inspect the contents of the FTP server manually. The pdf is still unencrypted. Okayish. (What did it do???)

The amount of output increases on each invocation. The file never changes:

occ encryption:fix-encrypted-version -p SFTP/ownCloud\ Manual.pdf admin

Verifying the content of file /admin/files/SFTP/ownCloud Manual.pdf
Attempting to fix the path: /admin/files/SFTP/ownCloud Manual.pdf
Decrement the encrypted version to 5
Decrement the encrypted version to 4
Decrement the encrypted version to 3
Decrement the encrypted version to 2
Decrement the encrypted version to 1
Increment the encrypted version to 7
Increment the encrypted version to 8
Increment the encrypted version to 9
Increment the encrypted version to 10
Increment the encrypted version to 11

occ encryption:fix-encrypted-version -p SFTP/ownCloud\ Manual.pdf admin

Verifying the content of file /admin/files/SFTP/ownCloud Manual.pdf
Attempting to fix the path: /admin/files/SFTP/ownCloud Manual.pdf
Decrement the encrypted version to 10
Decrement the encrypted version to 9
Decrement the encrypted version to 8
Decrement the encrypted version to 7
Decrement the encrypted version to 6
Decrement the encrypted version to 5
Decrement the encrypted version to 4
Decrement the encrypted version to 3
Decrement the encrypted version to 2
Decrement the encrypted version to 1
Increment the encrypted version to 12
Increment the encrypted version to 13
Increment the encrypted version to 14
Increment the encrypted version to 15
Increment the encrypted version to 16

These operations take progressively longer. Scary. What is it doing?
option -vvv does not reveal anything new.

Expected behaviour: Nothing is done. Just print The file /admin/files/SFTP/ownCloud Manual.pdf is: OK

Activity

  1. micbar commented on Mar 19, 2021

    @micbar
    Contributor

    This command is a maintenance command. It is totally unaware of its used context.

    Consider it as a tool for ownCloud support. It should be used on a file which encryption is broken.

  2. micbar commented on Mar 19, 2021

    @micbar
    Contributor

    @C0rby @IljaN We need to check if theMOVE operation leaves the DB in an inconsistent state.

    @jnweiger same here, please also repeat this test with WND storage.

  3. C0rby commented on Mar 19, 2021

    @C0rby
    Contributor

    @C0rby @IljaN We need to check if theMOVE operation leaves the DB in an inconsistent state.

    Setup:

    • encrypted primary storage
    • unencrypted sftp external storage

    Process

    • Create file in primary storage
    • File is encrypted
    • Move file to external storage
    • File is unencrypted
    • Sync with desktop client
    • File is synced and unencrypted in the desktop client folder

    We couldn't reproduce any errors.

  4. micbar commented on Mar 19, 2021

    @micbar
    Contributor

    @C0rby How is the db value from oc_filecache? The encrypted value should be 0 after the MOVE

  5. jnweiger commented on Mar 19, 2021

    @jnweiger
    ContributorAuthor

    I have reproduced a case without a prior MOVE operation and without involving SFTP:

    • docker run -ti -p 888:8080 owncloud/server:10.7.0-rc
    • docker exec into the machine, install and enable app encryption-1.5.0RC1
    • enable encryption , [x] home storage
    • add external storage type 'ownCloud' https://demo.owncloud.org demo/demo
      image
    • Navigate into the /ownCloud folder
    • Upload a photo.
    • docker exec into the test machine, run
    root@e5f42b33ddee: /mnt/data/files/admin/files # occ encry:fix -p /ownCloud/photo_2020-04-29_17-19-39.jpg admin
    Verifying the content of file /admin/files/ownCloud/photo_2020-04-29_17-19-39.jpg
    Attempting to fix the path: /admin/files/ownCloud/photo_2020-04-29_17-19-39.jpg
    Increment the encrypted version to 2
    Increment the encrypted version to 3
    Increment the encrypted version to 4
    Increment the encrypted version to 5
    Increment the encrypted version to 6
    
    
    
    • Login to demo.owncloud.org, demo/demo
    • Upload a Screenshot png to the Documents folder
    • docker exec into the test machine, run
    root@e5f42b33ddee: /mnt/data/files/admin/files # occ encry:fix -p '/ownCloud/Screenshot from 2021-03-15 00-27-12.png' admin
    Verifying the content of file /admin/files/ownCloud/Screenshot from 2021-03-15 00-27-12.png
    The file /admin/files/ownCloud/Screenshot from 2021-03-15 00-27-12.png is: OK
    
    
    • This Screenhot png has no history in the test machine. It remains unencrypted. OK
    • move the Screenshot png to home folder, move it back to /ownCloud external storage
    • it gets encrypted (demo.owncloud.org sees it as a corrupt Screenshot png). Okayish
    • docker exec into the test machine, run
    root@e5f42b33ddee: /mnt/data/files/admin/files # occ encry:fix -p '/ownCloud/Screenshot from 2021-03-15 00-27-12.png' admin
    Verifying the content of file /admin/files/ownCloud/Screenshot from 2021-03-15 00-27-12.png
    Attempting to fix the path: /admin/files/ownCloud/Screenshot from 2021-03-15 00-27-12.png
    Decrement the encrypted version to 1
    Increment the encrypted version to 3
    Increment the encrypted version to 4
    Increment the encrypted version to 5
    Increment the encrypted version to 6
    Increment the encrypted version to 7
    

    so yes, a MOVE can trigger the situation, but is not necessary.

  6. jnweiger commented on Mar 19, 2021

    @jnweiger
    ContributorAuthor

    (sorry for using the fix tool again. I understand is has no real life usage here. But I hope it points us to the core of the issue.)

  7. jnweiger commented on Mar 19, 2021

    @jnweiger
    ContributorAuthor

    In case of an externl ownCloud storage, I suggest encryption should be default disabled. or even hardcoded disabled.
    I feel sorry for the poor users of demo.owncloud.org seeing my "aparently corrupt" jpg files. 😕

  8. C0rby commented on Mar 19, 2021

    @C0rby
    Contributor

    @C0rby How is the db value from oc_filecache? The encrypted value should be 0 after the MOVE

    Oh right... this wasn't about error while synching but about inconsistent state. The encrypted value was not 0. 😞

  9. C0rby commented on Mar 19, 2021

    @C0rby
    Contributor

    (sorry for using the fix tool again. I understand is has no real life usage here. But I hope it points us to the core of the issue.)

    No need to be sorry. I think that's what @micbar is thinking.

    • Create file in encrypted primary storage
      • encrypted value in filecache is not 0
    • Move file to unencrypted external storage
      • File is not encrypted but encrypted value is still not 0
    • execute fix-encrypted-version command
      • it looks for all files where encrypted != 0 but some of those files (in external storage) are not encrypted

    And that could throw off the fix command.

  10. IljaN commented on Mar 19, 2021

    @IljaN
    Contributor

    In case of an externl ownCloud storage, I suggest encryption should be default disabled. or even hardcoded disabled.
    I feel sorry for the poor users of demo.owncloud.org seeing my "aparently corrupt" jpg files.

    +1, especially because the more common case is that the external storage is used by other clients or applications than ownCloud, or isn't it?

  11. C0rby commented on Mar 19, 2021

    @C0rby
    Contributor

    In case of an externl ownCloud storage, I suggest encryption should be default disabled. or even hardcoded disabled.
    I feel sorry for the poor users of demo.owncloud.org seeing my "aparently corrupt" jpg files. confused

    Disabled by default maybe, but hardcoded disabled is not a good idea in my opinion. Wasn't the purpose of the encryption module to be able to store files on (external) storages you don't trust? Hardcoded disabling this would remove that option.

  12. jnweiger commented on Mar 19, 2021

    @jnweiger
    ContributorAuthor

    In case of an externl ownCloud storage, I suggest encryption should be default disabled. or even hardcoded disabled.
    I feel sorry for the poor users of demo.owncloud.org seeing my "aparently corrupt" jpg files. confused

    Disabled by default maybe, but hardcoded disabled is not a good idea in my opinion. Wasn't the purpose of the encryption module to be able to store files on (external) storages you don't trust? Hardcoded disabling this would remove that option.

    Encryption is perfectly fine fine for any type of external storage, except for the type "ownCloud", where the files are hosted at another ownCloud instance. Only in this case I'd like to discuss default disable or hard off.

    It may lead to very odd situations. Users at the hosting ownCloud instance see these files as corrupt files. A confused admin at the hosting ownCloud instance may even recognize the files as encrypted owncloud files, and try to fix the encryption ... -> Chaos.

  13. jnweiger commented on Mar 20, 2021

    @jnweiger
    ContributorAuthor

    Same problem (and more) also seen on WND -> #257

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions