-
Notifications
You must be signed in to change notification settings - Fork 0
Fix missing hash verification #49
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -270,30 +270,26 @@ public void downloadPackage(JSONObject updatePackage, String expectedBundleFileN | |
| String signaturePath = CodePushUpdateUtils.getSignatureFilePath(newUpdateFolderPath); | ||
| boolean isSignatureAppearedInBundle = FileUtils.fileAtPathExists(signaturePath); | ||
|
|
||
| if (isSignatureVerificationEnabled && !isSignatureAppearedInBundle) { | ||
| throw new CodePushInvalidUpdateException( | ||
| "Error! Public key was provided but there is no JWT signature within app bundle to verify. " + | ||
| "Possible reasons, why that might happen: \n" + | ||
| "1. You've been released CodePush bundle update using version of CodePush CLI that is not support code signing.\n" + | ||
| "2. You've been released CodePush bundle update without providing --privateKeyPath option." | ||
| ); | ||
| } | ||
|
|
||
| if (!isSignatureVerificationEnabled && isSignatureAppearedInBundle) { | ||
| CodePushUtils.log( | ||
| "Warning! JWT signature exists in codepush update but code integrity check couldn't be performed because there is no public key configured. " + | ||
| "Please ensure that public key is properly configured within your application." | ||
| ); | ||
| } | ||
|
|
||
| CodePushUpdateUtils.verifyFolderHash(newUpdateFolderPath, newUpdateHash); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acceptable, the non-ZIP update codepath is considered legacy, we don't recommend generating plain JS bundle updates (fortunately, only around 1% of our users do). It's not just the integrity check that's missing from this codepath, but also code signing. |
||
|
|
||
| if (isSignatureVerificationEnabled) { | ||
| if (isSignatureAppearedInBundle) { | ||
| CodePushUpdateUtils.verifyFolderHash(newUpdateFolderPath, newUpdateHash); | ||
| CodePushUpdateUtils.verifyUpdateSignature(newUpdateFolderPath, newUpdateHash, stringPublicKey); | ||
| } else { | ||
| throw new CodePushInvalidUpdateException( | ||
| "Error! Public key was provided but there is no JWT signature within app bundle to verify. " + | ||
| "Possible reasons, why that might happen: \n" + | ||
| "1. You've been released CodePush bundle update using version of CodePush CLI that is not support code signing.\n" + | ||
| "2. You've been released CodePush bundle update without providing --privateKeyPath option." | ||
| ); | ||
| } | ||
| } else { | ||
| if (isSignatureAppearedInBundle) { | ||
| CodePushUtils.log( | ||
| "Warning! JWT signature exists in codepush update but code integrity check couldn't be performed because there is no public key configured. " + | ||
| "Please ensure that public key is properly configured within your application." | ||
| ); | ||
| CodePushUpdateUtils.verifyFolderHash(newUpdateFolderPath, newUpdateHash); | ||
| } else { | ||
| if (isDiffUpdate) { | ||
| CodePushUpdateUtils.verifyFolderHash(newUpdateFolderPath, newUpdateHash); | ||
| } | ||
| } | ||
| CodePushUpdateUtils.verifyUpdateSignature(newUpdateFolderPath, newUpdateHash, stringPublicKey); | ||
| } | ||
|
|
||
| CodePushUtils.setJSONValueForKey(updatePackage, CodePushConstants.RELATIVE_BUNDLE_PATH_KEY, relativeBundlePath); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How likely it is in the wild? Can you release an app without signing it to the store (if not, that app should in practice always have a public key)?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't about code signing the native app itself, it's just the CodePush OTA upload. And CodePush updates are not code-signed by default, we don't enforce this. Other products also don't enfoce code signing, in fact, Expo limits this feature to their highest paid tiers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will provide the
stringPublicKeyused for theisSignatureVerificationEnabled?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming from here:
react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java
Line 395 in 4c56dfa
Essentially, this is coming from the app's
strings.xmlThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the public key in strings.xml and Info.plist is optional or mandatory?