wordpress-mobile / wordpress-mobile/WordPress-iOS
The app crashes for external developers when uploading encrypted logs
Nobody has claimed this yet.
- 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
- Follow the Build Instructions in README.
- Checkout
WordPress/Credentials/Secrets.swiftfile,encryptedLogKeyproperty value is an empty string. - Build and run the app onto an iOS simulator. App may crash at this step, if there is any encrypted log. Otherwise, please continue.
- Log in with a wordpress.com account.
- Navigate to "Encrypted Logs" screen: Your avatar -> App Settings -> 🐞 Debug -> Encrypted Logs.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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