wordpress-mobile / wordpress-mobile/WordPress-iOS

The app crashes for external developers when uploading encrypted logs

Open
#18,583 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

[Type] Crash Tooling
Dominant language
Swift
Stars
3.9k
Forks
1.2k
Avg merge
23h 51m
Merged PRs (30d)
58

Description

This issue only happens for external contributors.

Expected behavior

The app doesn't crash.

Actual behavior

The app crashes at LogEncryptor.swift in Tracks:

    internal func encryptSecretWithSodium(secret: Bytes) throws -> Bytes {
        // Crash due to force-unwrapping a nil value.
        return sodium.box.seal(message: secret, recipientPublicKey: publicKey)! 
    }
Steps to reproduce the behavior
  1. Follow the Build Instructions in README.
  2. Checkout WordPress/Credentials/Secrets.swift file, encryptedLogKey property value is an empty string.
  3. Build and run the app onto an iOS simulator. App may crash at this step, if there is any encrypted log. Otherwise, please continue.
  4. Log in with a wordpress.com account.
  5. Navigate to "Encrypted Logs" screen: Your avatar -> App Settings -> 🐞 Debug -> Encrypted Logs.
  6. Tap the "+" button. App crashes.
Workaround

This crash is due to missing ApiCredentials.encryptedLogKey. You can generate one by running following command and use it in your WordPress/Credentials/Secrets.swift file.

ruby -e 'require "base64"; puts Base64.encode64(Random.bytes(32))'

With this workaround, the app won't crash, but there will be (harmless?) error logs in debug console, something like this:

2022-05-12 16:32:05:188 WordPress[90804:3142275] 📜 Error uploading encrypted log: 8310122D-4328-4D4E-8CF0-787B79431D4E
2022-05-12 16:32:05:189 WordPress[90804:3142275] 📜	too_many_requests
2022-05-12 16:32:05:189 WordPress[90804:3142275] 📜	 Code: 429
2022-05-12 16:32:05:189 WordPress[90804:3142275] 📜	 Details: You're sending too many messages. Please slow down.
Tested on an iOS simulator in Xcode 13.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in LogEncryptor.swift at encryptSecretWithSodium and inspect how the empty encryptedLogKey from WordPress/Credentials/Secrets.swift reaches the force unwrap. Reproduce with an external-contributor build using the listed simulator steps and check the Encrypted Logs flow. Done means uploading or opening that flow no longer crashes when the key is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
mobile, security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.