Skip to content

Kotlin decryption. Test decryption errors after moving to use PGPainless for the message decryption #1360

Closed

Description

@DenBond7

It would be nice to have such tests. I think it's very important to prevent security bugs (for example after upgrading PGPainless to a newer version). We should be sure that a received content is parsed to expected blocks and Android shows the expected UI.

Activity

  1. added this to the 1.2.1 milestone on Jul 22, 2021
  2. self-assigned this
    on Jul 22, 2021
  3. DenBond7 commented on Jul 22, 2021

    @DenBond7
    CollaboratorAuthor

    I'm talking about things like this one

    image

  4. DenBond7 commented on Jul 22, 2021

    @DenBond7
    CollaboratorAuthor

    @tomholub It would be nice to create a list of the decryption errors that we would like to handle. I think it will be useful for all platforms

  5. tomholub commented on Jul 22, 2021

    @tomholub
    Collaborator

    Yes. All error scenarios that are interesting are represented in flowcrypt.compatibility account as email messages, so we can extract them from there (as you have done)

  6. tomholub commented on Jul 22, 2021

    @tomholub
    Collaborator

    tests/decrypt error label should have most of them. If you see any that are (expected) errors and not labeled that way, feel free to add the label, so that they are all in one place.

  7. changed the title [-]Test decryption errors after moving to use PGPainless for the message decryption[/-] [+]Kotlin decryption. Test decryption errors after moving to use PGPainless for the message decryption[/+] on Sep 17, 2021
  8. DenBond7 commented on Sep 23, 2021

    @DenBond7
    CollaboratorAuthor

    tests/decrypt error label should have most of them. If you see any that are (expected) errors and not labeled that way, feel free to add the label, so that they are all in one place.

    For now, I see the following decryption errors

    • 1. WRONG CHECKSUM - Message is either badly formatted or not compatible with FlowCrypt
    • 2. NO_MDC - Security threat. The message is missing integrity checks (MDC)
    • 3. BAD_MDC - Security threat. Opening this message is dangerous because it was modified in transit
    • 4. KEY_MISMATCH - Message encrypted for public keys that don't match(An active account doesn't have a right private key). A message encrypted for another public key (only one public key used, the sender public key)
    • 5. FORMAT - take any armored message, remove some lines from the middle, and then try to read it.
    1. OTHER - when it throws some exception we don't recognize.
  9. tomholub commented on Sep 23, 2021

    @tomholub
    Collaborator

    5 and 6 are the same thing - should be returning KEY_MISMATCH error

    Also there is FORMAT error - take any armored message, remove some lines from the middle, and then try to read it.

    Encrypted message inside signed

    This one doesn't really sound like an error.

  10. DenBond7 commented on Sep 23, 2021

    @DenBond7
    CollaboratorAuthor

    Updated

  11. tomholub commented on Sep 23, 2021

    @tomholub
    Collaborator

    On browser extension I also have "other" when it throws some exception I don't recognize.

  12. tomholub commented on Sep 23, 2021

    @tomholub
    Collaborator

    I suppose you have something similar

  13. DenBond7 commented on Sep 23, 2021

    @DenBond7
    CollaboratorAuthor

    Updated

  14. DenBond7 commented on Sep 24, 2021

    @DenBond7
    CollaboratorAuthor

    @tomholub Please look at the following screenshots. Do they look good?

    WRONG CHECKSUM

    image

    NO_MDC

    image

    BAD_MDC

    image

    KEY_MISMATCH

    image

    FORMAT

    image

  15. tomholub commented on Sep 24, 2021

    @tomholub
    Collaborator

    It's all good for now. For the mdc checks missing/wrong, eventually we'll show the content of the decrypted message instead of the armor, but that is already filed for later #1363 (comment)

    else good

  16. DenBond7 commented on Sep 25, 2021

    @DenBond7
    CollaboratorAuthor
    1. BAD_MDC - Security threat. Opening this message is dangerous because it was modified in transit

    @tomholub Do you know how to reproduce this error? I need to have it for flowcrypt.test

  17. DenBond7 commented on Sep 25, 2021

    @DenBond7
    CollaboratorAuthor

    NO_MDC - Security threat. The message is missing integrity checks (MDC)

    For history. To reproduce this error we can use an old version of GnuPG. For example GnuPG 1.4

    via gpg --encrypt --sign --armor --disable-mdc -r fingerprint we can create a PGP message without MDC like this one

    -----BEGIN PGP MESSAGE-----
    
    hQIMA3LvK1JdDBkzAQ//RjLOB+l/hvljxS+WamHcsx6JH4YVWcrElifdlmmFTB0z
    R+F3mlJXLLAbpwAs0hLpfpsI+cpf3Ori67FfGyQPxCY3O0ilamPIvaJm7CqBJ08Y
    c0zwVXpmOfAj0cv3NtPKERx88LgukolLk72m5UV2jVKv5fwH685B202rO08GcCt6
    GO8CfvyzMv42ys8KgiPkZd8snY9NBT5918nHqHywBFmU9N3suiLM2nKvvFsg+bAg
    +0yGkhrFxyWuoL+OYiytR1rutDQjiqwBM7rWvwNFqN3hcBtY46qqQNq0PMe2n1Xm
    1fcYI2ESganoO6Ovt2m5LbEyRAJYbVpeTAe/zS1EcmF7Abcn4Zy6mrWi+7eaVfju
    8zhE4rxCxkQCFLb+bNc5hBl7ZTT7u7PcoRVGG8KSJc401ztef14RpzzpyP/RIhpq
    V4m88VZ9yimr7eIvGPG2WHW445JCq47iu61j8FyVnscgFCMNTyn3t2k/IS/dyVEA
    PeN36NUBhd8rM5i6WopO9szqFtwNI0Y9+xvjy07OBueU0enmxA3dcdq21Zc80F/3
    kkyD7W5dh4p4uBFzyL/o187hSlqGFk2+d9d6qDKVm7Ff3cY2ivF8SHXjtYk9kau2
    ZhFyoT8D1Jf3sYxCOdj72FyByPv/ugrxce/wu9bVBZbw7WDxcxmgvEsXv+UxTTrJ
    wKHaEMxIbu1scpeSVUEaaAKeiviCkkC5m8jHTpjCmcVt8Sl8ucw/m5AwWIJosR20
    0NmxsgsEhT10fyuynWi3JhDpi+Z+TPTAxNgTqHR5pCBga/gyAQUbpNcWASylp6qa
    AmqrP2IFEhED6MUmxcNLomIscRVUSS29+JHJZ7RLKORKymJq2stMnpuntwV+Hq7P
    ZqSyI7YtiUvgFsINTdpydAWmIEkSOfIDNoDFDEcxFa7AYz72YEVUHVuuS5pmJ/A+
    fmkvS74gJMTqf7NYRE40uUUF9gPCS86qOeyzlYqxYdCZ0ipDrUQEMFNSgwLVuDBH
    EM23JNOSs13nABklfWYkS9AAV1WYn/UxOHgBPspS1I+izTt2DQmjCd7RChk6a12K
    R8C2GYrhhlsqMNZhwaI6gGKEg5yD2Ru3oVZPGrdifMaAu1mbOVzUHfJTFzzH/2xe
    AD30MkqtGBtQ0rBnaMC4E8+JIA==
    =5QII
    -----END PGP MESSAGE-----
    

    I've used the following link to set up GnuPG on docker

  18. tomholub commented on Sep 25, 2021

    @tomholub
    Collaborator

    You can extract message with subject encrypted - MDC hash mismatch - modification detected - should fail from compatibility account

  19. tomholub commented on Sep 25, 2021

    @tomholub
    Collaborator

    NO_MDC is different from BAD_MDC. First case there is no checksum, in second case there is checksum but it's wrong.

  20. added a commit that references this issue on Sep 25, 2021
  21. DenBond7 commented on Sep 25, 2021

    @DenBond7
    CollaboratorAuthor

    You can extract message with subject encrypted - MDC hash mismatch - modification detected - should fail from compatibility account

    it requires adding keys(with a passphrase) of flowcrypt.compatibility to the Android emulator. I don't like that idea. The best would be to create a PGP message with BAD_MDC for flowcrypt.test accounts. If it sounds too difficult I think we can leave it as is(or for later). We handle BAD_MDC via JUnit tests(PGPainless). On Android(Instrumentation tests with UI), we have tests for all decryption errors, except BAD_MDC(we handle it, but don't have a UI test)

  22. tomholub commented on Sep 25, 2021

    @tomholub
    Collaborator

    sounds ok to me to leave it for now

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

Metadata

Metadata

Assignees

Labels

android_testingThis label means we need to add an Android test.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions